0

So I'm using selenium to navigate through a web page. When I click a button, a modal dialog appears, like a new window. I can find the elements inside it, but when I try to click them, the error presented occurs:

I've seen switch to and iframes, but none of them seems to match my case as there is no other windows nor iframes.

-- driver.find_element_by_id("id-terr-cod").click()

selenium.common.exceptions.ElementNotInteractableException: Message: Element <input id="id-terr-cod" name="check-terr-cod" type="checkbox"> could not be scrolled into view

How do I "scroll into view" in order to be able to do this? I have tried switch_to.alert and it indicates that no alert is present (I've seen in other places that modal dialogs are alert)

Edit: The problem is, is that scroll into view seems to assume you can't "view" the dialog, as I commented on @Prophet though, I can see it. It's the checkbox element on this page when you click "Download" on the bottom https://sidra.ibge.gov.br/tabela/5457

def sidraGet(table_code, variables, panels : dict, years=()):
    driver = webdriver.Firefox()
    driver.get("https://sidra.ibge.gov.br/tabela/"+str(table_code))
    driver.maximize_window()
    time.sleep(10)
    driver.find_element_by_id("botao-downloads").click()
    time.sleep(3)
    terrBox = driver.find_element_by_id("id-terr-cod")
    print(driver.execute_script("arguments[0].scrollIntoView()", terrBox))
    actions = ActionChains(driver)
    actions.move_to_element(terrBox)
    actions.click()
    actions.perform()
Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
  • Does this answer your question? [Scrolling to element using webdriver?](https://stackoverflow.com/questions/41744368/scrolling-to-element-using-webdriver) – Prophet Oct 26 '22 at 07:43
  • 1
    There are a lot of existing answered questions about scrolling to the element. We can't know what exactly will work on your side and what not without minimal debugging details. – Prophet Oct 26 '22 at 07:44
  • @Prophet I suppose so, but I believe it's easy to see from a pratical view atleast https://sidra.ibge.gov.br/tabela/5457 If you look here in this page there's a download button at the end, click it and you'll see the dialog, I want to check one of those boxes, I get the id, but the error I mentioned occurs. Also, I did actions again and now it's giving me "Origin element is not displayed." – Oz_Magician Oct 26 '22 at 10:15
  • 1
    OK, please share here all your selenium code including links to the page you working on (as you mentioned above) and we will try to debug your code and find working solution. – Prophet Oct 26 '22 at 10:19

0 Answers0