TypeError Traceback most recent call lastInput In 2 in cell line 63 61 ul=WebDriverWaitdriver10005untilECpresence_of_element_locatedByXPATHhtmlbodydiv60div1divdivdi
The error message 'WebElement' object is not iterable suggests that you are trying to iterate over a single WebElement instead of a list of WebElements.
In your code, you are using WebDriverWait.until() to wait for the presence of a specific element, and then using list() to convert it into a list. However, the WebDriverWait.until() method returns a single WebElement, not a list.
To fix this error, you can directly access the desired elements using appropriate methods provided by the Selenium WebDriver. For example, you can use find_elements() method to find all the desired elements under the 'ul' element.
Here's an updated code snippet:
ul = WebDriverWait(driver, 100, 0.5).until(EC.presence_of_element_located((By.XPATH,'/html/body/div[60]/div[1]/div/div/div[1]/div[2]/div[2]/div/div[2]/div/div/div/ul/li[2]/ul/li/ul')))
li_list = ul.find_elements(By.XPATH, 'li')
print(li_list)
print(type(li_list))
This code will find all the 'li' elements under the 'ul' element and store them in the li_list variable
原文地址: http://www.cveoy.top/t/topic/h73s 著作权归作者所有。请勿转载和采集!