0

I am trying to loop clicks with Selenium, the first click is working but the second gives error below: selenium.common.exceptions.ElementNotInteractableException: Message: Element could not be scrolled into view

Here is the code:


    def send_keys_dropdown(self,url):
        bot = self.bot
        bot.get(url)
        elements = bot.find_elements_by_xpath("//a[@data-tag='globalize']")
        for elem in elements:
            class_of_element = elem.get_attribute("class")
            if class_of_element == 'CsLinkButton':
                elem.click()
                time.sleep(5)
                # close icon
                bot.find_element_by_xpath("//a[@data-tag='cmdCancel']").click()

How I can click these elements inside loop? Thank you!

2
  • 1
    try using a WebDriverWait with expected condition of "ElementToBeVisible". Commented Nov 12, 2019 at 0:30
  • 1
    For sure you can't use the elements reference in your code, check here for more explanation. And have a question, doe the globalize' link disappear for the element once you click on the Cancel` link? Commented Nov 12, 2019 at 1:56

1 Answer 1

0

It seems after click action performed element may be inside scroll down or up window form. following may help you please go through it.

after click action performed add following line.

((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", elem); here, "elem" is web element of your click button.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.