我想按类名称选择元素,但只能使用特定名称(first-level-li)
,如果还有其他类具有我尝试选择的名称,但关注其他名称
(<li class="first-level-li no-second-level shop-link">
<li class="first-level-li no-second-level ">)
,我需要忽略它们,我该怎么做? 示例:
firstLevelMenu = self.driver.find_elements_by_class_name ( "first-level-li" )
网站
<li class="first-level-li no-second-level shop-link">
<li class="first-level-li no-second-level ">
<li class="first-level-li ">
最佳答案
firstlevelMenu = self.driver.find_elements_by_xpath("//li[@class='first-level-li ']")
文档在这里 http://selenium-python.readthedocs.io/locating-elements.html
关于python - 按特定类名称选择元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46908136/