0

I want to click this element but I don't know how to find it. This is the HTML code :

<div class="qF0y9  Igw0E     IwRSH      eGOV_         _4EzTm    " style="height: 30px;">
   <span class="FLeXg bqE32">
      <span class="vBF20 _1OSdk">
         <button class="_5f5mN       jIbKX  _6VtSN     yZn4P   ">Follow</button>
      </span>
      <span class="mLCHD _1OSdk">
         <button class="_5f5mN       jIbKX KUBKM      yZn4P   ">
            <div class="            qF0y9          Igw0E   rBNOH          YBx95       _4EzTm                                                                                zQLcH            XTCZH                  ">
               <span style="display: inline-block; transform: rotate(180deg);">
                  <svg aria-label="Down Chevron Icon" class="_8-yf5 " color="#ffffff" fill="#ffffff" height="12" role="img" viewBox="0 0 48 48" width="12">
                     <path d="M40 33.5c-.4 0-.8-.1-1.1-.4L24 18.1l-14.9 15c-.6.6-1.5.6-2.1 0s-.6-1.5 0-2.1l16-16c.6-.6 1.5-.6 2.1 0l16 16c.6.6.6 1.5 0 2.1-.3.3-.7.4-1.1.4z"></path>
                  </svg>
               </span>
            </div>
         </button>
      </span>
   </span>
</div>

I tried to find it using XPATH/CLASSNAME/CSS selector but did not pass anyway.

Can someone help me?

Nitin Sahu
  • 611
  • 6
  • 12

1 Answers1

0

To click on the element with text as Follow you can use either of the following Locator Strategies:

  • Using xpath:

    driver.find_element(By.XPATH, "//button[text()='Follow']").click()
    

The desired element is a dynamic 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 XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Follow']"))).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