gpt4 book ai didi

javascript - Selenium 处理 HTML 弹出窗口

转载 作者:行者123 更新时间:2023-11-28 03:52:45 26 4
gpt4 key购买 nike

<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.

我想点击按钮,但我无法点击。我尝试了很多代码,但我不能:(我停下来等待这段代码。请帮助我。

最后我点击: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 内。

关于javascript - Selenium 处理 HTML 弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47837616/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com