gms
gms

Reputation: 11

How to click a button when it is covered by tooltips of other links above the button in selenium

I have a scenario where I need to click a button to edit the page, But above this edit button there are links.. when am running the code the mouse automatically moving over those links and masking the EDIT button. Can Anyone Suggest me hoe to click that button

Upvotes: 1

Views: 869

Answers (2)

fabdurso
fabdurso

Reputation: 2444

You should hide your elements you don't want to appear on the page with something like

driver.execute_script(document.getElementById('THE_ID_OF_YOUR_ELEMENT').style.display='none';");

If you don't want to use the ID, you can also use the css selector, the xpath, etc...

Upvotes: 0

Guy
Guy

Reputation: 50909

JavaScript will click on the element regardless its state (covered in your case)

//Java syntax, similar in other languages
WebElement button = driver.findElement(By.id("id")); //locate the button
JavascriptExecutor js = (JavascriptExecutor)driver;  //initialize JavascriptExecutor
js.executeScript("arguments[0].click();", button);   //click the button

Upvotes: 1

Related Questions