简体   繁体   English

如何在 Selenium WebDriver 中使用 SafariDriver

[英]How to use SafariDriver with Selenium WebDriver

I am testing on Selenium WebDriver on SafariDriver.我正在 SafariDriver 上测试 Selenium WebDriver。

I obtain this message in the beginning:我一开始就收到了这条消息:

SafariDriver Launcher

[  0.024s] [safaridriver.client] Connecting to SafariDriver browser extension...
[  0.033s] [safaridriver.client] This will fail if you have not installed the latest SafariDriver extension from
http://selenium-release.storage.googleapis.com/index.html
[  0.033s] [safaridriver.client] Extension logs may be viewed by clicking the Selenium [✓] button on the Safari toolbar
[  0.082s] [safaridriver.client] Connected to extension
[  0.083s] [safaridriver.client] Requesting extension connect to client at ws://localhost:36850

And after I obtain this message error:在我收到此消息错误后:

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request POST /tunnel/cart/add/uenc/aHR0cDovL2dlbmVyb3NpdHktZGVtby5iaXNub2RlLmZyOjgyL2NhbXBhZ25lLWRlLWRvbi10cmVlLWxhYi5odG1s/product/23/form_key/JEQ8UWdbycz65baM/.

Reason: Error reading from remote server

For launching Safari I use:为了启动 Safari,我使用:

Webdriver driver = new SafariDriver()

How can I resolve this problem?我该如何解决这个问题?

You need to download the safaridriver.safaridriverxtz from the provided link and then double click it (click trust) and enable it as an extension for your Safari.您需要从提供的链接下载 safaridriver.safaridriverxtz,然后双击它(单击信任)并将其启用为 Safari 的扩展。

Restart and it should work (although I am running into other issues with it here...).重新启动它应该可以工作(尽管我在这里遇到了其他问题......)。

Configure and enable Safari WebDriver:配置并启用 Safari WebDriver:

  • If you are on macOS v10.13 (High Sierra) and later run 'safaridriver --enable' command in terminal.如果您使用的是macOS v10.13 (High Sierra) 并且稍后在终端中运行“safaridriver --enable”命令。
  • Open the Safari browser and follow the below steps:打开 Safari 浏览器并按照以下步骤操作:
    • Safari → Preferences then on the Advanced tab, select 'Show Develop menu in menu bar' Safari →首选项,然后在高级选项卡上,选择“在菜单栏中显示开发菜单”
    • From the menu bar, choose Develop'Allow Remote Automation'从菜单栏中,选择“开发”“允许远程自动化”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM