Exception running with Selenium WebDriver - selenium-webdriver

I just installed Selenium WebDriver. When I run, I got the following exception.
Can anyone help me how to fix it Please?
Exception in thread "main" java.lang.IllegalStateException:
The driver executable does not exist: C:\Users\Owner\workspace\Second
Time Jave Project\path of\geckodriver.exe at
com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at
org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:121)
at
org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:116)
at
org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:37)
at
org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:95)
at
org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at
org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:247)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:242)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:135)
at secondTimePackage.NewJavaClass.main(NewJavaClass.java:17)

Have you installed your web driver? Once you do, you'll need to set your system property:
System.setProperty("webdriver.gecko.driver", "[your file path to your web driver here]");
before you call your new Firefox Driver.
Looks like you're having the a similar problem to this question:
Firefox browser is not opening with selenium webbrowser code

Related

selenium browser launch by octopus [duplicate]

The release notes for ChromeDriver 2.33 says that ""Fixes a bug which caused Resizing/Positioning Window commands to fail on Chrome 62+" however this still seems to be an issue when i am using Chrome 62+ browser. Maximizing chrome window using chrome driver results in below exception. Does anyone know a solution please?
Another thing i noticed is, though i installed latest chromedriver (v2.33) from https://chromedriver.storage.googleapis.com/index.html?path=2.33/, the log printed below says Driver info: chromedriver=2.25.426923 !!
Exception in thread "main" org.openqa.selenium.WebDriverException:
unknown error: cannot get automation extension from unknown error:
page could not be found:
chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=62.0.3202.62) (Driver info:
chromedriver=2.25.426923
(0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT
10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
There are exactly 2 issues.
As you mentioned, you have installed latest chromedriver (v2.33) but the log printed below says Driver info: chromedriver=2.25.426923, this issue must be addressed first. You can consider to manually kill all the dangling chromedriver.exe tasks from the Task Manager. Additionally you can consider to use CCleaner to wipe out all the rotten OS stuffs from your system. Take a system reboot if required. Finally ensure that what ever the absolute location of chromedriver.exe you are using within System.setProperty() ensure that the chromedriver binary is of version 2.33.
Finally, it is suggested to use ChromeOptions class to maximize the Web Browser as follows:
System.setProperty("webdriver.chrome.driver", "C:\\your_directory\\chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.addArguments("disable-infobars");
opt.addArguments("--start-maximized");
opt.addArguments("--disable-extensions");
WebDriver driver = new ChromeDriver(opt);
driver.get("https://google.com");
Here are some of the alternatives which may solve your question:
Using maximize() from WebDriver.Window interface :
driver.manage().window().maximize();
Using setSize(Dimension targetSize) from WebDriver.Window interface:
driver.manage().window().setSize(new Dimension(800, 600));
Using addArguments("--start-maximized") through ChromeOptions:
chromeOptions.addArguments("--start-maximized");
Using addArguments("--window-size=1920,1080") through ChromeOptions:
chromeOptions.addArguments("--window-size=1920,1080");
Using executeScript() from JavaScriptExecutor interface:
((JavaScriptExecutor)driver).executeScript("window.resizeTo(1024, 768);");
You can find a related discussion in Chrome - org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension at driver.manage().window().maximize();.
I believe there were some old chrome driver processes running in backend and same were being picked up when it was invoked via code. I deleted all processes instances, deleted old version of chrome driver, added the new 2.33 version and it worked. Thanks all for your suggestions.
I think the reason behind it may be your chrome version. Try again with updating your chrome browser. I have faced this type of issues for compatibility between chrome browser & the driver
Use class ChromeOptions.
System.setProperty("webdriver.chrome.driver", "h:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
options.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(options);
driver.get(url);

Error in Selenium Webdriver

Now, I am started to learn Selenium WebDriver.I have got the following error.
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.
Does anyone know how to resolve this error?
It seems like you are using latest version of selenium. Unlike older versions, wherein you don't need to set system property for browser driver executable in case of firefox, the System.setProperty("path to geckodriver.exe") is required to be mentioned in code.
This should resolve your issue

I am getting the following exception while launching face book using chrome browser in Selenium can any one suggest me the solution for this

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 at
com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at
org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at
org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)
at
org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at
org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at
org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:116)
at New.HelloWorld.main(HelloWorld.java:16)
You need to use this code to set the location of chromedriver before initializing the driver. Use the method setProperty(String key, String path):
System.setProperty("webdriver.chrome.driver", "/tpt/chromedriver.exe");

FirefoxWebdriver on remote machines

Is it required to install the Firefox web driver on the remote machines acting as node or hub?
I tested the hub and nodes locally? I think, it is necessary to install the web driver on the hub and node. Any comments or suggestions?
Update:
Selenium jars are running (i.e. Java is installed and web driver also exists within the selenium jar as per the documentation). Why am I getting this error
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to connect to
host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Also,
(process:13023): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
Error: no display specified
Thanks in advance!
You don't need anything on the machine that runs the hub except the selenium jar.
On the machine that runs the node you only need firefox itself to be installed, and the selenium jar running.
Firefox doesn't need a webdriver, only chrome.
from documentation
Firefox driver is included in the selenium-server-stanalone.jar
Yesterday, I was able to find the root cause, I was running these on the headless machines and needed those to be configured in order to launch ff. Thanks for your help!

Selenium server fails to launch Chromium

I have a set of acceptance tests written with https://github.com/camme/webdriverjs. I wish to run the tests against real browsers via Selenium Server (WebDriver) and Sauce Labs. Firefox starts fine, but Chromium (30.0.1599.101 from Debian Wheezy packages) does not. By just setting { desiredCapabilities: { browserName: "chrome" } } I get ERROR COULDNT GET A SESSION ID and Selenium Server console output shows
WARN - Exception: 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. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
If I start Selenium Server with -Dwebdriver.chrome.driver=/usr/bin/chromium new browser window appears, but the tests never start running and after timeout I get the same ERROR COULDNT GET A SESSION ID and Selenium Server console output shows
Created new window in existing browser session. 13:43:25.775 WARN - Exception thrown java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
[...]
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
[...]
Caused by: org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
[...]
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Please set the ChromeDriver executable path in a right way.
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver")
//Then your Driver instance
WebDriver driver = new ChromeDriver();
More Information on ChromeDriver here

Resources