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
Related
I am trying to initiate chrome through below code. I am getting below error and unable to proceed further. I tried all the options which was available in this website but nothing is working for me.
System.setProperty("webdriver.chrome.driver","path\\chromedriver.exe");
//WebDriver driver = new ChromeDriver();
//ChromeOptions options = new ChromeOptions();
//options.addArguments("--no-sandbox"); // Bypass OS security model
//options.addArguments("--headless");
//options.setExperimentalOption("useAutomationExtension", false);
//options.addArguments("start-maximized"); // open Browser in maximized mode
//options.addArguments("disable-infobars"); // disabling infobars
//options.addArguments("--disable-extensions"); // disabling extensions
//options.addArguments("--disable-gpu"); // applicable to windows os only
//options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
WebDriver driver = new ChromeDriver();
driver.get("https://www.facebook.com/");
driver.manage().window().maximize();
Thread.sleep(2000);
error:
``
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally.
(unknown error: DevToolsActivePort file doesn't exist)
System.setProperty("webdriver.chrome.driver","path\\chromedriver.exe");
//WebDriver driver = new ChromeDriver();
//ChromeOptions options = new ChromeOptions();
//options.addArguments("--no-sandbox"); // Bypass OS security model
//options.addArguments("--headless");
//options.setExperimentalOption("useAutomationExtension", false);
//options.addArguments("start-maximized"); // open Browser in maximized mode
//options.addArguments("disable-infobars"); // disabling infobars
//options.addArguments("--disable-extensions"); // disabling extensions
//options.addArguments("--disable-gpu"); // applicable to windows os only
//options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
WebDriver driver = new ChromeDriver();
driver.get("https://www.facebook.com/");
driver.manage().window().maximize();
Thread.sleep(2000);
error:
``
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Program Files\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Iam trying to run a selenium test in azure pipeline, the test works fine in my local machine with:
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
chrome_exe= ChromeDriverManager()
driver = webdriver.Chrome(executable_path=chrome_exe.install(), options=options)
but when i run the same in the pipeline it fails with the following error.
E selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
E (unknown error: DevToolsActivePort file doesn't exist)
E (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
/opt/hostedtoolcache/Python/3.6.11/x64/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py:242: WebDriverException
---------------------------- Captured stdout setup -----------------------------
---------------------------- Captured stderr setup -----------------------------
[WDM] - Current google-chrome version is 84.0.4147
[WDM] - Get LATEST driver version for 84.0.4147
[WDM] - There is no [linux64] chromedriver for browser 84.0.4147 in cache
[WDM] - Get LATEST driver version for 84.0.4147
[WDM] - Trying to download new driver from http://chromedriver.storage.googleapis.com/84.0.4147.30/chromedriver_linux64.zip
[WDM] - Driver has been saved in cache [/home/vsts/.wdm/drivers/chromedriver/linux64/84.0.4147.30]
manually i go to that path it says: No such object: chromedriver/84.0.4147.30
but if i query using link
it gives the same version number
chromedriver azuredops pipeline failure
According to the error message, it seems the Chrome browser is not installed at the default location within your system.
For the Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.
If you are using a Chrome executable in a non-standard location you can try to override the Chrome binary location as follows:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\\path\\to\\chrome.exe" #chrome binary location specified here
options.add_argument("--start-maximized") #open Browser in maximized mode
options.add_argument("--no-sandbox") #bypass OS security model
options.add_argument("--disable-dev-shm-usage") #overcome limited resource problems
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')
You could check this thread for some details.
My first Selenium project.
installed Selenium Webdriver 3.141 using nuget in VS2019
Downloaded and executed Chrome WebDriver from here
Get message that ChromeDriver was started successfully.
I've tried a number of different sample codes e.g.
[Test(Description = "Check SauceLabs Homepage for Login Link")]
public void Login_is_on_home_page()
{
homeURL = "https://www.SauceLabs.com";
driver.Navigate().GoToUrl(homeURL);
WebDriverWait wait = new WebDriverWait(driver,System.TimeSpan.FromSeconds(15));
wait.Until(driver => driver.FindElement(By.XPath("//a[#href='/beta/login']")));
IWebElement element = driver.FindElement(By.XPath("//a[#href='/beta/login']"));
Assert.AreEqual("Sign In", element.GetAttribute("text"));
}
[TearDown]
public void TearDownTest()
{
driver.Close();
}
[SetUp]
public void SetupTest()
{
homeURL = "http://SauceLabs.com";
driver = new ChromeDriver();
}
I've disabled both firewall and antivirus.
I get a new Chrome window with
data:,
in the address bar and "Chrome is being controlled by automated test software"
Then after a while the test crashes out with the error:
Test Name: Login_is_on_home_page
Test FullName: HelperTest.HelperTest.Chrome_Sample_test.Login_is_on_home_page
Test Source: C:\src\repos\Helper\HelperTest\Class1.cs : line 25
Test Outcome: Failed
Test Duration: 0:00:00
Test Name: Login_is_on_home_page
Test Outcome: Failed
Result StackTrace:
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor()
at HelperTest.Chrome_Sample_test.SetupTest() in C:\src\repos\Helper\HelperTest\Class1.cs:line 51
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--TearDown
at HelperTest.Chrome_Sample_test.TearDownTest() in C:\src\repos\Helper\HelperTest\Class1.cs:line 43
Result Message:
OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:56519/session timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
I have absolutely no idea what to try - can anyone help?
There are a few things to verify and experiment with that could help resolve the problem:
Check driver compatibility. Upgrade the NuGet packages in the test projects and check the Chrome driver NuGet package matches the driver version on the agent (you can view this in the agent pool details).
You can try to create the Chrome driver differently and specify a timeout for it, and increase the page load timeout.
Also, see if there are cached DLLs and try running VS2019 as an administrator.
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);
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