Python中文
首页
教程
问答
标签
搜索
登录
注册
通过\u类\u名称查找\u元素\u,当元素明显存在时,返回NoTouchElementException
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在使用Selenium编写一个脚本,该脚本应该定期从Box:<a href="https://osu.app.box.com/v/covid-19publicdata" rel="nofollow noreferrer">https://osu.app.box.com/v/covid-19publicdata</a>下载这个.csv文件,但是我在查找button元素时遇到了问题</p> <p>按钮的HTML代码如下所示:</p> <pre><code><button class="btn tooltip-target tooltip-element-attached-top tooltip-element-attached-center tooltip-target-attached-bottom tooltip-target-attached-center" type="submit" data-resin-item_id="725957383895" data-resin-target="download" tabindex="0"><span class="btn-content"><span>Download</span></span></button> </code></pre> <p>为了找到按钮并单击它,我编写了以下代码(在导入适当的库后运行):</p> <pre><code>driver = webdriver.Chrome('C:/Users/calle/chromedriver') driver.get("https://osu.app.box.com/v/covid-19publicdata") button = driver.find_element_by_class_name("btn tooltip-target tooltip-element-attached-top tooltip-element-attached-center tooltip-target-attached-bottom tooltip-target-attached-center") button.click() </code></pre> <p>然而,尽管我搜索的类名与驱动程序上的类名完全相同,但它在“find element”行上返回NoSuchElementException。我还没有找到任何关于为什么会发生这种情况的信息。我不是一个计算机科学家,所以在这方面的任何帮助都将不胜感激。我也不太喜欢这种特殊的方法,所以如果有更简单的方法,我会洗耳恭听</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>代码的问题是它是一个复合类名,是多个类名。它不适用于类名。有一个更容易使用的选择器</p> <pre><code>button=driver.find_element_by_css_selector("button[data-resin-target='download']") button.click() </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
plt.savefig不会覆盖现有文件
2 回答
plt.savefig不保存图像
6 回答
plt.savefig在jupyter笔记本中不起作用
10 回答
plt.savefig在从另一个fi调用时停止工作
3 回答
plt.savefig在调用plt.show之前保存空数字
9 回答
plt.save不创建png文件
3 回答
plt.scatter overlay分类数据帧列
6 回答
Plt.Scatter:如何添加title、xlabel和ylab
5 回答
plt.scatter()绘图与Matplotlib中的plt.plot()绘图类似
6 回答
plt.scatter错误'NoneType'对象在成功运行后没有属性'sqrt'
7 回答
plt.set_title()中的标题字符串有误
6 回答
plt.show()
7 回答
plt.show()不在Jupyter笔记本上渲染任何内容
3 回答
plt.show()不打印plt.plot only plt.scatter
10 回答
plt.show()不显示三维散射图像
6 回答
plt.show()不显示任何内容
5 回答
plt.show()不显示数据,而是保留它供下一个图表使用(spyder)
1 回答
plt.show()使终端挂起
5 回答
plt.show()无法使用此代码
6 回答
plt.show()没有打开新的图形风
1 回答