1

I have been stuck on this issue, where no matter how i write out the navigation to the specific element, using .click() wont work, the element 100% loads in before the click is fired(this i know because i can manually click it), but it wont actually click, is there something about ng-click that needs specification or what, but hopefully i can atleast get some closure as to why this element wont be clicked

<div class="item-card-thumb-container" ng-click="root.onItemCardClick(userAsset)">

is there any possible way to click this element without specifically finding that element and adding .click() to it, because it doesn't seem to work, I understand its too vague, but also maybe the element isn't clickable unless the mouse hovers over the element, cause it is a UI

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

1 Answers1

0

The desired element is a Angular element element, so ideally to click on the 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-card-thumb-container[ng-click^='onItemCardClick']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='item-card-thumb-container' and contains(@ng-click, 'onItemCardClick')]"))).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