无法与Selenium找到元素以接受隐私弹出
我正在使用GURU99的Selenium测试一个演示网站(在Firefox上),每当我启动应用程序时,我都会被“管理您的隐私”弹出。我以其他方式解决了该问题,例如在Incognito中设置个人资料或启动浏览器,但我也想通过接受隐私弹出来做到这一点。
我编写了以下代码,以查找使用CSS选择器(或XPATH)的元素,然后单击它,但是我得到一个例外,没有任何具有#save的元素。
WebElement accept = driverFirefox.findElement(By.cssSelector("#save"));
waiter.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector("#save")));
accept.click();
这是 site ,访问它时应该弹出。
还添加屏幕截图弹出并检查工具
为什么它不起作用?我应该重定向到窗口之类的警报吗?我不知道如何,弹出隐私是此页面的一部分。
I am testing a demo site (on firefox) with selenium from guru99 and whenever i start the application i get disrupted by "Manage Your Privacy" pop up. I've solved the issue in other manners like, setting a profile or starting browser in incognito, but i also want to do it by accepting the privacy pop up.
I wrote the following code to find the element with css selector(or xpath) and then click it, but i get an exception that no such element with #save exists.
WebElement accept = driverFirefox.findElement(By.cssSelector("#save"));
waiter.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector("#save")));
accept.click();
This is the site, you should get a pop up when you visit it.
Also adding a screenshot Pop up and inspect tool
Why is it not working? Should i redirect to an alert like window? I dont know how since, privacy pop up is a part of this page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须切换到一个框架。
参见 https://www.guru9999.com/handling-iframes-iframes-iframes-iframes-selenium.html
代码:
输出:
There is a frame you have to switch to.
See https://www.guru99.com/handling-iframes-selenium.html
Code:
Output: