JavascriptError while using Internet Explorer with WebDriverBackedSelenium - selenium

I am using WebDriverBackedSelenium for the automated testing of a website but my code is working fine for the chrome and firefox but problem in IE
Code is
WebDriver driver = new ChromeDriver();
String baseUrl = "https://mywebsite.com/";
selenium = new WebDriverBackedSelenium(driver, baseUrl);
selenium.fireEvent("//td[#id='skin_container_logoff']/a/table/tbody/tr/td[2]", "click");
This line give the below error
com.thoughtworks.selenium.SeleniumException: JavaScript error (WARNING: The server did not
provide any stacktrace information) Command duration or timeout: 125 milliseconds Build info:
version: '2.18.0', revision: '15704', time: '2012-01-27 15:48:16' System info: os.name: '
Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_24' Driver info:
driver.version: EventFiringWebDriver Command duration or timeout: 735 milliseconds Build info:
version: '2.18.0', revision: '15704', time: '2012-01-27 15:49:22' System info: os.name:
'Linux', os.arch: 'amd64', os.version: '2.6.32-131.2.1.el6.x86_64', java.version: '1.6.0_26-
rev' Driver info: driver.version: RemoteWebDriver at
org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:42)
at org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:39) at
org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:145) at
org.openqa.selenium.WebDriverCommandProcessor.doCommand(WebDriverCommandProcessor.java:75) at
com.thoughtworks.selenium.DefaultSelenium.fireEvent(DefaultSelenium.java:210) at
com.example.tests.WebDriverBackedSeleniumEx.fireEvent(WebDriverBackedSeleniumEx.java:103) at
com.example.tests.LoginAdvanceIE.testLoginIE(LoginAdvanceIE.java:48) at
com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:230) Caused by:
org.openqa.selenium.WebDriverException: JavaScript error (WARNING: The server did not provide
any stacktrace information) Command duration or timeout: 125 milliseconds Build info: version:
'2.18.0', revision: '15704', time: '2012-01-27 15:48:16' System info: os.name: 'Windows 7',
os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_24' Driver info: driver.version:
EventFiringWebDriver Command duration or timeout: 735 milliseconds Build info: version:
'2.18.0', revision: '15704', time: '2012-01-27 15:49:22' System info: os.name: 'Linux', os.arch:
'amd64', os.version: '2.6.32-131.2.1.el6.x86_64', java.version: '1.6.0_26-rev' Driver info:
driver.version: RemoteWebDriver at
java.lang.reflect.Constructor.newInstance(Constructor.java:513) at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147) at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113) at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439) at
org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:353) at
org.openqa.selenium.internal.seleniumemulation.JavascriptLibrary.executeScript(JavascriptLibrary.java
:88) at
org.openqa.selenium.internal.seleniumemulation.FireEvent.handleSeleneseCommand(FireEvent.java:38)
at
org.openqa.selenium.internal.seleniumemulation.FireEvent.handleSeleneseCommand(FireEvent.java:1)
at org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:36)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken Build info:
version: '2.18.0', revision: '15704', time: '2012-01-27 15:49:22' System info: os.name: 'Linux',
os.arch: 'amd64', os.version: '2.6.32-131.2.1.el6.x86_64', java.version: '1.6.0_26-rev' Driver
info: driver.version: RemoteWebDriver at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:101) Caused by:
org.openqa.selenium.WebDriverException: JavaScript error (WARNING: The server did not provide any
stacktrace information) Command duration or timeout: 125 milliseconds Build info: version:
'2.18.0', revision: '15704', time: '2012-01-27 15:48:16' System info: os.name: 'Windows 7',
os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_24' Driver info: driver.version: Even
tFiringWebDriver Build info: version: '2.18.0', revision: '15704', time: '2012-01-27 15:49:22'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-131.2.1.el6.x86_64',
java.version: '1.6.0_26-rev' Driver info: driver.version: EventFiringWebDriver at
java.lang.reflect.Constructor.newInstance(Unknown Source) at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147) at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113) at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439) at
org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:353) at
org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:100) at
$Proxy2.executeScript(Unknown Source) at
org.openqa.selenium.support.events.EventFiringWebDriver.executeScript(EventFiringWebDriver.java:208)
at org.openqa.selenium.remote.server.handler.ExecuteScript.call(ExecuteScript.java:54) at
org.openqa.selenium.remote.server.handler.ExecuteScript.call(ExecuteScript.java:1) at
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at
java.util.concurrent.FutureTask.run(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown
Source)
I tried the WebDriverWait but I am still getting the error.

I am not sure if this is the problem, but try specifying javascript timeout manually:
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);

Related

Unable to launch chrome with selenium standalone

I am trying to launch chrome using selenium standalone by using below command
java -Dwebdriver.chrome.driver=chromedriver-new.exe -jar selenium-server.jar standalone --host 127.0.0.1 --port 4444
However when I am triggering my webdriverio test for chrome, it momentarily opens chrome and the it crashes with below error
{"traceId": "faca75a3db657eed4b96bdac93977746","eventTime": 1637343152240678600,"eventName": "exception","attributes": {"driver.url": "http:\u002f\u002flocalhost:57786","exception.message": "Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: session not created\nfrom tab crashed\n (Session info: chrome=96.0.4664.45)\nBuild info: version: '4.0.0', revision: '3a21814679'\nSystem info: host: '', ip: '192.168.0.11', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_311'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created\nfrom tab crashed\n (Session info: chrome=96.0.4664.45)\nBuild info: version: '4.0.0', revision: '3a21814679'\nSystem info: host: '', ip: '192.168.0.11', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_311'\nDriver info: driver.version: unknown\r\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)\r\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)\r\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)\r\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:131)\r\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:65)\r\n\tat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:143)\r\n\tat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:315)\r\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:513)\r\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:440)\r\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:648)\r\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:612)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\r\n\tat java.lang.Thread.run(Unknown Source)\r\n","exception.type": "org.openqa.selenium.SessionNotCreatedException","logger": "org.openqa.selenium.grid.node.config.DriverServiceSessionFactory","session.capabilities": "{"acceptInsecureCerts": true,"browserName": "chrome","goog:chromeOptions": {"args": [ "--disable-gpu" ] } }\n"}}
It worked by adding '--no-sandbox' in chrome options.

How to debug SessionNotCreatedException?

How to debug SessionNotCreatedException in Firefox/Selenium?
1501668018402 geckodriver INFO Listening on 127.0.0.1:6748
1501668025463 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args ["-marionette"]
1501668037220 Marionette INFO Listening on port 53205
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}}], required capabilities = Capabilities [{moz:firefoxOptions={binary=Optional.empty, args=[], legacy=null, logLevel=null, prefs={}, profile=null}}]
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'CELKON-RND-PC', ip: '192.168.1.6', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:121)
at testpack.testclass.main(testclass.java:16)

Issue with Selenium Webdriver: UnreachableBrowserException raised

I am trying to set up a continuous delivery pipeline and an UnreachableBrowserException is always raised.
Here is the full stacktrace:
17:20:05.970 ERROR - org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
17:20:05.977 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'ct-10-0-180-116', ip: '10.0.180.116', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-042stab105.14', java.version: '1.8.0_51'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:125)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:58)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:175)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:202)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:164)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'ct-10-0-180-116', ip: '10.0.180.116', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-042stab105.14', java.version: '1.8.0_51'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:113)
at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103)
... 9 more
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.
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'ct-10-0-180-116', ip: '10.0.180.116', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-042stab105.14', java.version: '1.8.0_51'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:141)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138)
... 14 more
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'ct-10-0-180-116', ip: '10.0.180.116', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-042stab105.14', java.version: '1.8.0_51'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:170)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:63)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568)
... 19 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:20882/status] to be available after 20010 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:167)
... 21 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
... 22 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 23 more
17:20:05.986 WARN - Exception: null
/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:108
var template = new Error(this.message);
^
UnknownError: null
at new bot.Error (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:108:18)
at Object.bot.response.checkResponse (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.js:109:9)
at /opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:160:24
at [object Object].promise.ControlFlow.runInFrame_ (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)
at [object Object].goog.defineClass.notify (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25)
at [object Object].promise.Promise.notify_ (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12)
at Array.forEach (native)
at [object Object].promise.Promise.notifyAll_ (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15)
at goog.async.run.processWorkQueue (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/async/run.js:130:15)
at runMicrotasksCallback (node.js:337:7)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at [object Object].Builder.build (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:445:22)
at [object Object].DriverProvider.getNewDriver (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
at [object Object].Runner.createBrowser (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/lib/runner.js:182:37)
at /opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/lib/runner.js:263:21
at _fulfilled (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/q/q.js:759:13)
at /opt/local/nvm/versions/node/v0.12.0/lib/node_modules/protractor/node_modules/q/q.js:525:49
[launcher] Process exited with error code 1
Here are the relevant parts from my bash script:
#Install protractor and webdriver & start webdriver
npm install -g protractor
webdriver-manager update
webdriver-manager start&
#Install and start application
./gradlew assemble
java -jar bignibou-server/build/libs/bignibou-server.jar&
#Run end2end tests
protractor bignibou-client/protractor.conf.js
Can someone please help?
edit 1: from protractor.conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['test/e2e/*.spec.e2e.js']
};
if (process.env.SNAP_CI) {
exports.config.chromeDriver = '/usr/local/bin/chromedriver';
}
edit 2: from my end2end test:
describe('Signin page', function () {
beforeEach(function(){
browser.get('http://localhost:8080/#/signin');
browser.refresh();
});
it('should allow user to signin', function () {
element(by.model('credentials.username')).sendKeys('balteo#example.fr');
element(by.model('credentials.password')).sendKeys('------');
element(by.id('submit')).click();
expect(element(by.tagName('h2')).getText()).toBe('Dashboard');
});
});

How to safely update chromedriver on selenium nodes

I have a selenium grid setup with one hub and 5 nodes. they both use the same version of selenium server 2.41.0.
On the nodes there are already chromedriver setup in the same folder as selenium sever.
Now the task is to update the chromedriver without broken any existing jenkins tests.
I have tried manually go to each nodes and update the chromedriver file. But, the tests on jenkins will throw WebDriverException saying unable to create driver.
What could be the issue here?
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'dseleniumnode05.xxx-dev.com', ip: 'xx.xx.xx.xxx', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.10-100.fc18.x86_64', java.version: '1.7.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
14:08:37.077 INFO - Executing: [new session: Capabilities [{platform=LINUX, browserName=chrome, proxy={socksUsername=null, noProxy=null, httpProxy=proxy.xxx-stage.com:80, socksPassword=null, ftpProxy=null, sslProxy=proxy.xxx-stage.com:443, proxyAutoconfigUrl=null, proxyType=MANUAL, class=org.openqa.selenium.Proxy, autodetect=false, hCode=1182650898, socksProxy=null}, version=, chrome.switches=[--start-maximized]}]] at URL: /session)
14:08:37.078 INFO - Creating a new session for Capabilities [{platform=LINUX, browserName=chrome, proxy={socksUsername=null, noProxy=null, httpProxy=proxy.xxx-stage.com:80, socksPassword=null, ftpProxy=null, sslProxy=proxy.xxx-stage.com:443, proxyAutoconfigUrl=null, proxyType=MANUAL, class=org.openqa.selenium.Proxy, autodetect=false, hCode=1182650898, socksProxy=null}, version=, chrome.switches=[--start-maximized]}]
Starting ChromeDriver (v2.10.267518) on port 13326
Only local connections are allowed.
[0.500][WARNING]: PAC support disabled because there is no system implementation
14:09:38.101 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'dseleniumnode05.xxx-dev.com', ip: 'xx.xx.xx.xxx', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.10-100.fc18.x86_64', java.version: '1.7.0_45'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:177)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:113)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:90)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:96)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:63)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:202)
at org.openqa.selenium.remote.server.JsonHttpRemoteConfig.handleRequest(JsonHttpRemoteConfig.java:193)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:174)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:140)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:112)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'dseleniumnode05.xxx-dev.com', ip: 'xx.xx.xx.xxx', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.10-100.fc18.x86_64', java.version: '1.7.0_45'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:72)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:56)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:216)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:170)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:62)
... 8 more
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.10.267518,platform=Linux 3.11.10-100.fc18.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.52 seconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'dseleniumnode05.xxx-dev.com', ip: 'xx.xx.xx.xxx', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.10-100.fc18.x86_64', java.version: '1.7.0_45'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.chrome.ChromeDriver.startSession(ChromeDriver.java:181)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:160)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:128)
... 13 more
14:09:38.103 WARN - Exception: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.10.267518,platform=Linux 3.11.10-100.fc18.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.52 seconds
the matter is that instance of driver is created on host machine (using existing chromdriver file there). Obviously once you substitute updated chrome driver file (of a newer version) older one -> everything should work fine after driver instance reinitizalization.
To initialize driver , I'm using following java piece of code:
public static WebDriver driverSetUp(WebDriver driver) throws MalformedURLException {
DesiredCapabilities capability = DesiredCapabilities.chrome();
log.info("Google chrome is selected");
System.setProperty("webdriver.chrome.driver", "....path/chromedriver.exe");
capability.setBrowserName("chrome");
capability.setPlatform(org.openqa.selenium.Platform.WINDOWS);
String webDriverURL = "http://" + environmentData.getHubIP() + ":" + environmentData.getHubPort() + "/wd/hub";
driver = new RemoteWebDriver(new URL(webDriverURL), capability);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.manage().window().setSize(new Dimension(1920, 1080));
return driver;
}
Try it out and let us know whether issue persists. Thanks.

Query related to Explicit wait: wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(

package wait1;
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Explicit {
public static void main(String[] args) {
FirefoxDriver driver= new FirefoxDriver();
WebDriverWait wait= new WebDriverWait(driver,20 );
driver.get("http://www.91mobiles.com/");
driver.findElement(By.xpath("//*[#id='q']")).sendKeys("Micromax");
//wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[#id='ui-id-22']/span[2]")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id=ui-id-172")));
driver.findElement(By.xpath("//*[#id='ui-id-52']")).click();
}
}
I am getting the following error when I execute the above script:
Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 20 seconds waiting for visibility of element located by By.id: id=ui-id-172
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:33:32'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:259)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228)
at wait1.Explicit.main(Explicit.java:20)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"id=ui-id-172"}
Command duration or timeout: 21 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:33:32'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Session ID: fd977506-2457-4981-a304-f9a9b6b57f4e
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=17.0.7}]
at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:191)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:348)
at org.openqa.selenium.By$ById.findElement(By.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:522)
at org.openqa.selenium.support.ui.ExpectedConditions.access$0(ExpectedConditions.java:520)
at org.openqa.selenium.support.ui.ExpectedConditions$4.apply(ExpectedConditions.java:130)
at org.openqa.selenium.support.ui.ExpectedConditions$4.apply(ExpectedConditions.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
... 1 more
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to locate element: {"method":"id","selector":"id=ui-id-172"}
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:33:32'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Driver info: driver.version: unknown
The behavior you are getting is the expected bahavior. You specified a 20 second explicit wait and in that time the ExpectedConditions.visibilityOfElementLocated(...) could not be established. So the wait fails with a timeout.
If you want to go on in your program you need to surround the wait in a try-catch block and catch org.openqa.selenium.TimeoutException
Try using like this
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[#id='ui-id-52']"));
Make sure that whatever identification type you use while waiting should be in the statement you use for action. (e.g. click, set etc.)
Here, we have two solutions...
Try increasing your WebDriverWait time to check if it fix the issue.
Try to locate same element by firebug, if it is successfully found by firebug, than WebDriverWait time is the only culprit.
You'll always get a timeout with the code you have. This is the offending line:
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id=ui-id-172")));
Note how you have By.id("id=ui-id-172"). This is wrong. It would look for an object that has the id id=ui-id-172. While it is possible to have an id with this value (yes, I tried and it works) it is unlikely that this is what you want, especially given your XPath expression on the next line. What you want, to be consistent with the rest of your code, is By.id("ui-id-172").