---
title: "Using watir-webdriver, how can I fire an event without waiting for the page to l"
author: "lilingjay"
date: "2012-04-01T14:45:33Z"
tags: []
categories: ["开源软件"]
slug: "using-watir-webdriver-how-can-i-fire-an-event-without-waiting-for-the-page-to-l"
draft: false
lastmod: "2012-03-31T23:46:18Z"
id: 1472028
url: "https://lilingjay.iteye.com/blog/1472028"
---

link: [http://stackoverflow.com/questions/6127031/using-watir-webdriver-how-can-i-fire-an-event-without-waiting-for-the-page-to-l](http://stackoverflow.com/questions/6127031/using-watir-webdriver-how-can-i-fire-an-event-without-waiting-for-the-page-to-l)

Question：

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 watir 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](http://wiki.openqa.org/display/WTR/Right+Click+an+Element)

 

Answer:

 

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
```