1
I have some components on my screen in a Section that has a scroll.
When I try to click on a component where it is necessary to use the scroll to find the component. But apparently the scroll has a delay and when Selenium tries to click my component is not yet "visible". This generates the following error:
org.openqa.Selenium.Webdriverexception: Unknown error: Element is not clickable at point
Currently I am doing the Scrolling and Click as follows:
public void scrollAndClick(WebElement webElement) {
Actions action = new Actions(webDriver);
action.moveToElement(webElement);
action.perform();
WebDriverWait wait = new WebDriverWait(webDriver, 10);
wait.until(ExpectedConditions.elementToBeClickable(webElement));
webElement.click();
}
I also tried to disable Chrome scroll-Smooth through the command --disable-smooth-scrolling
but this command has no effect, searching found some issues open to this case.
I could put a Thread.sleep
before the click, but would not be cool.
Does anyone have any other suggestions?
I don’t know if it will help you, but it’s just an idea, there’s no way you could pick up the xpath item where it will be clicked so you wouldn’t have to have the item on the screen,
– Bulfaitelo
I understood, but how I would do it. The click would be done by Javascript?
– DiegoAugusto
you can use for example
element = body.find_element_by_xpath.('xpath do elemento')
after meeting himelemento.click();
in case it gets weird I only used Python Selenium but I think the idea is the same.– Bulfaitelo
So that’s what I already do today. the webElement that appears in my code is already xpath. :(
– DiegoAugusto
It only "appears" to the xpath when it gets on screen ?
– Bulfaitelo
Yes. While the scroll animation doesn’t finish, I can’t click on the component. But the same already exists in the DOM
– DiegoAugusto
You can move the page with the keys could do what send a keyboard command to scroll down the screen create a Sleep and after continuity to the script, it is just an idea.
– Bulfaitelo
So I guess it wouldn’t be cool to use a Sleep. But thanks for the ideas.
– DiegoAugusto
when I said Sleep I meant the method that waits until an item appears, you set a time until it appears.
– Bulfaitelo