Below is the dependencies version i am using :
WebDriverManager-versioned 3.6.1
(Gecko driver versioned 0.24.0)
Firefox versioned 68.0.1 64 bit Windows 10
Selenium version 3.141.59
I have a maven -selenium project with 10+ test classes in testNG.
When i execute these classes on Chrome browsers ,each test class gets executed successfully .
Same test classes when i execute on Firefox using the (WebDriverManager-Gecko driver) the test classes execute for some time say 5-10 seconds and then abruptly closes and opens next test class for execution ,even this test class execute for some time and then closes .
Same thing happens with each test class.
I have tried to manually use geckodriver.exe and set up system properties, still it doesnt fix the error
Below is the code i have used for WebDriverManager
if (browser.equals("chrome")) {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
}
if (browser.equals("firefox")) {
WebDriverManager.firefoxdriver().setup();
driver = new FirefoxDriver();
}
This is the link for the stack trace
There must be version discrepancy, just make sure your firefox version is compatible with the gecko driver and then try again.
Assuing the versions are compatible, Check with the below code while calling the driver.
System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
driver = new FirefoxDriver();
Related
I am using Internet Explorer driver 4.0.0(32bit) and selenium updated version 4.1.2when I run the code using Internet Explorer driver 4.0.0 it is stuck at This is the initial start page for the WebDriver server.
even though I check the setting in Internet Explorer:
All the protected mode is disabled
zoom setting is 100% for Internet Explorer and windows also
enchanted protected mode is off
but when I change the Internet Explorer driver to 3.1.4 it works fine. I also tried the Internet Explorer 4.0.0 for 64 but the same issue I am facing please help me.
public class EdgeTest {
static RemoteWebDriver driver = null;
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.ie.driver",
"D:\\Automation\\Jar Details\\Drivers\\IEDriverServer_Win32_4.0.0\\IEDriverServer.exe");
InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.attachToEdgeChrome();
ieOptions.withEdgeExecutablePath("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");
ieOptions.setCapability("ignoreProtectedModeSettings", true);
ieOptions.setCapability("ignoreZoomSettings",true);
System.out.println("this:"+ieOptions.getCapability("ignoreZoomSettings"));
driver = new InternetExplorerDriver(ieOptions);
InternetExplorerDriverService.createDefaultService();
driver.get("https://github.com/");
WebElement elem = driver.findElement(By.name("q"));
elem.sendKeys("gitu");
elem.sendKeys(Keys.ENTER);
driver.quit();
error: "Could not create a new remote session" this is an error
getting
It looks like you are using selenium webdriver to automate Edge IE mode. I tried executing your code and I found this code to work fine (using IE driver 4.0.0 and Selenium 4.1.2).
But when executing code again before the code has not been executed complete, you get the same problem you describe (execute code twice at once). like this:
So I think when the IE driver may be occupied, you can try to open the task manager, end the related task (IE driver 32 bit), and then re-execute the code, I think this should be useful to you.
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Write "webdriver.chrome.driver" instead of "webdriver.chrome.Driver"
Just lowercase instead of uppercase.
When you are setting the properties, you can't use uppercase
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/chromedriver.exe");
WebDriver driver = new ChromeDriver();
user.dir will take you to the current working directory.
Let me know if it works for you.
I am using Ubuntu 14 and installed Eclipse with compiler compliance level 1.7 using selenium 3.0. If I decrease the level to 1.4, it shows me error on sendkey() function. I set the property:
System.setProperty("webdriver.gecko.driver","/home/Rrrrr/Downloads/jars/geckodriver");
I use following code:
WebDriver driver;
driver = new FirefoxDriver();
System.setProperty("webdriver.gecko.driver","/home/Rrrrr/Downloads/jars/geckodriver");
driver.get("http://www.google.com");
but it still gives me following error. Is it version problem or any other?
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
If by compliance level you mean Java version then you must set it to 8. Have a look at the release notes for v3.0.0-beta1 where it says:
Minimum java version is now 8+
I Got solution over above code
"Sequence of code is wrong"
Sequence must be as follows
WebDriver driver;
System.setProperty("webdriver.gecko.driver","/home/Rrrrr/Downloads/jars/geckodriver");
driver = new FirefoxDriver();
I have following questions regarding seleniumn webdriver:
How does IEDriverServer.exe and Chromedriver. exe works. i.e. What happens when these exes are executed.
What is the significance of using these exes
These executables are used to run the webdrivers. These need to be specified in the System.setProperty. This is something that needs to be done for IE and Chrome but not for Firefox.
Running the .exe by themselves will probably do nothing.
Example Java Code for ChromeDriver:
System.setProperty("webdriver.chrome.driver","/.../chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get(URL);
I am trying to launch chrome browser (version 26.0) using webdriver.
I am getting the following error message.
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver.
at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:69)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
at googleSearch.main(googleSearch.java:13)
Code I used:
driver = new ChromeDriver();
driver.navigate().to("http://www.google.com/");
I use mac 10.8.2.
For this to work, you need to:
Install Chrome
Install Chrome Web Driver
Make sure you have the chrome web driver in you path, for example on Windows something pointing to chromedriver2_win32_0.8. You can put that in your path by either: (a) Modifying your windows path environment variable, or; (b) adding the following to your java command line options:
-Dwebdriver.chrome.driver='/path/to/driver'
In case of using selenium grid
-Dwebdriver.chrome.driver='/path/to/driver'
has to be added while creating a node from command line.
1) In case of using selenium without GRID:
System.setProperty("webdriver.chrome.driver","/absolute/path/to/chromedriver");
driver = new ChromeDriver();
does the job.
2) In case of using selenium with GRID:
System.setProperty("webdriver.chrome.driver","/absolute/path/to/chromedriver");
driver = new ChromeDriver();
And from command line, while creating a node for chrome browser one needs to pass
-Dwebdriver.chrome.driver='/absolute/path/to/chromedriver'
The above two changes did the job for me, apart from this I was getting this libnss3.so not found error which I solved by creating a symlink of libnss3.so present in /usr/lib/x86_64-linux-gnu/ folder to /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/libnss3.so
PS: Also make sure that you are using 64bit OR 32bit version of chrome driver as per your system.
For chrome to work with selenium-webdriver you need to have not only a working chrome browser installed, but also the chromedriver executable. Note that these are TWO different executable files that both need to be specified.
change the permission of file and then run your code again.
Open command prompt and navigate to directory where your chrome exe exists and write
chmod 777 filename
Hope it will solve your problem.