Selenium 处理 HTML 弹出窗口

Selenium Handling a HTML Popup

<iframe src="https://authedmine.com/authenticate.html?key=tqao2dYaXfMVJuUNUIwh6OBUUGSW3omn&amp;domain=mining.freebitco.in&amp;theme=light&amp;lang=auto" style="border: none; width: 380px; height: 412px; max-width: 100%; max-height: 100%; position: absolute; overflow: auto; left: 0px; right: 0px; top: 0px; bottom: 0px; margin: auto;"></iframe> 


<body class="light">
<div id="content" style="display: block;">
<a id="set-english-locale" href="#" style="display: block;">English</a>
<h1 id="head">xx</h1>
<p id="body">yy.</p>
<p class="warn" id="batteryWarning">Not:cc.</p>

<div class="actions">
    <button class="allow" id="accept">Bu oturum için izin ver</button> --Need click this--
    <button class="cancel" id="cancel">İptal</button>
</div>

<p class="foot">
    powered by
    <a href="asdadad.com" class="icon">
        coinhive
    </a>
    – 
    <a href="https://coinhive.com/info/opt-in" target="_blank">more info</a>
</p>

我遇到了这个错误;

An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll Additional information: The HTTP request to the remote WebDriver server for URL http://localhost:57885/session/233d4589882afe49d8dd64d1f9318ac0/element timed out after 60 seconds.

我想点击按钮,但我不能点击..我尝试了很多代码,但我不能:(我为此停止了code.Please帮助我。

最后我点击:D 非常感谢@DebanjanB

driver.SwitchTo().Frame(driver.FindElement(By.XPath("/html/body/div[2]/iframe")));
        driver.FindElement(By.XPath("//*[@id='accept']")).Click();
        driver.SwitchTo().DefaultContent();

尝试:

driver.FindElement(By.XPath("//div[@class='actions']/button[@class='allow']").Click();

更新:

正如您看到的 timeout 异常检查元素是否在 iframe.