简体   繁体   中英

Watir 4.0.2 Click crashes the browser

The following code is causing some issues:

b = Watir::Browser.new

options =  b.select.options

options.each do |opt|
  s =  opt.text
  i = s.length - 1
  if s[i-1] == '(' then
    puts s
    b.select().select_value(s)
    b.text_field(:id => 'nombre', :name => 'nombre').value = '0'
    b.input(:class => 'bouton-ajouter').click
  end
end

When the click is performed it stops doing the each and just crashes. Why could this be so?

I don't know what you are trying to do, but I have corrected your program a bit, try this

require 'watir'

b = Watir::Browser.new

b.select_list.options.each { |opt|
  s = opt.text
  if s.chars.last == '('
    puts s
    b.select_list.option(text: s).select
    b.text_field(:id => 'nombre', :name => 'nombre').set '0'
    b.input(:class => 'bouton-ajouter').click
  end
}

谢谢你们的帮助,我想我只是想出了怎么做,我会重新加载我的浏览器回到我的选择更改另一个选项并在上面创建一段时间直到没有选项数据符合我的条件,这是最简单的我的想法(如果我不能升级)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM