python - 如何在webelement中迭代标签?
问题描述
我有这样的html页面:
<div>
<h3>..</h3>
<p>..<a>..</a>..</p>
<p>..</p>
<h4>..</h4>
</div>
我收到了包含 div 标签的 webelement。在此之后我想在里面迭代标签
h3, p, p, h4
(我不知道页面中到底有哪些标签)
我怎样才能做到这一点?
我试过了:
driver.find_elements_by_tag_name(but there I need specify tag)
解决方案
items = conteiner.find_elements_by_xpath("""/div/*""")
for item in items:
print(item.tag_name)
print(item.get_attribute('innerHTML'))
推荐阅读
- android - 在 `runBlockingTest` 中测试 Room 的事务查询
- asp.net-core - ASP.NET Core - Entity Framework Core:发布类型化表单时的访问关系
- ios - 如何将 iOS 应用程序中的旧项目设置保留或转移到全新项目?
- java - 硒。如果事先不知道选择器,如何关闭弹出窗口?
- ios - 如何使用 Alamofire 快速发布请求 json 正文?
- f# - 如何让 SQLProvier 在 dotnet core 3.1 MySQL(实际上是 MariaDB)上工作?
- xamarin - 如何从 Xamarin 中的 SQLite 数据库中删除数据
- javascript - 字符串:使用切片查找段
- ruby-on-rails - pg_search gem 返回重复项
- haskell - (->) r 的 MonadReader 实例的用例是什么