TypeError: element_to_be_clickable() takes 1 positional argument but 2 were given当我运行以下代码时出现错误:
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
url = 'https://www.expedia.co.uk/'
s = Service(ChromeDriverManager().install())
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
driver = webdriver.Chrome(service=s, options=chrome_options)
driver.get(url)
elem = WebDriverWait(driver, 10).until(EC.element_to_be_clickable(By.CSS_SELECTOR, "#add-flight-switch"))
elem.click()
elem1 = driver.find_element(By.XPATH, "button[aria-label='Leaving from']").text
driver.quit()
Run Code Online (Sandbox Code Playgroud)
我可以看到函数中确实有两个参数elements_to_be_clickable(),但是该By.CSS_SELECTOR部分不需要通过特定的选择器类型(在本例中为 CSS)来查找吗?
我正在使用选择器中心来获取 CSS_SELECTOR 信息。
非常感谢任何有关如何解决的支持。