我下载了ChromeDriver https://sites.google.com/a/chromium.org/chromedriver/downloads并将其放入Android SDK文件夹中的platform-tools
文件夹中。我已将手机连接起来,并且可以正确设置,当我运行时./chromedriver
它说
$ ./chromedriver
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 9515
Only local connections are allowed.
但是如何让Watir连接到它呢?我尝试了以下操作,但它只是在Android设备上打开本地桌面浏览器而不是浏览器。
@browser = Watir::Browser.new(:remote, :url => "http://localhost:9515")
答案 0 :(得分:1)
基于ChromeDriver's Getting Started page for Android,您需要指定androidPackage Chrome选项。
Ruby和Watir等效的例子是:
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
"chromeOptions" => { "androidPackage" => "com.android.chrome" }
)
@browser = Watir::Browser.new(
:remote,
:url => "http://localhost:9515",
:desired_capabilities => caps
)