我正在寻找自动点击这个页面,我正在使用它作为一个测试,因为我正在学习Selenium。在
https://www.pgatour.com/competition/2019/safeway-open/leaderboard.html
我无法让我的代码在加载页面时自动接受并关闭cookies覆盖,这使我无法继续。在
我尝试了各种方法来识别元素,但每次都收到相同的消息。在
我相信这就是我需要标识的元素的HTML:
<a class="call" tabindex="0" role="button">Agree and Proceed</a>
我的代码的最新版本是:
^{pr2}$错误消息是:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//a[@class = 'call']"}
在要测试的URL中,位于iframe中的cookie。要在这个iframe中单击某个东西,首先必须找到iframe。然后你必须切换到iframe。之后,您可以返回到默认页面。在
然后找到你的元素(同意并继续),然后点击它。在
然后:
^{pr2}$有一个标题为
TrustArc Cookie Consent Manager
的iframe。您需要先切换到iframe才能访问元素。在诱导}
诱导}
WebDriverWait
和{WebDriverWait
和{浏览器快照:![enter image description here](https://i.stack.imgur.com/iJyMx.png)
要关闭按钮,请在此之后添加此代码。在
^{pr2}$隐藏cookie横幅的最简单方法是为了符合gdrp。当您接受cookie模式时,它会为您的系统在浏览器上编写一个cookie。在
像![enter image description here](https://i.stack.imgur.com/Z3pQj.png)
你也可以做同样的事。打开浏览器后,编写此cookie并重新加载浏览器。那么cookie模式将不会在功能中打开。在
我对python cookie不太了解写。你可以按照本教程编写cookie
https://chercher.tech/python/python-selenium-cookies
Python create cookies and then load a page with the cookies
相关问题 更多 >
编程相关推荐