无法使用xpath和webdriver打印特定数据
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://datatables.net/")
print driver.findtext('.//*[@id="example"]/tbody/tr[1]/td[1]')
预期结果:
Airi Satou
答案 0 :(得分:1)
尝试此操作以获得所需的输出:
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait as wait
print(wait(driver, 10).until(EC.presence_of_element_located((By.XPATH, '//table[@id="example"]//td'))).text)