我使用的是Ruby/Cucumber
我的页面:
class DemoContextMenuPage
include PageObject
include DataMagic
page_url 'http://the-internet.herokuapp.com/context_menu'
h5(:context_menu_title, :css => '.example > h3:nth-child(1)')
div(:context_menu_hotspot, :id => 'hot-spot')
end我的步骤:
When /^I right click context menu hot spot$/ do
on(DemoContextMenuPage).context_menu_hotspot_element.right_click
end我的特点是:
Scenario: Verify right click menu
Given I am on the context menu page
When I right click context menu hot spot结果:# (NoMethodError)的未定义方法`context_click
watir-webdriver only selenium-webdriver Se=2.53.4、watir=0.9.3没有问题
发布于 2016-09-28 21:43:26
这是Page Object gem中的一个错误。您可以从page object's Selenium implementation中看到它是这样做的:
def right_click
element.context_click
endcontext_click不是为硒元素定义的方法。
从Watir source code中可以看到,上下文单击需要使用操作构建器来完成:
driver.action.context_click(@element).perform不幸的是,似乎没有一种方法可以从Selenium::元素中获取Selenium::WebDriver。我认为您需要从页面对象调用上下文单击:
on(DemoContextMenuPage) do |page|
e = page.context_menu_hotspot_element.element
page.browser.action.context_click(e).perform
endhttps://stackoverflow.com/questions/39712647
复制相似问题