0

I saw similar questions but in my case there is not even "init" function in my code. How to solve this problem? The problem is with line (EC.element_to_bo_clickable)

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.Chrome(executable_path="C:\Chromedriver\chromedriver.exe")
driver.implicitly_wait(1)
driver.get("https://cct-103.firebaseapp.com/")

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

element.click()
undetected Selenium
  • 151,581
  • 34
  • 225
  • 281
Virtual107
  • 35
  • 5

3 Answers3

4

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")))
JeffC
  • 19,228
  • 5
  • 29
  • 49
undetected Selenium
  • 151,581
  • 34
  • 225
  • 281
1

You are missing: (), in this argument: ((By.CLASS_NAME, "MuiButton-label")).

Try the bellow code:

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.Chrome(executable_path="C:\Chromedriver\chromedriver.exe")
driver.get("https://cct-103.firebaseapp.com/")

element = WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.CLASS_NAME, "MuiButton-label")))
element.click()
frianH
  • 6,710
  • 6
  • 17
  • 42
0

element_to_be_clickable() calls internally to visibility_of_element_located

def __call__(self, driver):
    element = visibility_of_element_located(self.locator)(driver)

Which call _find_element

def __call__(self, driver):
    try:
        return _element_if_visible(_find_element(driver, self.locator))

Which in turn call to find_element(self, by=By.ID, value=None) in webdriver.py

def _find_element(driver, by):
    try:
        return driver.find_element(*by)

This means you need to send a tuple as parameter

element = WebDriverWait(driver, 1).until(EC.element_to_be_clickable((By.CLASS_NAME, "MuiButton-label")))
Guy
  • 40,130
  • 10
  • 33
  • 74