Индуцируйте WebDriverWait
и presence_of_all_elements_located
() или visibility_of_all_elements_located
() и используйте ниже xpath
. Попробуйте ele.text
или ele.get_attribute('textContent')
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
elements=WebDriverWait(driver,20).until(EC.presence_of_all_elements_located((By.XPATH,"//div[@class='table_road_set'][starts-with(@id,'tableID')]")))
for ele in elements:
print(ele.text)
print(ele.get_attribute('textContent'))
ИЛИ
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
elements=WebDriverWait(driver,20).until(EC.visibility_of_all_elements_located((By.XPATH,"//div[@class='table_road_set'][starts-with(@id,'tableID')]")))
for ele in elements:
print(ele.text)
print(ele.get_attribute('textContent'))
Вы также можете использовать следующий Css Selector.
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
elements=WebDriverWait(driver,20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR,"div.table_road_set[id^='tableID']")))
for ele in elements:
print(ele.text)
print(ele.get_attribute('textContent'))