2

I'm writing a testcase with selenium driver and python,

after clicking a button, one div currently visible (contenetor of the button clicked) gets hidden, and other div previously hidden gets visible that contains some buttons that needs to be clicked to continue the flow

selenium detects as visible the secound div and the elements inside of it, but when I attempt to click a button, the exception is raisen

inside the second div is also a table that contains some checkboxes, i can even print the checkbox element but can't click on it

# Espera hasta que se encuentre visible el panel para selecciona sucursales visibles
        try:
            sucursalsTable = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.ID , 'sucursals-table')))
        except TimeoutException:
            print "Error al intentar seleccionar sucursales visibles"


        tbody = sucursalsTable.find_element_by_tag_name("tbody")
        rows = tbody.find_elements_by_tag_name("tr")  


        for row in rows:
            cells = row.find_elements_by_tag_name("td")
            checbox = cells[0].find_element_by_xpath("(//input[@type='checkbox'])") # la primera columna
            print checbox
            checbox.click()
            pass

after run

Pyhon Code

the HTML

Html Code

id="Sucursals-panel" is the second div

the same exception is raisen when I attempt to click a button inside the second div

I'll be very grateful if someone can give me a hand with this

1 Answers1

1

I was having a similar problem. This button keeps hidden until something goes wrong on the form. So I faked a problem and I could find the button, visually and inside the page code. But when i tryed to click it, using the following code:

driver.find_element_by_class_name('btn_ok_alert').click()

I got the Element Not Interactable Exception... After sweeping the page code for a long time, I found out that were two buttons with the same name, and the first one was still hidden.

The solution i found was use the multiple elements search method that gives you a index for handle it:

elem = driver.find_elements_by_class_name('btn_ok_alert')
elem[1].click()

This happens because the search of the driver begins at the top of the page and will find the button that still hidden (for another purpose) first. And if I meant to click the first one it would be like:

elem[0].click()
Hugo Vares
  • 977
  • 7
  • 7