问题描述
我无法单击此按钮在我的机器人上创建结帐.我想点击图片获取另一个页面.
I can't click on this button to create a checkout on my bot. I want to click the image to get another page.
这是我的代码:
我收到此错误:
推荐答案
在我的机器人上创建结帐的按钮 似乎是一个 信用卡 相关领域,并且在历史上信用卡相关字段位于<iframe>
中.
The button to create a checkout on my bot seems to be a Credit Card related field and historically Credit Card related fields resides within <iframe>
.
您可以在以下位置找到一些相关讨论:
You can find a couple of relevant discussions in:
- 无法定位使用 selenium python 的信用卡号元素
- org.openqa.selenium.NoSuchElementException:尝试通过 CssSelector 定位 card-fields-iframe 时返回的节点(null)不是 DOM 元素
因此,如果所需的元素在 <iframe>
内,那么您必须:
So if the the desired element is within an <iframe>
so you have to:
- 诱导 WebDriverWait 使所需的框架可用并切换到它.
- 诱导 WebDriverWait 使所需的元素可点击.
您可以使用以下任一解决方案:
- Induce WebDriverWait for the desired frame to be available and switch to it.
- Induce WebDriverWait for the desired element to be clickable.
You can use either of the following solutions:
使用
CSS_SELECTOR
:
使用 XPATH
:
注意:您必须添加以下导入:
Note : You have to add the following imports :
这篇关于NoSuchElementException:消息:尝试通过 Selenium 和 Python 单击 VISA 按钮时无法找到元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!