Click functionality inconsistent with geckodriver
Meta
OS: Mac OS
Selenium Version: 4.0.0-alpha.1 JavaScript
Browser: Firefox (using GeckoDriver)
Browser Version: 61.0
Expected Behavior -
Running
let cancelButton = await browser.findElement(By.id('cancel-export-div'));
const actions = browser.actions();
await actions.click(cancelButton).perform();
should click on the cancel button (which is actually a div) consistently.
Actual Behavior -
The button is not always clicked properly (which causes the test to fail). It fails around 20% of the time, but it's hard to discern when it'll happen and it seems completely arbitrary to me.
It's not an issue with the element not being loaded, as I am sleeping a few seconds before clicking and can observe every time that the element is loaded and clickable. In the times that the element is not clicked properly, I can see that the mouse moves to the WebElement, but the click just doesn't seem to register (perhaps it doesn't execute either).
However, I use clicks everywhere else in my tests and they all succeed. This is the only case where it fails. In this case, I'm clicking a button which creates a progress bar div (takes the whole page), and this click to cancel the progress (and destroy the div) sometimes fails.
Steps to reproduce -
Not sure, seems to happen arbitrarily, yet only in this specific test. The exact code for this test:
test('cancel progress bar works', async () => {
await browser.sleep(1500);
let cancelButton = await browser.findElement(By.id('cancel-export-div'));
const actions = browser.actions();
await actions.click(cancelButton).perform();
await browser.sleep(1000);
expect(await browser.findElements(By.id('pixel-export-div'))).toEqual([]); // empty list since not found
});
I ran my unit tests 10 times in succession, and in 2/10 the click failed. The above code should realistically implement a click on the cancel button consistently.
Seems to be related to this issue, but I'm using geckodriver not chromedriver
For issues please provide a concise reproducible test case and describe what results you are seeing and what results you expect.
See CONTRIBUTING.md
It's difficult to produce a test case since the issue seems to occur arbitrarily on a specific unit test in my suite, and not for any general action.click(WebElement).perform()that I do.
I've given the results I'm seeing/expect in the behaviour sections, but more explicitly:
- Results I'm seeing:
actions.click(cancelButton).perform()sometimes does not actually click the element despite it being fully loaded and clickable. Instead the mouse moves to the center of thecancelButtonbut the click never registers - Results I'm expecting: for the click to actually register 100% of the time and click the
cancelButton
I altered my test structure a bit and this issue no longer seems to occur. Closing