对于“重复”场景,Watir-webdriver挂起1-2分钟

时间:2014-09-23 08:34:28

标签: cucumber watir-webdriver

我的页面对象中有下一个方法:

def open_random_report(count)
  opened_reports = 0
  rows = self.how_many_reports_present
  cells = self.browser.divs(:class=>/x-grid-cell-inner./)
  type_position = self.calculate_report_type_position
  row_length = 0
  self.browser.divs(:class=>"x-column-header-inner").each do |d|
      if d.visible?
        row_length += 1
      end
  end
  while opened_reports  < count.to_i do
    $start=Time.now
    r = Random.new
    row = r.rand(rows - 2)
    cell_position = type_position + (row * row_length) - 1
    cells[cell_position].a.click
    opened_reports += 1
    sleep 1
    self.close_report
    $finish=Time.now
    p "#{$finish} Report# #{opened_reports} - #{$finish - $start}" 
    f = File.new('log.txt', 'a')
    f.puts "#{$finish} Report# #{opened_reports} - #{$finish - $start}" 
    f.close
  end
  end

此代码点击表格中的随机单元格(表格由extjs-grid表示),除了一件事情外它可以正常工作:驱动程序不时挂起1-2分钟。悬挂没有模式,可以在运行期间发生一次,也可以在运行期间发生10次。 还有一个细节:当驱动程序单击单元格时,应用程序会生成pdf报告,该报告将在预览窗口中显示给用户。我不关心报告我的目标只是打开报告,所以我关闭了预览窗口,尽管pdf已经完全加载或不加载。 有什么想法可能会发生这样的悬念?也许代码有问题?

0 个答案:

没有答案