1

How to handle the Accept All button that appears with the page loading.

screenshot

DebanjanB
  • 118,661
  • 30
  • 168
  • 217

2 Answers2

1

To click on Accept All button you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using and XPATH:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='optanon-allow-all accept-cookies-button']"))).click();
    
  • Using and CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.optanon-allow-all.accept-cookies-button"))).click()
    
  • Note : For python clients 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
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217
  • @Md.Mahfuz-Ul-AlamBadhan Great News !!! Please [_accept_](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) the _Answer_ by clicking on the hollow tick mark beside the _Answer_ which have solved your query and _Upvote_ the _Answers_ which were helpful to you for the benefit of the future readers. – DebanjanB Jun 30 '20 at 08:24
0

You can simply click "Accept All" button after page is loading.

Justin Lambert
  • 839
  • 1
  • 7
  • 11