Selenium TypeError: __init__() takes 2 positional arguments but 3 were given

16,417

Change this

WebDriverWait(driver, 10).until(expected_conditions.invisibility_of_element_locate‌​d((By.XPATH, "//input[@id='message']")))

I have added extra () , hope this should work.

Share:
16,417

Related videos on Youtube

Iber
Author by

Iber

Updated on June 04, 2022

Comments

  • Iber
    Iber almost 2 years
    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
    driver = webdriver.Firefox()
    driver.get("http://somelink.com/")
    
    
    WebDriverWait(driver, 10).until(expected_conditions.invisibility_of_element_located(By.XPATH, "//input[@id='message']"))
    # Gives me an error:
    TypeError: __init__() takes 2 positional arguments but 3 were given
    

    ...

    # Simply:
    expected_conditions.invisibility_of_element_located(By.XPATH, "//input[@id='message']"))
    # Gives me the same error.
    TypeError: __init__() takes 2 positional arguments but 3 were given
    

    The error repeats itself whether I use By.XPATH, By.ID or anything else.

    Also, find_element works just fine:

    el = driver.find_element(By.XPATH, "//input[@id='message']")
    print(el) # returns:
    [<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="03cfc338-f668-4fcd-b312-8e4a1cfd9f24", element="c7f76445-08b3-4a4c-9d04-90263a1ef80e")>]
    

    Suggestions appreciated.

    Edit:

    Extra parentheses () around By.XPATH, "//input[@id='message']" as suggested in the comments solved the problem.

    • thebadguy
      thebadguy over 7 years
      change this WebDriverWait(driver, 10).until(expected_conditions.invisibility_of_element_locate‌​d((By.XPATH, "//input[@id='message']"))) I am added extra () , hope this should work
  • JeffC
    JeffC over 7 years
    When you post an answer, please take a minute to properly format it, especially the code portion so that it's readable.
  • psitae
    psitae over 4 years
    why did that work?
  • sunny moon
    sunny moon over 4 years
    @psitae A tuple is expected as the argument, but without extra parentheses By.XPATH, "//input[@id='message']" are just two separate arguments.