Python Automation pull down the box to hide the tag positioning code & error resolution
Python Automation: the select tag style= "display: none;" of the drop-down box positioning method
Error
Selenium.common.exceptions.ElementNotVisibleException: Message: element not visible: Element is not currently visible and may not be manipulated
Interface source code: (Zen Tao as an example)
Troubleshooting:
1) because it is hidden, it needs to be visible before it can be located.
2) if the location still cannot be located, please check whether there is sleep waiting before and after. The efficiency of xpath positioning will be lower.
The''select tag positioning uses index if manipulating hidden elements:; [js is not needed if it is not hidden] js =' document.querySelectorAll ("select") [0] .style.display = "block"; 'driver.execute_script (js)-document.querySelectorAll ("select") selects all select. [0] specify the number of tags in this set of tags. Style.display= "block"; display= "block" of the modified style to indicate visibility. After executing this js code, you can operate the drop-down box normally.'' # index location; Import: from selenium.webdriver.support.select import Selectjs = 'document.querySelectorAll ("select") [2] .style.display = "block";' # [2]: write driver.execute_script (js) project = driver.find_element_by_xpath ("/ / * [@ id='project']") Select (project). Select_by_index (1) # check the option from zero