question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SafariDriver Immediately Releases Click Events. Does not Check Pending Navigation.

See original GitHub issue

This 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:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ashleydwcommented, Apr 25, 2016

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:

15:10:43.506 INFO - Executing: [click: 7 [[SafariDriver: safari on MAC (null)] -> name: save]])
15:10:43.513 INFO - Done: [click: 7 [[SafariDriver: safari on MAC (null)] -> name: save]]
15:10:43.514 INFO - Executing: [find element: By.xpath: //ul[@class='orangeText']/li[1]])

Chrome:

15:11:55.909 INFO - Executing: [click: 7 [[ChromeDriver: chrome on MAC (...)] -> name: save]])
15:11:56.353 INFO - Done: [click: 7 [[ChromeDriver: chrome on MAC (...)] -> name: save]]
15:11:56.354 INFO - Executing: [find element: By.xpath: //ul[@class='orangeText']/li[1]])
15:11:56.369 INFO - Done: [find element: By.xpath: //ul[@class='orangeText']/li[1]]
0reactions
barancevcommented, Apr 4, 2018

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/

Read more comments on GitHub >

github_iconTop Results From Across the Web

SafariDriver Immediately Releases Click Events. Does not ...
The issue: After clicking a link / button using SafariDriver, it appears there is no check for pending navigation requests before releasing the ......
Read more >
Click event not working in Safaridriver on Catalina OS where ...
This is an existing issue for Safari v13, a lot of people are experiencing the same. There is a similar question here ....
Read more >
Safari Technology Preview Release Notes - Apple Developer
If you already have Safari Technology Preview installed, you can update in the Software Update pane of System Preferences on macOS Monterey, or...
Read more >
WebDriver - W3C
The Element Click command could not be completed because the element receiving the events is obscuring the element that was requested clicked.
Read more >
How to run Selenium tests on Safari using SafariDriver
Running Selenium Tests on Safari using SafariDriver​​ To do so, enable the Safari Developer menu first with the steps below: Go to Safari...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found