TypeError exception was thrown here: init() takes 2 positional arguments but 3 were given using explicit wait through Selenium and Python

Viewed 119

I copied a snippet from the selenium python documentation. Of course I typed it by hand to verify if it is out of date against Python 3.8.6 which python version I am using. Fortunately not out-of-date. but a TypeError exception was thrown here: init() takes 2 positional arguments but 3 were given

my snippet as below:(error occurs at the last row)

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

driver = webdriver.Firefox()
driver.get("https://www.liaoxuefeng.com/wiki/1016959663602400/1017602696742912")

wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable(By.ID, 'brand'))
1 Answers

element_to_be_clickable() should be called within a tuple as it is not a function but a class, where the initializer expects just 1 argument beyond the implicit self. Effectively, your code will be:

wait = WebDriverWait(driver, 10)
element = wait.until((EC.element_to_be_clickable(By.ID, 'brand'))

Reference

You can find a couple of relevant detailed discussions in:

Related