0

I'm trying to click that button, I've tried several ways and I couldn't.

<div class="item" data-id="rota_grupo">
   <i class="fal fa-users">
   </i>
</div>
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

0

You can add your chromedriver path to "DRIVER_PATH" and it should work.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service

CHROMEDRIVER_PATH = Service("DRIVER_PATH")

driver = webdriver.Chrome(service=CHROMEDRIVER_PATH)

button = driver.find_element(By.CLASS_NAME, "fa-users")
button.click()

Abhay S
  • 11
  • 2
0

To locate the clickable element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.item[data-id='rota_grupo'] > i.fal.fa-users"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='item' and @data-id='rota_grupo']/i[@class='fal fa-users']"))).click()
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352