gpt4 book ai didi

C# Selenium : Click button under iframe

转载 作者:行者123 更新时间:2023-11-30 17:40:20 27 4
gpt4 key购买 nike

我的网站下有一个 iframe 模式。我正在尝试单击按钮 它,但我无法这样做。下面是我的代码。请告诉我 我错过了什么

driver.SwitchTo().Frame(driver.FindElement(By.Id("iframeid='frame_name'"))); 
driver.FindElement(By.Id("sendReuqest")).Click();

预期结果:按钮 id:应该点击 iframe 上的 sendRequest

实际结果: 未找到元素。

如果您有任何问题,请告诉我。

最佳答案

尝试这样做。让我们将 frame_name id 作为 iframe_1。无论您的框架 ID 是什么,您都可以添加而不是 iframe_1。另外你有一个拼写错误(拼写错误)它可能是 sendRequest 所以我添加了你的按钮的 id。

driver.SwitchTo().Frame(driver.FindElement("iframe_1"))); 
driver.FindElement(By.Id("sendRequest")).Click();

希望它有效。请发表评论并让我们知道。

祝你好运。

关于C# Selenium : Click button under iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34422364/

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