如果你在运行 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