Selenium clicks below elements when running on Apple Mac/Safari 13.0.1
🐛 Bug Report
When Selenium tests that click on elements are run, the clicking is visibly below the actual element. This happens for all elements tested and for all tests on which we tried this.
It only happens on Apple Mac/Safari 13.0.1. Was not tested on iOS devices. Same Apple Mac machine runs tests correctly on Chrome. Other Macs running Safari 12.x also run correctly. We tested this with Selenium 3.141.59 and 4.0.0 alpha-2 - bug reproduces identically on both versions, when browser is Safari 13.0.1.
To Reproduce
Detailed steps to reproduce the behavior:
- Use any Selenium test that involves clicking an element (button, etc) that is sufficiently narrow.
- Run on Apple Mac, Safari v13.0.1. selenium-standalone-server.jar v3.141.59 or v4.0.0 alpha-2.
- Clicking will visibly occur below the element. All clicking seems to be off expected location by a constant offset.
Expected behavior
When clicking an element, clicking should occur within that element, such that it is clicked.
Test script or set of commands reproducing this issue
Environment
OS: Browser: Safari Browser version: 13.0.1 (14608.2.11.1.11) Browser Driver version: safaridriver 'Included with Safari 13.0.1' (same version as browser) Selenium Grid version (if applicable): N/A
Hi Ron,
We are also witnessing something similar. We have found some issues with extracting text from labels and that's also not working as expected.
Thanks, Ash
Yes, we know already that Safari 13 fails ~20% of the regression test suite that Safari 12 passed well. I'll merge into this issue all the complains related to Safari 13 blackout.
Hi @barancev
Who will be fixing these issues? Apple Safari team or the Selenium devs/contributors?
Thanks, Ash
It should be fixed by Apple.
Thank you everybody for your replies. Any information about which Apple components specifically may be at fault, and links to issues you raised with Apple would be much appreciated :)
safaridriver maintainer here.
Please include the operating system version on which you are seeing these results. As far as I know, the only reports I've seen are from Mojave users who upgraded to Safari 13. Haven't seen any reports on Catalina yet.
Hi @burg ,
I can confirm that its happening on Mojave for me. But I guess safari got updated with the OS and that's why it's happening.
-Ash
@burg I am experiencing this issue on Mojave 10.14.6 as well. Clicking buttons was working with Safari version 13.0. When I upgraded to 13.0.1 it stopped working. The issue persists with Safari 13.0.2.
Hi @burg I am experiencing this issue on Catalina with Safari 13.0.2
Does there is any work around to solve this issue ??
I note that there is little movement on the 2 related WebKit issues (see links below). This is a blocking defect for Selenium/Appium on MacOS/iOS and the community needs a fix or workaround ASAP. Even if WebKit/Apple take their time with a fix, perhaps adjust x,y location of click (x is correct, y needs adjustment) in Selenium/Appium such that it works until WebKit/Apple have fixed it?
https://bugs.webkit.org/show_bug.cgi?id=202589
https://bugs.webkit.org/show_bug.cgi?id=202802
Just tested with STP 94 - defect still reproduces. Are there any plans to fix this or provide a workaround?
It is being investigated.
On Oct 29, 2019, at 04:33, Ron [email protected] wrote:
Just tested with STP 94 - defect still reproduces. Are there any plans to fix this or provide a workaround?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
@burg Kindly let us know if there is any update?
I am using macOS 10.14.6 My Safari got updated to 13.0.2
There are a few Web Applications that are working fine. But in a few Web Applications (like salesforce) I am facing major issues. Sometimes Selenium has issues in finding an element also.
This issue still reproduces on Safari Technology Preview (STP) release 96.
It is being investigated. … On Oct 29, 2019, at 04:33, Ron @.***> wrote: Just tested with STP 94 - defect still reproduces. Are there any plans to fix this or provide a workaround? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Hi @burg
One observation. SafariDriver is not able to interact with an element which has a custom HTML tag in it's hierarchy. Can you kindly advise why this might be the case? Is it a known issue in SafariDriver?
In the meantime, if anyone needs a workaround...
For tags, you can get the href attribute using elem.getAttribute('href'); and then visit that location
For buttons you can click using executeScript:
webdriver.executeScript('arguments[0].click();', elem);
This works in Safari 13.0.3.
webdriver.executeScript('arguments[0].click();', elem);
This is what I started doing. However, if someone has the time to figure this out, a nicer workaround might be to find some way to automatically translate clicks to "executeScript" calls. The idea is to do something like this but the main problem is figuring out how to translate the parameters for a "clickElement" command to an equivalent "executeScript":
new SafariDriver() {
@Override
protected Response execute(String driverCommand, Map<String, ?> parameters) {
if (DriverCommand.CLICK_ELEMENT.equals(driverCommand)) {
// return super.executeScript(...)
}
return super.execute(driverCommand, parameters);
}
}
We actually wrote it into the click function in our node package that wraps selenium. https://www.npmjs.com/package/dce-selenium
This is still being investigated. A fix that was expected for STP 96 was not included for various reasons. I'm sorry for the trouble and will ping All The Threads when it's really fixed.