python - 蟒蛇,硒。如何按样式或 xpath 编号查找元素?
问题描述
<html>
<body>
<pre style="example" xpath="1">
"amount": 12{
"value" : 3
},
</pre>
</body>
</html>
这是给定的。我将如何定位价值?
我在想这样的事情:
driver.find_element_by_xpath("//style='example'")
先感谢您!
解决方案
在这种情况下,您需要使用整个 xpath:
driver.find_element_by_xpath("/html[1]/body[1]/pre[1]")
推荐阅读
- java - 将控制台日志 Temp 分配到一个十元素数组中
- ios - Swift App - 在范围内找不到“SKStoreProductViewController”
- python - python spacy 分句器
- etl - 有没有办法为 Prefect 中的新 Flow 回填历史数据(一次)?
- sql - 在 oracle db 中共享表的替代方案
- python - 将模型预测保存在具有不同名称的 for 循环中
- javascript - 使用 node 和 ffmpeg 将编程创建的视频流式传输到 youtube
- sql - 基于列优先级的 MSSQL 查询
- ruby - 使用 xcode 命令行工具 12 的 ruby 版本 1.9.3、2.2.0、2.2.5 的 rbenv / ruby-build 安装失败
- c# - 基于 Swagger 模型从 SQL 创建 JSON