Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在下面的树中找到满足条件的元素?_Python_Selenium_Class - Fatal编程技术网

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

Python 如何在下面的树中找到满足条件的元素?,python,selenium,class,Python,Selenium,Class,使用Python和Selenium如何在下面的树中找到满足条件的元素 (S,A~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']") 是|

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

(S,A~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']")

是|还是在这种情况下?
elem=s.find_element_by_xpath("//[class='c']/[class='d']")
if elem:
   s.find_element_by_xpath("//[class='e']/[class='f']")