开发者

Using watir-webdriver, how can I fire an event without waiting for the page to load?

开发者 https://www.devze.com 2023-03-08 13:25 出处:网络
The code for i in 0..10 $browser.link(:id => \"send_link\").fire_event(\"onclick\") puts \"Click #\" + i.to_s

The code

for i in 0..10  
  $browser.link(:id => "send_link").fire_event("onclick")
  puts "Click #" + i.to_s
end

only displays "Click #0" to the console before crashing with an unable to locate element error. I need it to click the link 10 times, even while the page is trying to load from the first click. Is there a way to do this using watir-webdriver, or will I have to use the win32api to hijack the mouse and do a hard click?

Edit: For the time being, I attempted to get around this by using the hardware click method that worked for a different issue I had using wa开发者_JS百科tir and IE8, but it doesn't seem to work with watir-webdriver and Firefox 4.

http://wiki.openqa.org/display/WTR/Right+Click+an+Element


have you tried using .click_no_wait to see if that will work for you?

10.times do |i|  
  $browser.link(:id => "send_link").click_no_wait
  puts "Click #" + i.to_s
end
0

精彩评论

暂无评论...
验证码 换一张
取 消