How to handle the Accept All button that appears with the page loading.
Asked
Active
Viewed 1,226 times
1

undetected Selenium
- 183,867
- 41
- 278
- 352
-
That would be great you either share the URL or DOM structure. – UnknownBeast Jun 29 '20 at 06:28
2 Answers
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 java and
XPATH
:new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='optanon-allow-all accept-cookies-button']"))).click();
Using python 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

undetected Selenium
- 183,867
- 41
- 278
- 352
0
You can simply click "Accept All" button after page is loading.

Justin Lambert
- 940
- 1
- 7
- 13
-
-
-
use this xpath to click "accept all" button //button[@title='Accept All'] – Justin Lambert Jun 29 '20 at 07:46