Python + selenium drop-down list error message: element not interactive

Today is going to make a whole page automation, wrote a drop-down list, run the script to throw the exception: selenium.com mon. Exceptions. ElementNotVisibleException: Message: element not interactable
As shown in the figure below, the script failed to run after using the select_by_index() method. It was found that the code ~~ was not carefully examined. The code was not select-option, but table.
The script is as follows:

driver.find_element_by_xpath("//*[@id=\"style_box\"]/div[1]").click()
#Select(s).select_by_index(3)
driver.find_element_by_xpath("//*[@id=\"style_box\"]/div[2]/div[1]/table/tbody/tr[2]").click()

Very simple two clicks, run after an error selenium.com mon. Exceptions. ElementNotVisibleException: Message: element not interactable
After debugging for several times, it was found that there was no waiting time added. Add time.sleep(3), debug again, and it was successful.
On the one hand, we must analyze the front-end code, on the other hand, when the foot is wrong, especially when it comes to switching, it is better to add a wait time to try ~~
 

 

Read More: