Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 当使用数据填充页面时,如何等待元素加载到页面对象中?_Ruby_Watir_Watir Webdriver_Page Object Gem - Fatal编程技术网

Ruby 当使用数据填充页面时,如何等待元素加载到页面对象中?

Ruby 当使用数据填充页面时,如何等待元素加载到页面对象中?,ruby,watir,watir-webdriver,page-object-gem,Ruby,Watir,Watir Webdriver,Page Object Gem,我将页面对象gem与watirwebdriver一起使用。在这里,我使用的是“populate_page_with”特性,当等待加载某个元素时,我无法使用该特性 在下面的脚本中,我应该输入:sum_ctgy,:sd和:foregin的详细信息,然后我应该等待:sumc可见。我正在用数据填充页面,方法的数据如下所示 sumdetailspage: sum_ctgy: Test1 sd: Test2 sumc: 502 sumd: -450 请告诉我使用填充方法解决此问题的更好方法

我将页面对象gem与watirwebdriver一起使用。在这里,我使用的是“populate_page_with”特性,当等待加载某个元素时,我无法使用该特性

在下面的脚本中,我应该输入
:sum_ctgy
:sd
:foregin
的详细信息,然后我应该等待
:sumc
可见。我正在用数据填充页面,方法的数据如下所示

sumdetailspage:
  sum_ctgy: Test1
  sd: Test2
  sumc: 502
  sumd: -450
请告诉我使用填充方法解决此问题的更好方法

 class SumDetailsPage
  include PageObject
  include DataMagic

  select_list(:sum_ctgy, :name => /categoryDescription/) --> send details
  text_field(:sd, :id => /sumDestination/) --> continue
  text_field(:foreign, :name => /foreignSymbol/) --> continue
  div(:pw, :id => /PleaseWaitMessage/) --> please wait behavior to complete(until hidden)
  text_field(:sumc, :id => /sumCalc/) --> then continue, but it is not waiting for this element to load
  text_field(:sumd, :id => /sumCalcdep/)

  def train_details(data = {})
    DataMagic.load('traindata.yml')
    populate_page_with data_for(:sumdetailspage, data)
    pw_element.when_not_visible  --> wait
    populate_page_with data_for(:sumdetailspage, data) --> again continue...
  end
end

我建议为sumc元素提供一个块,以便它总是等待消息消失。这是有益的,因为与文本字段的任何交互都将始终等待-即如果您正在设置、获取等

text_field(:sumc){ 
  pw_element.when_not_visible
  text_field_element(:id => /sumCalc/)
}
然后,您可以像平常一样使用“填充页面”

注意:这假设您使用的是Ruby 1.9+,其中保留了散列的插入顺序-即
page\u populate\u with
将输入:sum\u ctgy、:sd和:foregin然后是:sumc(并假设这是您指定它们的顺序)