我正在使用 cucumber、selenium-webdriver 和 page-object gem 进行测试自动化。当我尝试运行简单的测试黄瓜时,会遇到以下错误:
Scenario: Going to billing # features/test.feature:10
When I click 'Платные услуги' # features/step_definitions/test_steps.rb:13
Unable to locate element: {"method":"link text","selector":"Платные услуги"} (Selenium::WebDriver::Error::NoSuchElementError)
[remote server] file:///tmp/webdriver-profile20130412-21410-z4p1ez/extensions/fxdriver@googlecode.com/components/driver_component.js:8405:in `FirefoxDriver.prototype.findElementInternal_'
[remote server] file:///tmp/webdriver-profile20130412-21410-z4p1ez/extensions/fxdriver@googlecode.com/components/driver_component.js:8414:in `FirefoxDriver.prototype.findElement'
[remote server] file:///tmp/webdriver-profile20130412-21410-z4p1ez/extensions/fxdriver@googlecode.com/components/command_processor.js:10421:in `DelayedCommand.prototype.executeInternal_/h'
[remote server] file:///tmp/webdriver-profile20130412-21410-z4p1ez/extensions/fxdriver@googlecode.com/components/command_processor.js:10426:in `DelayedCommand.prototype.executeInternal_'
[remote server] file:///tmp/webdriver-profile20130412-21410-z4p1ez/extensions/fxdriver@googlecode.com/components/command_processor.js:10366:in `DelayedCommand.prototype.execute/<'
./features/pages/job_main_page.rb:38:in `go_to_billing'
./features/step_definitions/test_steps.rb:14:in `/^I click 'Платные услуги'$/'
features/test.feature:11:in `When I click 'Платные услуги''
这是黄瓜的特点:
Scenario: Going to billing
When I click 'Платные услуги'
Then I should see "Коммерческие услуги"
测试所在的步骤定义:
When(/^I go to billing$/) do
@job_myroom_billing = @job_myroom.billing_element.when_visible.go_to_billing
end
和页面对象:
class BasePage
include PageObject
include RSpec::Matchers
end
class JobMyroom < BasePage
link :billing, link: 'Платные услуги'
def go_to_billing
billing
JobMyroomBilling.new @browser
end
end
class JobMyroomBilling < JobMyroom
#some code
end
怎么了?司机不要等待元素的存在