I have, in part, the following html structure:
And the following code in my PageObject to handle it:
driver.switchTo().frame(foo); //Search sizeTextbox.sendKeys(size); bttnSubmitSearchBySize.click(); [snip WebDriverWait for the search results to appear] driver.switchTo().defaultContent();
where foo, sizeTextbox, and bttnSubmitSearchBySize are all WebElements lazy-loaded via PageObject.
The first time I perform the search in my test, everything works great. I enter a size, I click search, I find the row, I toggle a checkbox in it. I then go off to another page to verify that the checkbox changed the state of the product. I then come back to this page and, in theory, perform the same search, toggle the checkbox, and go off to verify that the product changed state again.
However, the second time I try to click bttnSubmitSearchBySize, instead, the Order Center button is clicked, and I am taken to the Order Center page. Furthermore, it seems to either be clicked multiple times or be hovered over, as there's a dropdown menu that appears on hover and it toggles on and off repeatedly until the test finally dies. This happens even if I recreate the PageObject to force it to re-find the button, and even if I manually re-find the button just before clicking.
What am I doing wrong?
Update: I've narrowed down the code responsible. The following snippit will also trigger the issue:
page.navigateTo(); page.searchBySize(size); driver.navigate().refresh(); page.searchBySize(size);
(where searchBySize is the method containing the above search code).
So far nothing I've put after the refresh will prevent the bug; I've tried re-calling initElements and making a new instance of the pageObject both.
ETA: Today I discovered that this only happens in IE, specifically IE10, it does not happen in Chrome. I have therefore performed the following troubleshooting steps:
- Verified that zoom is at 100%
- Tried maximizing the window. No change.
- Printed the location and size of the element. It's identical on both passes, but only the first succeeds.