带有safaridriver的Selenium 3.0.1在waitForElementVisible()上失败 [英] Selenium 3.0.1 with safaridriver failing on waitForElementVisible()
问题描述
Safari 10.0.1 macOS Sierra
Safari 10.0.1 macOS Sierra
运行Codeception命令时:
When running Codeception command:
$I->waitForElementVisible(['css' => 'input[type=text][id=UserUsername]'], 30);
在Safari中使用Selenium 3.0.1进行的验收测试中,我收到一条错误消息.失败时截取的屏幕截图清楚地显示了有问题的元素.在Firefox和Chrome中,相同的测试/命令均成功.错误:
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
当我在Safari/Firefox/Chrome中使用Selenium 2.53.1运行相同的测试/命令时,它会找到没有问题的元素.
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?
更新12年1月16日:与Locator相比,waitForElementVisible()命令现在似乎更成问题.如果我将命令更改为$I->waitForElement(['css' => 'input[type=text][id=UserUsername]'], 30);
,则测试将成功前进,直到下一个waitForElementVisible()命令.
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.
推荐答案
Safari技术预览版,如果您的问题仍然存在,我们可以得出结论,这是其他问题,而不是可见性检查不完整.如果您的问题消失了,那将不完全是您的用户体验,但是总比没有好.另外,您也可以尝试使用浏览器一侧的脚本(例如
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).
要在Safari Technology Preview中运行测试,请添加
To run your tests in Safari Technology Preview, add
'safari.options': { technologyPreview: true }
功能.
另请参阅关于该主题的其他答案.
这篇关于带有safaridriver的Selenium 3.0.1在waitForElementVisible()上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!