Reputation: 115
I am trying to run BDD test case using Jbehave , selenium it works fine in local environment but fails when i am running through Jenkins. Error i am seeing as below :
org.openqa.selenium.TimeoutException: Timed out after 10 seconds waiting for visibility of element located by By.xpath: //*[@id='my-id']
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'lt29nxas000000u.opr.statefarm.org', ip: '10.56.8.88', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-693.11.6.el7.x86_64', java.version: '1.7.0_95' Session ID: 10a633701cc1b7e5b678d24c0ee8890e
Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{platform=LINUX, acceptSslCerts=false, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/tmp/.org.chromium.Chromium.D1Awd8, chromedriverVersion=2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881)}, networkConnectionEnabled=false, unexpectedAlertBehaviour=, rotatable=false, setWindowRect=true, mobileEmulationEnabled=false, locationContextEnabled=true, pageLoadStrategy=normal, version=64.0.3282.186, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, hasTouchScreen=false, applicationCacheEnabled=false, takesScreenshot=true, acceptInsecureCerts=false}]
I can see the application logs that traffic generated by BDD execution but it fails to get the element , i tried increasing timeout values but no luck . I am using Headless Chrome browser on jenkins .
appreciate any help !
Upvotes: 0
Views: 2250
Reputation: 15528
2.53.1
seems like a version inherited in a spring-boot project. Anyway whether you can update it to something more recent or not, you can find below 3 options for some Selenium version where I tried it, but they should all yield the same result with v2.35.528161 of the Chrome Driver which you're using.:
1) Selenium 2.53.1:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("acceptInsecureCerts", true); // no dedicated method
WebDriver driver = new ChromeDriver(capabilities);
Result
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'xxxx', ip: 'x.y.z.w', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_112'
Driver info: org.openqa.selenium.chrome.ChromeDriver v--------v--------v v-----------v----------v
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73), userDataDir=C:\Users\batman\AppData\Local\Temp\scoped_dir17748_29858}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=64.0.3282.186, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, acceptInsecureCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
2) Selenium 3.4.0:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setAcceptInsecureCerts(true); // dedicated method
WebDriver driver = new ChromeDriver(capabilities);
Result
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'xxx', ip: 'x.y.z.w', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_112'
Driver info: org.openqa.selenium.chrome.ChromeDriver v---------v-------v v-----------v----------v
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73), userDataDir=C:\Users\batman\AppData\Local\Temp\scoped_dir11844_18447}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=64.0.3282.186, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, acceptInsecureCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
3) Selenium 3.9.1:
ChromeOptions options = new ChromeOptions();
options.setAcceptInsecureCerts(true);
WebDriver driver = new ChromeDriver(options); // use "Options" constructor instead of deprecated capabilities one
Result
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:25:02.294Z'
System info: host: 'xxxx', ip: 'x.y.z.w', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_112'
Driver info: org.openqa.selenium.chrome.ChromeDriver
v-----------v-----------v v---------v--------v
Capabilities {acceptInsecureCerts: true, acceptSslCerts: true, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.35.528161 (5b82f2d2aae0ca..., userDataDir: C:\Users\batman\AppDa...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 64.0.3282.186, webStorageEnabled: true}
Upvotes: 1
Reputation: 193298
The error stack trace does gives us some hint on whats wrong happening as follows :
org.openqa.selenium.TimeoutException: Timed out after 10 seconds waiting for visibility of element located by By.xpath: //*[@id='my-id']
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'lt29nxas000000u.opr.statefarm.org', ip: '10.56.8.88', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-693.11.6.el7.x86_64', java.version: '1.7.0_95' Session ID: 10a633701cc1b7e5b678d24c0ee8890e
Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{platform=LINUX, acceptSslCerts=false, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/tmp/.org.chromium.Chromium.D1Awd8, chromedriverVersion=2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881)}, networkConnectionEnabled=false, unexpectedAlertBehaviour=, rotatable=false, setWindowRect=true, mobileEmulationEnabled=false, locationContextEnabled=true, pageLoadStrategy=normal, version=64.0.3282.186, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, hasTouchScreen=false, applicationCacheEnabled=false, takesScreenshot=true, acceptInsecureCerts=false}]
It is clear from the error stacktrace that the Driver info is not recognized as follows :
Driver info: org.openqa.selenium.chrome.ChromeDriver
Your main issue is the version compatibility between the binaries you are using as follows :
So there is a clear mismatch between the JDK v7u95 , Selenium Client v2.53.1 , ChromeDriver version (v2.35) and the Chrome Browser version (v64.0)
Instead of a generic Locator Strategy as By.xpath: //*[@id='my-id'] try to use a more specific Locator Strategy which will identify the WebElement uniquely. An example of an xpath
:
//tagName[@attribute='attribute_value']
Execute your @Test
.
Upvotes: 1