__init__() takes 2 positional arguments but 3 were given using WebDriverWait and expected_conditions as element_to_be_clickable with Selenium Python

According to the definition, 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:

class element_to_be_clickable(object):
    """ An Expectation for checking an element is visible and enabled such that you can click it."""
    def __init__(self, locator):
        self.locator = locator

    def __call__(self, driver):
        element = visibility_of_element_located(self.locator)(driver)
        if element and element.is_enabled():
            return element
        else:
            return False

So instead of:

element = WebDriverWait(driver, 1).until(EC.element_to_be_clickable(By.CLASS_NAME, "MuiButton-label"))

You need to (add an extra parentheses):

element = WebDriverWait(driver, 1).until((EC.element_to_be_clickable(By.CLASS_NAME, "MuiButton-label")))

Leave a Comment