SafariDriver Immediately Releases Click Events. Does not Check Pending Navigation.
See original GitHub issueThis was reported in 2014 but never triaged/addressed. See Google Code - Open Issues
The issue: After clicking a link / button using SafariDriver, it appears there is no check for pending navigation requests before releasing the click event as complete.
The Consequence: Click actions which result in a page refresh or redirect are released before the refresh/redirect occurs and thus proceeding actions are kicked off too early and fail consistently.
The Workaround: Add element level waits after click-through events to stop SafariDriver from submitting the next actions too early. Downside is the element-wait timeout is being eaten up by page load. Moreover, because the click has been released as successful, any failure is attributed to the next action rather than the click.
The Solution: Have SafariDriver behave similar to ChromeDriver in which pending navigations are checked before releasing the click action. My fear is that there is a good reason why SafariDriver cannot do this, and perhaps this is why the issue was never addressed. If this is the case, it would just be great to understand the limitation and hear if there are better / other workarounds.
Here are some details from the original ticket post to help illustrate the matter.
SafariDriver log:
14:37:57.86 [safaridriver.extension.Server] [779h50wyyvq2] Received a message: {"origin":"webdriver","type":"command","command":{"id":"79","name":"clickElement","parameters":{"id":":wdc:1412681861302"}}}
14:37:57.87 [safaridriver.extension.Server] [779h50wyyvq2] Executing command: clickElement
14:37:57.87 [safaridriver.extension.Tab] [2ymt8tn075fa] Sending message: {"origin":0,"type":"command","command":{"id":"9hv7rx7u2env","name":"clickElement","parameters":{"id":":wdc:1412681861302"}}}
14:37:57.87 [safaridriver.inject._Top_] [p1s4okvij0cl] Executing {"id":"9hv7rx7u2env","name":"clickElement","parameters":{"id":":wdc:1412681861302"}}
14:37:57.88 [safaridriver.extension.Tab] [2ymt8tn075fa] Received response: {"origin":1,"type":"response","id":"9hv7rx7u2env","response":{"status":0,"value":null}}
14:37:57.88 [safaridriver.extension.Server] [779h50wyyvq2] Sending response: {"origin":0,"type":"response","id":"79","response":{"status":0,"value":null}}
ChromeDriver log:
[26.534][INFO]: COMMAND ClickElement {
"id": "0.7670850940048695-14"
}
[26.534][INFO]: Waiting for pending navigations...
[26.534][INFO]: Done waiting for pending navigations
[26.594][INFO]: Waiting for pending navigations...
[38.981][INFO]: Done waiting for pending navigations
[38.981][INFO]: RESPONSE ClickElement
under SafariDriver response for click action is being sent immediately after click but, this click leads to another page and it should send a response when new page loaded(like under ChromeDriver).
Selenium Version: 2.48.2 / 2.49.0 OS Version: Mac OS X Yosemite / El Capitan Browse Version: Safari 9.0 / 9.0.1 / 9.0.2
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
I too see that SafariDriver doesn’t wait for navigation to finish, whereas both ChromeDriver and Phantom do.
I have a form that submits to the same URL, and returns to the same URL. The submission (a click event) continues the test immediately without waiting for the page navigation to finish (i.e. waiting for the submit action to complete).
Does this mean I need to litter my tests with
if using safari, wait X time
? Or a fix for this?Execution logs are the same, but Safari doesn’t wait.
Safari log:
Chrome:
The issue was raised 2 years ago on the driver implementation developed by Selenium team. It’s 2018 and now Apple develops safari driver, issues should be reported to https://bugs.webkit.org/