Appium 如果你遇到 private method `capabilities' called for #<Hash:0x007fd6cd82bb48> (NoMethodError)

恒温 · 2014年01月20日 · 最后由 twh_eastasia 回复于 2014年01月20日 · 994 次阅读

如果你在运行 appium 的 cucumber case 时候遇到这样的问题,

Scenario: Add two numbers                               # features/calculator.feature:43
    Given I have entered 4 into field 1 of the calculator # features/step_definitions/steps.rb:21
      Called: 4  1
      private method `capabilities' called for #<Hash:0x007fd6cd82bb48> (NoMethodError)
      ./features/support/env.rb:41:in `selenium'
      ./features/step_definitions/steps.rb:24:in `/^I have entered (\d+) into field (\d+) of the calculator$/'
      features/calculator.feature:44:in `Given I have entered 4 into field 1 of the calculator'
    And I have entered 7 into field 2 of the calculator   # features/step_definitions/steps.rb:21
    When I press button 1                                 # features/step_definitions/steps.rb:28
    Then the result should be displayed as 11             # features/step_definitions/steps.rb:33
      undefined method `quit' for nil:NilClass (NoMethodError)
      /Users/Apple/code/appium/sample-code/examples/ruby/cucumber/features/support/env.rb:50:in `After'

Failing Scenarios:
cucumber features/calculator.feature:43 # Scenario: Add two numbers

请将 capabilities 改成别的名字


# What we need as a capability --> iOS device, where our app is, ect.
def caps
  {
    'browserName' => '',
    'platform' => 'Mac',
    'device' => 'iPhone Simulator',
    'version' => '6.0',
    'app' => absolute_app_path,
  }
end



# The location of our selenium (or in this case, Appium) file
def server_url
  "http://127.0.0.1:4723/wd/hub"
end

# Set up a driver or, if one exists, return it
def selenium
  @driver ||= Selenium::WebDriver.for(:remote, :desired_capabilities => caps, :url => server_url)
end

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 3 条回复 时间 点赞

这个我之前也被坑过,然后我就直接把 capabilities 和 server_url 定义在 selenium 的内部了,然后也能跑通,虽然不太美观 😄

#1 楼 @twh_eastasia 哈哈 这个是我今天帮你看 orientation 的时候 发现的。坑爹。

你好,我想咨询下,如何让 appium 每次启动后不用重新安装 APP,通过 cucumber 来实现的。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册