Python中文
首页
教程
问答
标签
搜索
登录
注册
Python Selenium单击按钮,无名称、无id、无文本、多个类和一个标签
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>这是按钮:</p> <pre><code><button _ngcontent-qte-c250="" mat-raised-button="" color="primary" aria-label="Close Welcome Banner" class="mat-focus-indicator close-dialog mat-raised-button mat-button-base mat-primary ng-star-inserted" style=""><span class="mat-button-wrapper"><mat-icon _ngcontent-qte-c250="" role="img" class="mat-icon notranslate material-icons mat-icon-no-color" aria-hidden="true" data-mat-icon-type="font"> visibility_off </mat-icon><span _ngcontent-qte-c250="" fxshow="" fxhide.lt-sm="" translate="">Dismiss</span></span><span matripple="" class="mat-ripple mat-button-ripple"></span><span class="mat-button-focus-overlay"></span></button> </code></pre> <p>我怎么才能点击这个呢? 尝试按照<a href="https://www.javaer101.com/en/article/17998130.html" rel="nofollow noreferrer">this</a>link所说的做,但是Xpath似乎不喜欢使用许多类</p> <p>尝试以下方法后,似乎没有任何效果</p> <pre><code>driver.find_element_by_xpath("//div[@aria-label='Close Welcome Banner']/div[@class='mat-focus-indicator close-dialog mat-raised-button mat-button-base mat-primary ng-start-inserted']"); driver.find_element_by_xpath("//div[@aria-label='Close Welcome Banner']").click() driver.findElement(By.xpath("//span[contains(@class,'middle') and contains(text(), 'Next')]")) </code></pre> <p>有什么建议吗</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>看起来像<code>button</code>标记,而不是<code>div</code></p> <p>试试这个:</p> <pre><code>driver.find_element_by_xpath("//button[@aria-label='Close Welcome Banner']").click() </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
尝试将单元格与pythondocx合并
5 回答
尝试将卡的5个值传递给函数,但不起作用
3 回答
尝试将卷绑定到docker容器
6 回答
尝试将原始queryset转换为queryset时出错
1 回答
尝试将原始输入与函数一起使用
2 回答
尝试将参数传递给函数时,可以通过python中的“@app.route”
5 回答
尝试将变量mid脚本返回到我的模板
3 回答
尝试将变量从一个函数调用到另一个函数
9 回答
尝试将变量传递给一个名称与参数不同的函数是否更好?
2 回答
尝试将变量传递给函数内部的函数。Python
10 回答
尝试将变量作为参数传递
7 回答
尝试将变量作为命令
2 回答
尝试将变量旁边的数据从文本复制到csv时,python获取错误:
2 回答
尝试将变量输入到sql数据库中已创建的行中
5 回答
尝试将只有两个或更多重复元音的单词打印到文本文件中
5 回答
尝试将后缀(字符串)添加到列表中每个WebElement的末尾
9 回答
尝试将命令行输出保存到fi时出错
1 回答
尝试将唯一ASCII文件导入数据帧时出现分析错误
6 回答
尝试将回归程序从stata转换为python
1 回答
尝试将图像上的点投影到二维平面时打开CV通道
1 回答