我已经设置了我的calabash android工作正常。 现在我必须在android模拟器中添加一个场景 我需要打开默认浏览器 导航到网址(即https://def/l/abc) 假设应用程序已安装,它将打开应用程序。 然后我可以登录该应用程序继续前进。 我如何通过葫芦自动化这个。特别打开浏览器并单击链接。 假设我的模拟器已经打开。 我找到了像
这样的东西 require 'selenium-webdriver'
caps = Selenium::WebDriver::Remote::Capabilities.android
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 480
driver = Selenium::WebDriver.for(
:remote,
:http_client => client,
:desired_capabilities => caps,
)
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!
然而它总是给出错误
ruby test.rb
/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/net/http.rb:878:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)
from /Users/asinha/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/net/http.rb:878:in `open'
from /Users/asinha/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
from /Users/asinha/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
from /Users/asinha/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/net/http.rb:877:in `connect'
from /Users/asinha/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
from /Users/asinha/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/net/http.rb:851:in `start'
from /Users/asinha/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/net/http.rb:1367:in `request'
from /Users/asinha/.rvm/gems/ruby-2.0.0-p598/gems/selenium-webdriver-2.46.2/lib/selenium/webdriver/remote/http/default.rb:107:in `response_for'
from /Users/asinha/.rvm/gems/ruby-2.0.0-p598/gems/selenium-webdriver-2.46.2/lib/selenium/webdriver/remote/http/default.rb:58:in `request'
from /Users/asinha/.rvm/gems/ruby-2.0.0-p598/gems/selenium-webdriver-2.46.2/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
from /Users/asinha/.rvm/gems/ruby-2.0.0-p598/gems/selenium-webdriver-2.46.2/lib/selenium/webdriver/remote/bridge.rb:657:in `raw_execute'
from /Users/asinha/.rvm/gems/ruby-2.0.0-p598/gems/selenium-webdriver-2.46.2/lib/selenium/webdriver/remote/bridge.rb:122:in `create_session'
from /Users/asinha/.rvm/gems/ruby-2.0.0-p598/gems/selenium-webdriver-2.46.2/lib/selenium/webdriver/remote/bridge.rb:87:in `initialize'
from /Users/asinha/.rvm/gems/ruby-2.0.0-p598/gems/selenium-webdriver-2.46.2/lib/selenium/webdriver/common/driver.rb:52:in `new'
from /Users/asinha/.rvm/gems/ruby-2.0.0-p598/gems/selenium-webdriver-2.46.2/lib/selenium/webdriver/common/driver.rb:52:in `for'
from /Users/asinha/.rvm/gems/ruby-2.0.0-p598/gems/selenium-webdriver-2.46.2/lib/selenium/webdriver.rb:84:in `for'
from test.rb:6:in `<main>'
答案 0 :(得分:0)
我认为你可能会混淆Calabash的用途。 Calabash用于测试iOS和Android应用程序。据我所知,Calabash不支持您尝试做的事情。如果我错误地认为Calabash无法通过网址打开您的应用,那么您仍需要将<uses-permission android:name="android.permission.INJECT_EVENTS"/>
添加到Android清单文件中,以便能够使用手机的“原生”功能,例如按主页按钮,按后退按钮等。然后您将面临无法启动Web浏览器的问题。 Calabash使用您的apk文件在您的手机上安装应用程序以使用模拟器进行替换。因此,Calabash在某种“沙盒”环境中,因为它不知道如何与您的设备的固件和硬件进行通信。因此,据我所知,你想要做的事情不在Calabash所达到的范围内。希望这会有所帮助。