Python 即使切换到iframe,也无法单击元素

Python 即使切换到iframe,也无法单击元素,python,selenium,iframe,selenium-chromedriver,Python,Selenium,Iframe,Selenium Chromedriver,我无法单击此元素 选择按钮id'onetrust-accept-btn-handler'不起作用,nore执行xpath 我不能只从4个iframe中选择一个,而且它似乎不是正确的一个 这是我目前的代码。我尝试使用javascript单击按钮,但也没有成功 url = 'https://www.gmx.co.uk/' chrome_options = webdriver.ChromeOptions() driver = webdriver.Chrome( executable_path

我无法单击此元素

选择按钮id
'onetrust-accept-btn-handler'
不起作用,nore执行xpath

我不能只从4个iframe中选择一个,而且它似乎不是正确的一个

这是我目前的代码。我尝试使用javascript单击按钮,但也没有成功

url = 'https://www.gmx.co.uk/'

chrome_options = webdriver.ChromeOptions()
driver = webdriver.Chrome(
    executable_path=r'.\chromedriver.exe', options=chrome_options)

driver.get(url)


#this counts the iframes, and even though the output says '1', their are 3 others I selenium interact with.

time.sleep(5)
seq = driver.find_elements_by_tag_name('iframe')
print("Number of frames present in the web page are: ", len(seq))

iframe = WebDriverWait(driver, 5).until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'iframe')))
driver.switch_to.frame(iframe)

element = WebDriverWait(driver, 10).until(expected_conditions.presence_of_element_located((By.XPATH, '/html/body/div/div[3]/div/div/div[2]/div/div/button')))
element.click() 
driver.execute_script("arguments[0].click();", element)
但是,我几乎立即得到一个
selenium.common.exceptions.TimeoutException
,而不是
elementnotinteractiableexception
NoSuchElementException。