1

I'm trying to to automate clicking on the accept button on the privcy banner on Oracle.com but selenium either cannot find the button or it just does nothing. unfortuntly the banner will always appear so I cannot click it manually for once.

The elemen is only defined by class but not sure what I'm doing wrong

acceptCookies = WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.CLASS_NAME, 'call')))

acceptCookies.click()

also tried


    cookies = driver.find_element(By.CLASS_NAME, 'pdynamicbutton')
    acceptCookies = cookies.find_element(By,CLASS_NAME, "call")
    
    acceptCookies.click()

Here is a screen shot of the dev option on firefox enter image description here

  • Sorry for the formatting, for some reason StackOverflow only accepted this and was rejecting correctly formatted code – lastpokemon Jul 09 '23 at 11:47

1 Answers1

0

The element Accept all within the Oracle Homepage is within an <a> tag.

<a class="call" tabindex="0">Accept all</a>

Solution

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

  • Using LINK_TEXT:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Accept all"))).click()
    
  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.pdynamicbutton a.call"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='pdynamicbutton']//a[@class='call' and 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
  • Unfortunately, none of the three options worked, it looks like selenium is not seeing that pop up at all. the three will fail with exactly the same errors the element cannot be found example of the error: `code` selenium.common.exceptions.TimeoutException: Message: Stacktrace: RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8 WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:187:5 NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:505:5 element.find/<@chrome://remote/content/marionette/element.sys.mjs:135:16 – lastpokemon Jul 11 '23 at 07:21
  • I think that the cookies pop up is just an overlay so I think there should be some method to switch to it, can someone with good experiences try to replicate my situation? – lastpokemon Jul 11 '23 at 08:59
  • Send me the details please. – undetected Selenium Jul 11 '23 at 10:22