gpt4 book ai didi

python - Selenium 找到元素并点击它

转载 作者:行者123 更新时间:2023-11-28 22:37:42 31 4
gpt4 key购买 nike

我试图让 Selenium 单击 View All Companies 按钮,但我不确定我做错了什么。它返回没有找到元素

html代码

<div class="screener-toggles">
<div class="buttons">
<span class="button selected" data-name="advanced-screener">Search by Screener<span data-name="advanced-screener" class="arrow selected"></span></span>
<span class="button" data-name="alpha-factors">Search by Alpha Factors<span data-name="alpha-factors" class="arrow"></span></span>
<span class="button" data-name="all-companies">View All Companies<span data-name="all-companies" class="arrow"></span></span>
</div>
</div>

我写的python代码

element1 = driver.find_elements_by_class_name('View All Companies')
element1.click()
# I have tried all-companies instead of View All Companies as well. But still doesn't work

我不应该使用 find_elements_by_class_name 吗?

非常感谢任何关于我做错的建议!

最佳答案

尝试 xpath:"//span[contains(text(),'查看所有公司')]"

关于python - Selenium 找到元素并点击它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36262033/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com