Sergei
Sergei

Reputation: 195

Why can't SafariDriver click on a specific element when Chrome, FF, Edge can?

I have a trouble when running Safari UI tests on MAC. I have an element:

wd.find_element_by_xpath("//div[@id='ZoomBundle_people_search__searchTab-innerCt']//fieldset//span[text()='Company Information']")

enter image description here It collapses/uncollapses a hidden block with filters. When I perform a click() action in Chrome, FF or Edge, this action performed. But when I run the same code for Safari, I get the exception:

selenium.common.exceptions.ElementNotInteractableException: Message:
C:\python\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: ElementNotInteractableException

I tried to add WebDriverWait, but the result is the same. It sees the element, but can't interact with it.

Upvotes: 1

Views: 1927

Answers (3)

Brian Burg
Brian Burg

Reputation: 815

If you believe this is a bug in safaridriver, please file a bug report at https://feedbackassistant.apple.com/ with a test case and test script. This behavior is well specified, so any divergence between implementations is probably a bug.

Upvotes: 0

Sudar
Sudar

Reputation: 101

If you don't want to execute javascript, try actual simulation of pressing the keyboard Enter key as follows.

Below sample corresponds to Python code

from selenium.webdriver.common.keys import Keys

driver = webdriver.Safari()
element = driver.find_element_by_xpath("//div[@id='ZoomBundle_people_search__searchTab-innerCt']//fieldset//span[text()='Company Information']")
element.send_keys(Keys.RETURN)

P.S: I am still wondering, if its an issue with SafariDriver then why Apple has not looked into it yet or is it due to something else. While I continue to look out an answer you can try the above method.

Upvotes: 1

Sergei
Sergei

Reputation: 195

It's a SafariDriver issue. Got a suggestion to try clicking via JS:

wd.execute_script("arguments[0].click();", elem)

instead

elem.click()

And it's working fine now (=

Upvotes: 3

Related Questions