2

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'))
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
sampan0423
  • 89
  • 6
  • 2
    It's supposed to be `EC.element_to_be_clickable((By.ID, 'brand'))`, as shown in the [docs](https://selenium-python.readthedocs.io/waits.html). – Reti43 Jan 13 '21 at 14:57
  • yes,you're right. I think the brackets are too many, so I deleted it. Because the documentation haven't acclaimed clearly as DebanjanB said below. Anyway, I'll double check the documentation. – sampan0423 Jan 14 '21 at 14:26

1 Answers1

0

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:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352