Selenium 3.0.1 with safaridriver failing on waitForElementVisible()

旧时模样 提交于 2019-12-24 05:22:03

问题


Safari 10.0.1 macOS Sierra

When running Codeception command:

$I->waitForElementVisible(['css' => 'input[type=text][id=UserUsername]'], 30);

in an acceptance test in Safari with Selenium 3.0.1 I receive an error. The screenshot taken at failure clearly displays the element in question. The same test/command is successful in both Firefox and Chrome. The error:

Screenshot saved to /Applications/MAMP/htdocs/AutomatedTests/tests/_output/debug/FAILED1479307207.png
  Unable to retrieve Selenium logs : The command 'GET /session/9BC56414-8934-4315-9293-B6E99720E318/log/types' is not implemented.
  Command duration or timeout: 3 milliseconds
  Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
  System info: host: 'Cosettes-MacBook-Pro.local', ip: '10.0.1.75', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.1', java.version: '1.8.0_101'
  Driver info: org.openqa.selenium.safari.SafariDriver
  Capabilities [{applicationCacheEnabled=true, rotatable=false, databaseEnabled=true, handlesAlerts=true, version=12602.2.14.0.5, cleanSession=true, platform=MAC, nativeEvents=true, locationContextEnabled=false, webStorageEnabled=true, browserName=safari, javascriptEnabled=true, cssSelectorsEnabled=true}]
  Session ID: 9BC56414-8934-4315-9293-B6E99720E318
  Screenshot and page source were saved into '/Applications/MAMP/htdocs/AutomatedTests/tests/_output/' dir
 ERROR 

When I run the same test/command in Safari/Firefox/Chrome with Selenium 2.53.1 it finds the element with no problems.

Is there a known issue with this type of locator I'm not finding when going through the forums? Anyone have a suggestion for how to make this work?

Update 12-01-16: This now seems to be more of an issue with waitForElementVisible() command than the Locator. If I change the command to $I->waitForElement(['css' => 'input[type=text][id=UserUsername]'], 30); the test successfully moves forward till the next waitForElementVisible() command.


回答1:


People say visibility checks are broken in the release version of Safari 10. You can try Safari Technology Preview, and if your issue is still there, we can conclude it's some other issue, not the broken visibility checks. If your issue is gone, it'll be not exactly your users' experience, but better than nothing anyways. Also you can try implementing your own visibility checks as a workaround using some script on the browser's side (e.g. this function looks good enough).

To run your tests in Safari Technology Preview, add

'safari.options': { technologyPreview: true }

to the capabilities.

See also my other answer on this subject.



来源:https://stackoverflow.com/questions/40635371/selenium-3-0-1-with-safaridriver-failing-on-waitforelementvisible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!