R
R
red06060606062021-07-12 20:31:28
Java
red0606060606, 2021-07-12 20:31:28

Can't click on element inside frame. ElementNotInteractableException error?

60ec7bd2499c4157855774.png

There was a difficulty when working with iframe.
I need to somehow click on the last element with the bg-event-time-container class. but the click does not work and the system swears that ElementNotInteractableException

tried like this:

@FindAll({@FindBy(xpath = "//div[@class='bg-allowed fc-bgevent']")}) // Свободное время для врача
    List<WebElementFacade> emptyShedulePlace;
    public void clickLastFreeTimeForDoctor() {

        List <WebElementFacade> empty = emptyShedulePlace.get(0).thenFindAll(".//div");
        scrollIntoView(emptyShedulePlace.get(0));
        System.out.println("size_ "+empty.size());
        empty.get(empty.size()-1).click();

        WebElement ele = empty.get(empty.size());
        JavascriptExecutor executor = (JavascriptExecutor)empty;
        executor.executeScript("arguments[0].click();", ele);
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
red0606060606, 2021-07-16
@red0606060606

found a solution to the problem:
String appointmentSlotPatternNoRecord = "//div[@class='bg-allowed fc-bgevent']//div[@class='text-center bg-event-time']//span[text()= '%s']/ancestor::div[@class='bg-event-time-container']";
passed it the value for span and click in this case only worked
$(String.format(appointmentSlotPatternNoRecord, value)).waitUntilClickable().click();

O
Orkhan, 2021-07-13
Hasanly @azerphoenix

Good afternoon!
If I'm not mistaken, then you need to switch to iframe. You cannot click on its elements without switching to it.
Useful related link:
https://www.guru99.com/handling-iframes-selenium.html

It is impossible to click iframe directly through XPath since it is an iframe. First we have to switch to the frame and then we can click using xpath.

Here's how switching to a frame works (read the article at the link above):
driver.switchTo().frame("a077aa5e");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question