I am attempting to access a button element on the consent-page for mail.com.
The URL for the page can be seen here https://www.mail.com/consentpage.
If you have already been to the site, the consent-page can be viewed in a incognito tab.
Sorry I'm not sure if I should post the link or the full html here.
I am trying to access the button with the following tag
<button id="onetrust-accept-btn-handler" tabindex="0">Agree and continue</button>
link: https://ibb.co/R9bFdws
There appear to be multiple iframe posts above the button I tried to access
link: https://ibb.co/cyptbNr
My code thus far:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from time import sleep
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("http:mail.com")
sleep(3)
try:
iframe = driver.find_elements_by_tag_name('iframe')[o]
driver.switch_to.frame(iframe)
button = iframe.find_element_by_id('onetrust-accept-btn-handler')
#driver.switch_to_default_content()
driver.quit()
except:
print('error')
driver.quit()
Getting access to the iframe appears to work, but after that I can not get to the button element.
I have followed the advice of other posting with this question but unfortunately cant seem to get this to work. Thanks for any help!