0

我正在尝试为我正在自动化的表单创建一个页面对象,并为“checkout_form”获取未定义的局部变量或方法,尽管我认为我已经定义了该变量。

这是我的页面对象页面:

    require "page-object"

    class CheckoutForm
        include PageObject

        # Checkout page
        # Billing info
        text_field(:billingfirst, :id => 'CheckOut_BillingTag_FirstName')
        text_field(:billingmiddle, :id => 'CheckOut_BillingTag_MiddleInitial')
        text_field(:billinglast, :id => 'CheckOut_BillingTag_Lastname')
        text_field(:billingaddress, :id => 'CheckOut_BillingTag_Address1')
        text_field(:billingaddress2, :id => 'CheckOut_BillingTag_Address2')
        text_field(:billingcity, :id => 'CheckOut_BillingTag_City')
        text_field(:billingstate, :id => 'CheckOut_BillingTag_State')
        text_field(:billingzip, :id => 'CheckOut_BillingTag_ZipCode')
        text_field(:billingphone, :id => 'CheckOut_BillingTag_Phone')
        text_field(:billingemail, :id => 'CheckOut_BillingTag_Email')

        def billing_info( billingfirst, billingmiddle, billinglast, billingaddress, billingaddress2, billingcity, billingstate, billingzip, billingphone, billingemail ) 
            self.billingfirst = billingfirst
            self.billingmiddle = billingmiddle
            self.billinglast = billinglast
            self.billingaddress = billingaddress
            self.billingaddress2 = billingaddress2
            self.billingcity = billingcity
            self.billingstate = billingstate
            self.billingzip = billingzip
            self.billingphone = billingphone
            self.billingemail = billingemail
        end
    end

在将使用我添加的页面对象的另一个页面上'require_relative“checkout-form.rb”'

我在那里设置了驱动程序:

@b = Watir::Browser.new :ff
checkout_form = CheckoutForm.new(@b)

并在此处与 pageobject 方法进行交互:

    checkout_form.billing_info.set 'Mike', 'L', 'Jones', '13677 Ruette Le Parc', 'Unit G', 'Del Mar', 'CA', '92014', 'aaaaa', 'mike.jones@gmail.com'    
4

0 回答 0