-3

When I call the <div> tag and his class value then it does not response.

HTML:

<div id="ccmgt_explicit_accept" class="privacy-prompt-button primary-button ccmgt_accept_button ">
    <span>Accept All</span>
</div> 

Snapshot of the element:

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Post your code, confirm the url you are trying to access, and explain what you are trying to achieve. – Barry the Platipus Sep 02 '22 at 05:36
  • Just i am finding here xpath for selenium
    Accept All
    – user2508281 Sep 02 '22 at 06:10
  • 1
    @user2508281 With the code that you posted in above comment, you may try `driver.find_element(By.ID, 'ccmgt_explicit_accept')`, but I don't think this would help much, for there could be some related HMTL too that may conflict with this code. Hence. more HMTL code if pasted would be better. If possible, share the website link – Anand Gautam Sep 02 '22 at 06:50
  • I'd suggest @AnandGautam's answer, but if you want to use XPath and class attribute try `//div[@class="privacy-prompt-button primary-button ccmgt_accept_button"]`. – Arslan Sohail Bano Sep 02 '22 at 13:25

1 Answers1

-1

To click on Accept All 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#ccmgt_explicit_accept > span"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Accept All']"))).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
  • Hey pal. Could you please help me with these questions? I'm kinda lost: https://stackoverflow.com/questions/73903953/looping-on-selenium-java-depending-on-the-rows-thrown-by-sql-sentence-and-fill/73904563#73904563 and https://stackoverflow.com/questions/73903125/trying-to-pass-values-from-sql-server-table-in-sendkeys-selenium-java-avoi?noredirect=1#comment130499884_73903125 – JustToKnow Sep 30 '22 at 12:31
  • @new_programmer Let's discuss the issue in [Selenium](https://chat.stackoverflow.com/rooms/223360/selenium) room. – undetected Selenium Sep 30 '22 at 14:02
  • Hey pal. You explain very well. Could you please take a look at these questions i sent you? I need to solve it :/ – JustToKnow Sep 30 '22 at 14:26