Selenium compatability with Firefox and Chrome - java

I am able to run the script successfully on Firefox and i am not able to run the same script on Chrome. Please help me in finding these issue.
Thanks

Hi to run test in chrome please call chrome driver like below
// call the Chrome driver as below first
System.setProperty("webdriver.chrome.driver", "D:\\eclipseProject\\##\\src\\com\\##\\chromedriver_win32\\chromedriver.exe");
// path to chrome exe that you have downloaded form given url (below)
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.seleniumhq.com"); // link to your web-table web page
now your script as same on firfox
// download chrome exe form this link http://docs.seleniumhq.org/download/

Related

Chrome Browser not opening in Selenium Webdriver

My chrome browser not opening in Selenium Webdriver .I have downloaded all things like chrome driver , selenium jars and chrome according to compatibility. I am using Intellij IDEA IDE.The code and version details are given below -
System.setProperty("webdriver.chrome.driver","C:\driver\chromedriver_win32.exe");
WebDriver driver = new ChromeDriver();
Versions:
Chrome:89.0.4389.90
IDE:IntelliJ IDEA : 203.7148.57
Chrome driver: https://chromedriver.storage.googleapis.com/index.html?path=89.0.4389.23/
Selenium Webdriver: selenium-java-4.0.0-beta-2
(I have tried with selenium old version as well)
Please give some suggestions .
Thanks .
Remove _win32 and than try
System.setProperty("webdriver.chrome.driver","C:\driver\chromedriver.exe");
WebDriver driver = new ChromeDriver();

When the below code is executed, firefox is showing error. I am using the latest version of java, eclipse, firefox, and WebDrive jar file

System.setProperty("webdriver.gecko.driver", "C:\\Users\\vinil\\Downloads\\geckodriver-v0.11.1-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.jobserve.com/in/en/Job-Search/");
driver.findElement(By.xpath("//*[#id='ddcl-selInd']/span/span")).click();
Thread.sleep(5000);
driver.quit();
[]
This happens on driver.quit() when you are closing the browser.
It is unfortunately known issue when quitting geckodriver firefox instance, see this links for details.
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/7506 https://bugzilla.mozilla.org/show_bug.cgi?id=1027222

Chrome browser is not opening in selenium webdriver

My code is not launching browser.
Project show running for a long time, but nothing happens. I pushed print and observed that WebDriver driver = new ChromeDriver(); is not getting executed.
package seleniumautomation;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
public class seleniumautomation {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","D:/selenium_java/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate().to("https://www.zaakpay.com/");
}
}
After some debugging, I am getting this new error:
I added manifest_vesion, but in every run, it is generating a new file and i am again getting same error.
Download jar from: http://chromedriver.storage.googleapis.com/index.html?path=2.23/
System.setProperty("webdriver.chrome.driver",
"<Downloaded file location>");
WebDriver driver = new ChromeDriver();
driver.get("https://www.zaakpay.com/");
Then, it will work.
To use Chrome Browser needs to System.setPropert("webdriver.chrome.driver","PATH")
The ChromeDriver is maintained / supported by the Chromium project iteslf. WebDriver works with Chrome through the chromedriver binary.
Download Link of ChromeDriver : LINK
You need to add chromedriver.exe(can be downloaded from http://www.seleniumhq.org/download/) to your project. Along with it, you need to add following lines in your code:
System.setProperty("webdriver.chrome.driver", PATH_TO_EXE_FINAL);
capabilities= DesiredCapabilities.chrome();
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
Use following code snippet to launch chrome driver.
System.setProperty("webdriver.chrome.driver", PATH_TO_EXE_FINAL);
ChromeOptions opt = new ChromeOptions();
opt.addArguments("disable-extensions");
opt.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(opt);
I solved the issue by changing my OS windows 10 language to english. selenium methods can not execute some other languages. If in both IE, geckodriver and chrome you are having the same issue it is language problem I can asuure you
enter image description hereTrying to check the version you installed in web driver and the version you currently use in you chrome

Selenium not able to identify the newly opened window in the IE browser

I am not able to identify a newly opened window in my application.
After using driver.get("my app url") when I try to click on any object, I am getting org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window.
I replicated the same issue on flipkart website using the below code :
System.setProperty("webdriver.ie.driver","path to IEDriverServer.exe);
WebDriver driver = new InternetExplorerDriver();
driver.get("https://www.flipkart.com");
Thread.sleep(10000); // just for sample
driver.findElement(By.linkText("24x7 Customer Care")).click();
But when I run it I am getting NoSuchWindowException.
It is working fine in chrome and Firefox browser.
Selenium Version =2.53.0 ,
OS= Windows7
I tried by adding ignoreProtectedMode and IntroduceFlakinessByIgnoringSecurityDomains capabilities as well but even that is working.
Kindly assist.
Use this it works for you
System.setProperty("webdriver.ie.driver", "path to IEdriverServer.exe" );
WebDriver driver =new InternetExplorerDriver();
driver.manage().window().maximize();
driver.get("https://www.flipkart.com");

How to run selenium tests in Chrome browser?

I have some tests using JUnit and Selenium, and I need to run it on the Chrome browser. I downloaded the Chrome driver, and configure my SetUp() as:
#Before
public void SetUp() throws Exception{
System.setProperty("webdriver.chrome.driver","");
driver = new ChromeDriver();
baseUrl = ;
driver.get(baseUrl);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);//Wait 5 seconds to load the page
}
The ChromeDriver.exe are added in my "Referenced Libraries" folder.
When I'll run the tests, the following error is displayed:
java.lang.exception: No runnable methods
Anybody know how can I fix this?
SOLUTION
1º Add the chromedriver in the path of your computer.
2º Update your setProperty as: System.setProperty("webdriver.chrome.driver","C:\\Users\\pedro_nazario\\Desktop\\ChromeDriver\\chromedriver.exe");
The second parameter must be the way where is your Chromedriver.exe in my case, the chromedriver are in a folder on desktop.
The most important thing, that you never forget
When you'll run the tests, before, close your Chrome browser completely. Any chrome browser must be open before you run your tests. If have some chrome browser opened, the selenium will take a error in your screen.
According to the documentation, webdriver.chrome.driver should contain the path to the chromedriver executable:
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
Alternatively, you can add path to the chromedriver to the PATH environment variable.

Categories