My issue is somewhat similar to this question.
I am using cucumber framework for automated testing of an enterprise java website. I have written many *.feature files for testing various functionalities. Recently when I ran regression tests on Jenkins, some of the tests started breaking.The test was as follows.
1) Go to Temp mail inbox in chrome.
2) Open the latest email.
3) Click on the 'confirm registration link', which will open a new tab.
4) Switch to the newly opened tab and continue with login.
The test is failing at the fifth step with 'Element not found' exception. When I checked the screenshots from selenium, it shows that the test is still in the temp mail inbox. Tab switch had not taken place.
I have narrowed the issue to the following step definition.
@And("^I switch to next window$")
public void iSwitchToNextWindow() throws Throwable {
for (String winHandle : getWebDriver().getWindowHandles()) {
if (!winHandle.equalsIgnoreCase(windowHandle)) {
getWebDriver().switchTo().window(winHandle);
}
}
}
windowHandle
is obtained from the previous step.
Can someone please help me with this.Please comment if you need any more information.Thank you.
Note: Test is failing only when it is ran on Jenkins, it works fine when ran on local machine.
EDIT:
[ISSUE RESOLVED] The problem was with the chromedriver.exe version. Jenkins was using an older version of chromedriver than on my machine.