我正在尝试单击使购买按钮出现的复选框。当我尝试使用它时,我收到“NoMethodError: undefined method 'eula' for Cart:0x101f54810”错误。我认为这可能是因为有两个相同的复选框,但我不确定。
HTML:
<p id="eula-box" class="annoy cc"><input type="checkbox" name="terms_of_service" value="terms_of_service" tabindex=20 />I have read & agree to the End-User License Agreement.</p>
<p id="eula-box" class="annoy pp"><input type="checkbox" name="terms_of_service" value="terms_of_service" tabindex=20 />I have read & agree to the End-User License Agreement.</p>
我的课:
require 'rubygems'
require 'page-object'
require 'page-object/page_factory'
require 'watir-webdriver'
CART_URL = 'http://www.anonymizer.com/cart/checkout.html?SKU=ANONUNV12'
class Cart
include PageObject
page_url CART_URL
checkbox(:eula, :class=>"annoy_cc")
button(:purchase, :value=>'purchase')
def complete_order(data = {})
self.eula.click
end
end
更新:我正在更改对象类型以使其正常工作。Element 是我尝试的最后一种类型。我将示例改回复选框(我最初的尝试)。感谢您指出了这一点。