Python:WebDriverWait按钮不工作
单击“显示更多结果”按钮。我使用了WebDriverWait,因此它允许加载页面,但没有任何用处 html:Python:WebDriverWait按钮不工作,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,单击“显示更多结果”按钮。我使用了WebDriverWait,因此它允许加载页面,但没有任何用处 html: XPath不正确,因为XPath中不允许使用这些谓词class='btn\u list\u more'type='button'。试一试 "//button[@id='more-btn' and @class='btn_list_more' and @type='button']" 谢谢,但是不行。错误:页面未正确加载。再试一次。 from selenium import webdri
XPath不正确,因为XPath中不允许使用这些谓词class='btn\u list\u more'type='button'。试一试
"//button[@id='more-btn' and @class='btn_list_more' and @type='button']"
谢谢,但是不行。错误:页面未正确加载。再试一次。
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
while True:
try:
WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, "//button[@id='more-btn' class='btn_list_more' type='button']")))
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.XPATH, "//button[@id='more-btn' class='btn_list_more' type='button']")))
click=WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[@id='more-btn' class='btn_list_more' type='button']")))
try:
click.click()
except WebDriverException:
print "Page not loaded Correctly. Try again."
break
except (TimeoutException, StaleElementReferenceException, ElementNotVisibleException, NoSuchElementException):
break
"//button[@id='more-btn' and @class='btn_list_more' and @type='button']"