Home > Enterprise >  How to extract all <ul> list from html using chromedriver selenium with WebDriverWait?
How to extract all <ul> list from html using chromedriver selenium with WebDriverWait?

Time:06-30

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

. . .
x = (
    WebDriverWait(driver, 120)
    .until(
        EC.presence_of_element_located(
            (
                By.XPATH,
                '//*[@id="root"]/div[2]/div[3]/div/div[6]/div/section[1]/div[2]/ul',
            )
        )
    )
    .find_element(
        by=By.TAG_NAME,
        value="li",
    )
)
print(x)

The output I wanted to extract all list from <ul> tag from html, but the output was <selenium.webdriver.remote.webelement.WebElement (session="2cb650732c8ccc1fbe4eb77febc4a449", element="3556f3cc-216a-49c6-9edf-5d478551cfdc")>.

The list that I want to extract

CodePudding user response:

To get a list instead of single element try to replace

EC.presence_of_element_located

with

EC.presence_of_all_elements_located
  • Related