V
V
Vladislav2019-10-12 18:53:27
Automation
Vladislav, 2019-10-12 18:53:27

How to use autotest to click on a button on a popup that appears when you click on an element and disappears when you move the mouse away from it?

I am writing an autotest in Selenium WebDriver + C# to follow a link when clicking on a button located on a popup (I find elements using a CSS locator).
Popup appears when you click on a certain element.
This popup disappears if you move the mouse cursor away from it.
When you try to click on the button using the click() method, the popup disappears and the autotest clicks on the element that was located behind the popup.
I tried to go through Actions using moveToElement().ckick().build().perform(), as a result, popup just disappears and an exception is thrown ("element not found").
I also tried to click using JavaScript Excecutor, it worked, but it throws it to the top of the current page, and does not follow the link.
Everything works manually.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
taktik, 2019-10-12
@taktik

I don’t know how to do it exactly the way you want, but you can cheat a little and decide differently:
1) call popup, check that it has opened and that the button is in place
2) just use the webdriver to follow the url to which the button should lead

A
Artyom, 2019-11-13
@hprot

Try this:
driver.findElement(By.id(element_id)).getLocation()
driver.mouseMove(coordinates.getX(),coordinates.getY())
If the popup appears above\below\side, add another mouse move. Then just click.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question