繁体   English   中英

如何在下面的树中找到满足条件的元素?

[英]How to find an element that satisfies a condition in the following tree?

使用 Python 和 Selenium 如何找到满足以下树中条件的元素?

(S, A ~ H 是等级)

S
├── A
├── B
├── C
│   └── D
├── E
│   └── F
├── G
└── H

当 D 存在时,我们想要找到 F 的元素。

如果 s 是 webelement 根并且我们想检查该元素中是否存在一个类,我们执行以下操作。

elem=s.find_element_by_xpath("//[class='c']/[class='d']")
if elem:
   s.find_element_by_xpath("//[class='e']/[class='f']")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM