I'm trying to launch a new Chrome browser using Selenium Grid but ending up with the below error
Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, version=55.0.2, platform=WINDOWS}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'PL9710388', ip: '10.61.249.5', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: driver.version: RemoteWebDriver
Below is my code to launch the Remote browser
java -Dwebdriver.chrome.driver=C:\chromedriver.exe -jar selenium-server-standalone-3.0.1.jar -role hub
java -Dwebdriver.chrome.driver=C:\chromedriver.exe -jar selenium-server-standalone-3.0.1.jar -role node
cap = DesiredCapabilities.chrome();
cap.setVersion("55.0.2");
cap.setBrowserName("chrome");
cap.setPlatform(org.openqa.selenium.Platform.WINDOWS);
browser = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);
Could you please help me on what is wrong?
make sure your code is able to find the chromedriver in your system. You can set the path programatically, you can even download and keep your driver from the below link
System.setProperty("webdriver.chrome.driver","/path to/chromedriver.exe");
cap = DesiredCapabilities.chrome();
cap.setPlatform(org.openqa.selenium.Platform.WINDOWS);
browser = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);
The line java -Dwebdriver.chrome.driver=C:\chromedriver.exe -jar selenium-server-standalone-3.0.1.jar -role node causes a plain vanilla node to be spun off which is agnostic of PLATFORM flavors (i.e., the node is not classified to recognize platform as a trait and is supposed to work as a generic node).
Your test code however seems to be specifying the platform as below
cap = DesiredCapabilities.chrome();
cap.setVersion("55.0.2");
cap.setBrowserName("chrome");
cap.setPlatform(org.openqa.selenium.Platform.WINDOWS);
To fix your problem please change your test code to look like below
cap = DesiredCapabilities.chrome(); // this sets the browser name. u dont need to do it again.
browser = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);
Once you have this, you should be able to execute tests properly.
Please dont forget to add the location to where your chromedriver binary exists to your PATH variable before starting the node, so that you dont see issues related to selenium not being able to find the chromedriver's location.
For general overview on working with Grid, you can refer to my blog post
I encounter the same and i found that the platform, browser name & browser version details were not matching the grid configuration. Specifically it was because i was using platrom as windows where i would have used VISTA. Also make sure you are using the hub URL instead of the node URL.Hub URL would be http://hubIP:port/wd/hub.
Refer below screenshot to get the right details about the node:
Related
I'm using Selenium Web driver, however, I am preloading a browser by setting the debuggerAddress. I connect through a specified port. I had this working great. Suddenly, it's stopped working. I'm not quite sure what the issue is.
public void launchBrowser() throws InterruptedException {
try {
// Set file path of chrome driver
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
// Start chrome driver with existing chrome browser
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("debuggerAddress","localhost:1250");
// Create object
driver = new ChromeDriver(options);
// Write to console where we are
System.out.println(driver.getCurrentUrl());
}
catch(Exception e) {
console("JacksClass.java","launchBrowser()", "Exception: " + e);
}
}
Before I run the script. I start the Chrome browser with this command in CMD
start chrome --remote-debugging-port=1250
After launching the browser from CMD successfully. Then running the code. I get the following exception after around 1-2 minutes.
JacksClass.java - launchBrowser() : Exception: 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.
Build info: version: '4.0.0-alpha-6', revision: '5f43a29cfc'
System info: host: 'DESKTOP-5H32IOI', ip: '192.168.1.53', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.8'
Driver info: driver.version: ChromeDriver
All of this was working great a month ago. I have the chrome driver installed in the same location.
Finally got it to work. Firstly I tried to access the open port in another browser.
Typing localhost:1250 into the URL bar.
It could not connect. So there clearly was an issue with that port. I have tried many different ports but still had the same issue.
I finally tried port 1258 and then double-checked it with the test outlined above. Typing localhost:1258 into another browser proved the port was active.
Then my program worked as well! How strange! Glad it's working now :)
I have tried everything that has been told in Stackoverflow topics. I have java selenium tests run on remote slave through jenkins. The absurd thing is first test always run and browsers opens, all other tests give me "Timed out waiting for driver server to start".
public WebDriver startChrome() {
System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--aggressive-cache-discard");
chromeOptions.addArguments("--disable-cache");
chromeOptions.addArguments("--disable-application-cache");
chromeOptions.addArguments("--disable-offline-load-stale-cache");
chromeOptions.addArguments("--disk-cache-size=0");
chromeOptions.addArguments("--dns-prefetch-disable");
chromeOptions.addArguments("--no-proxy-server");
chromeOptions.addArguments("--log-level=3");
chromeOptions.addArguments("--silent");
chromeOptions.addArguments("--disable-browser-side-navigation");
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
chromeOptions.addArguments("-disable-cache");
chromeOptions.addArguments("-disable-extensions");
chromeOptions.addArguments("--incognito");
chromeOptions.addArguments("start-maximized");
//chromeOptions.setExperimentalOption("useAutomationExtension", false);
ChromeDriverService chromeDriverService = ChromeDriverService.createDefaultService();
port = chromeDriverService.getUrl().getPort();
return new ChromeDriver(chromeDriverService, chromeOptions);
}
Error:
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5'
System info: host: 'ISTDTSTYNMD04V', ip: '10.52.253.54', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:231)
at org.openqa.selenium.remote.service.DriverService.lambda$start$0(DriverService.java:193)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1596)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:35592/status] to be available after 20000 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:90)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:227)
... 7 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:88)
... 8 more
All the solutions I have tried so far:
Update Java 1_8_271
Update Selenium 4
Update ChromeDriver 87
Check localhost traffic with rawcap
Check localhost dns definiton in etc/hosts
Update Chrome 87
Set Proxy
Check port availability
Check driver path
Kill all chrome and driver tasks before create (Only solution that worked, but not good for parallel tests)
Check localhost url and port is accessible with chrome -> http 200
When I try to reach url and port through java urlconnection in code driver create function catch block), it gives me connection reset but in chrome it gives 200.
All help will be appreciated.
Best Regards
This error message...
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5'
System info: host: 'ISTDTSTYNMD04V', ip: '10.52.253.54', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271'
Driver info: driver.version: unknown
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
A bit of more information about your usecase would have helped us to analyze the error in a better way. However to start with you can use only one single arguments start-maximized and remove all the other arguments which would get you started. So your effective code block will be:
public WebDriver startChrome() {
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("start-maximized");
ChromeDriverService chromeDriverService = ChromeDriverService.createDefaultService();
return new ChromeDriver(chromeDriverService, chromeOptions);
}
Additional Consideration
Ensure that:
JDK is upgraded to current levels JDK 8u271.
Selenium is upgraded to current released Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v87.0 level.
Chrome is updated to current Chrome Version 87.0 level. (as per ChromeDriver v87.0 release notes).
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
References
You can find a couple of relevant detailed discussions in:
Selenium Chromedriver server times out despite being available
Driver info: driver.version: unknown with ChromeDriver Chrome using Selenium and Python
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start while initiating Chrome browser through Selenium
System.setProperty("webdriver.chrome.driver","D:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate().to("https://link");
driver.findElement(By.cssSelector("#username")).sendKeys("id");
driver.findElement(By.cssSelector("#password")).sendKeys("pass");
driver.findElement(By.cssSelector("#clientName")).sendKeys("name");
driver.findElement(By.cssSelector("#submitButton")).click();
System.out.println("Okay !");
I set property for Chrome Driver. When I run it gives an error. (Below) I searched a lot but didn't found any solution.
Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 10589
Only local connections are allowed.
Exception in thread "main" 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.
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z'
System info: host: 'DESKTOP-9HVORCR', ip: '192.168.1.24', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:564)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at zaaa.main.main(main.java:11)
Caused by: java.lang.IllegalArgumentException: Unexpected char 0x131 at 23 in User-Agent value: selenium/3.12.0 (java wındows)
at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:338)
at okhttp3.Headers$Builder.add(Headers.java:288)
at okhttp3.Request$Builder.addHeader(Request.java:177)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:85)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
... 6 more
I have tried these:
32/64 bit drivers.
Run it as administrator.
Creating a Try/Catch block.
Other drivers. (Like Operadriver.exe) (Result: Same error)
I think your windows is not english. I am having the same problem. When I tried the same in an english version windows 10 the code works without any problem.
Locale.setDefault(new Locale("en", "EN"));
you can also try this. it worked for me.
Add these lines before instantiating "WebDriver driver = new ChromeDriver();"
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
Then add the argument where you have declared Webdriver as shown below:-
WebDriver driver = new ChromeDriver(chromeOptions);
I hope it will help you.
Here you are using
selenium version : 3.12.0
chromedriver version : 2.40
When i tried to run with these configurations (they are latest at present)
I am able to launch the application without any exception and in the logs getting :
Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 35584
Only local connections are allowed.
Jun 21, 2018 2:42:51 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Okay !
which is same as your starting logs.
My chrome browser version is :
Version 67.0.3396.87 (Official Build) (64-bit)
I think you should check your .m2 folder and delete
.m2\repository\org\seleniumhq\selenium
folder from there and then again try to download the dependencies.
Also update to latest chrome browser version.
Hope it helps.
This is a problem of Turkish Windows. As it is indicated in exception message the 'ı' character in user agent value "selenium/3.12.0 (java wındows)" is the cause of the exception.
The problem is the string "WINDOWS" is changed to lower case and it results "wındows" because of TR locale. I found that it is generated in class org.openqa.selenium.remote.http.HttpClientand added Locale.US like this.
String USER_AGENT = String.format(
"selenium/%s (java %s)",
new BuildInfo().getReleaseLabel(),
(Platform.getCurrent().family() == null ?
Platform.getCurrent().toString().toLowerCase(Locale.US) :
Platform.getCurrent().family().toString().toLowerCase(Locale.US)));
I compiled the library with my changes and it works now. I also opened a pull request on github.
You can also find my edited fork here.
I m trying to launch Safari Browser in Mobile using Appium on Mac.
Below are the capabilities I have used in eclipse
desCapabilities = DesiredCapabilities.iphone();
desCapabilities.setCapability(BrowserType.IPHONE, "Safari");
desCapabilities.setCapability("browserName", "Safari");
desCapabilities.setCapability("platformName","iOS");
desCapabilities.setCapability("deviceName", "iPhone");
desCapabilities.setCapability("version", "10.3.1");
desCapabilities.setCapability("udid", "mobileID");
driver = new RemoteWebDriver(new URL("http://" + nodeUrl + ":" + nodeUrlPort + "/wd/hub"), desCapabilities);
When I try to run in eclipse, below are the exception I m facing.
org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{iPhone=Safari, browserName=Safari, platformName=iOS, udid=****, deviceName=Ananda's iPhone, version=10.3.1, platform=MAC}]
Command duration or timeout: 233 milliseconds
Build info: version: '2.53.1', revision: '*****', time: '2016-06-30 19:26:09'
System info: host: 'hostname', ip: 'ipaddress', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.4', java.version: '1.7.0_71'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Kindly help me out in this.
To fix the issues in desired capabilities, change your code for desired capabilities as
desCapabilities.setCapability("browserName", "Safari");
desCapabilities.setCapability("platformName","iOS");
desCapabilities.setCapability("deviceName", "write the name of the test device (eg: myphone)");
desCapabilities.setCapability(“platformVersion”, "10.3.1");
desCapabilities.setCapability("udid", "write the mobile udid");
There is a difference between version and platform version.
platform Version is the mobile operating system version that you want to use in your test.
Version is the version of the browser you want to use in your test.
You can refer DesiredCapabilities [here][1].
[1]: a) https://wiki.saucelabs.com/display/DOCS/Desired+Capabilities+Required+for+Selenium+and+Appium+Tests
b) https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities
You need to use appium 1.6.4 for ios 10.3.1. Upgrade your environment and it will sort out the issue. Refer to below link:
github.com/appium/appium/releases/tag/v1.6.4
Appium 1.6.4 fixes numerous issues with the previous releases. This release
supports iOS 10.3 as well as Android 7.1.
And for ios 10 and onwards you have to use appium 1.6.x and ios 10.3 support has been provided in appium 1.6.4
Hello StackOverflow community,
I am trying to run Selenium grid with actual devices. My set up (kind of) works when I use android phones but when I use an iPhone it gives me the following error message
"Error forwarding the request For input string: "(null)"
So my question boils down to:
How do you set up iPhone WebDriver with Selenium Grid2?
What I did so far:
Grid Set up:
Setting up selenium Grid
java -jar selenium-server-standalone-2.28.0.jar -role hub
Setting up iPhone node
Go to Settings > iWebDriver
Port: 3001
Grid : localhost ip Address and Port: 4444
java -jar selenium-server-standalone-2.28.0.jar -role webdriver -host [phone Host] -port 3001 -hub http://localhost:4444/grid/register -browser browserName=iPhone,platform=MAC
I then run a junit test with the following
public void testIphoneDriver() throws Exception {
DesiredCapabilities capability = DesiredCapabilities.iphone();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub") , capability);
driver.get("http://www.google.com"); }
I am then given an error "Error forwarding the request For input string: "(null)"
Strangely enough if I connect to the device directly (replacing localhost:4444 with the iPhone IP address) it works fine.
Below is the stack trace
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Error forwarding the new session Error forwarding the request For input string: "(null)"
Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 15:53:30'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_25'
Driver info: driver.version: unknown
at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:111)
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:84)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:68)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.seleniumhq.jetty7.servlet.ServletHolder.handle(ServletHolder.java:565)
at org.seleniumhq.jetty7.servlet.ServletHandler.doHandle(ServletHandler.java:479)
at org.seleniumhq.jetty7.server.session.SessionHandler.doHandle(SessionHandler.java:225)
at org.seleniumhq.jetty7.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
at org.seleniumhq.jetty7.servlet.ServletHandler.doScope(ServletHandler.java:406)
at org.seleniumhq.jetty7.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.seleniumhq.jetty7.server.handler.ContextHandler.doScope(ContextHandler.java:965)
at org.seleniumhq.jetty7.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.seleniumhq.jetty7.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.seleniumhq.jetty7.server.Server.handle(Server.java:349)
at org.seleniumhq.jetty7.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
at org.seleniumhq.jetty7.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
at org.seleniumhq.jetty7.server.AbstractHttpConnection.content(AbstractHttpConnection.java:894)
at org.seleniumhq.jetty7.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:948)
at org.seleniumhq.jetty7.http.HttpParser.parseNext(HttpParser.java:857)
at org.seleniumhq.jetty7.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.seleniumhq.jetty7.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
at org.seleniumhq.jetty7.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
at org.seleniumhq.jetty7.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
at org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
at java.lang.Thread.run(Unknown Source)
We have provided some documentation on how to configure the connectivity and the Grid for the iPhone driver on the relevant wiki page for the Selenium project http://code.google.com/p/selenium/wiki/IPhoneDriver
You might also test connectivity exists between your tests and the hub; and the hub and the iphone with webdriver running on it; using telnet or even a web browser to connect to the respective URLs e.g. to
http://localhost:4444/wd/hub
if you're using a web browser on your machine that'll run the tests.
I hope that's sufficient to enable you and people in a similar predicament to get their tests working. Thanks for a detailed description of what you've done.