Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Python Automation pull down the box to hide the tag positioning code & error resolution

Shulou Source: shulou.com Published: 2022-06-03 08:08:27 11月23日 Update

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

Tags: Positioning tags drop-down code automation low points elements efficiency methods styles source code interface if yes or select Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Docker macOS MariaDB MySQL