Watir页面对象用于复杂元素

时间:2018-09-14 19:04:16

标签: ruby automated-tests watir pageobjects

具有此html:

<div class = "account">
    <div class = "name"></div>
    <div class = "email"></div>
    <div class = "phone"></div>
</div>
<div class = "account">
    <div class = "name"></div>
    <div class = "email"></div>
    <div class = "phone"></div>
</div>
<div class = "account">
    <div class = "name"></div>
    <div class = "email"></div>
    <div class = "phone"></div>
</div>

我想创建一个包含帐户列表的页面对象,但是由于我是Ruby和watir的新手,所以我不知道它的外观。

这是“帐户”类别:

class Account
  def initialize(browser)
    @browser = browser
  end
  def user
    @browser.div(:class => "name")
  end

  def email
    @browser.div(:class => "email")
  end

  def phone
    @browser.div(:class => "phone")
  end
end

我需要有帐户列表的页面对象

class Page 
  def initialize(browser)
    @browser = browser
  end

#here should be a list of accounts

end 

0 个答案:

没有答案