Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium - what is the difference between click and clickAndWait?

I am new to selenium and need some clarification on some stuff. I've tried click and clickAndWait in the IDE, and while the references stated clearly what each meant, when I export the test case to Python, it seems like both are doing the same thing here

driver.find_element_by_xpath("//li[@id='pa-u_8298348-bd']/a/span[2]").click() #click and wait
driver.find_element_by_link_text("IMVironments").click() #click

Can someone tell me what is the difference here then?

like image 313
goh Avatar asked Apr 20 '12 04:04

goh


2 Answers

From Selenium docs:

Many Actions can be called with the "AndWait" suffix, e.g. "clickAndWait". This suffix tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.

like image 127
Trott Avatar answered Sep 28 '22 05:09

Trott


2 years later, I know. But I was looking for the same answer and found it.

From the Selenium Wiki

The AndWait alternative is always used when the action causes the browser to navigate to another page or reload the present one.

In other words, Selenium's webdriver, when utilizing the Click() command, will inherently use the "AndWait" modifier if it recognizes a page load.

See also Interface WebElement

void click()

Click this element. If this causes a new page to load, this method will attempt to block until the page has loaded.

like image 26
Machtyn Avatar answered Sep 28 '22 04:09

Machtyn