简体   繁体   English

如何使用 selenium python 定位按钮

[英]how to locate button using selenium python

I have tried many ways and seen many posts on Stackoverflow but i cannot find a solution.我尝试了很多方法并在 Stackoverflow 上看到了很多帖子,但我找不到解决方案。 I need to access this button and click it, any ideas?我需要访问此按钮并单击它,有什么想法吗?

<a class="button secondary radius" href="/logout"><i class="icon-2x icon-signout"> Logout</i></a>

如果还有其他按钮的类名相同,你可以试试这种方式

driver.find_element_by_xpath('//input[@href="/logout"]').click();

this button has three classes button secondary and radius .这个按钮有三类button secondaryradius Just use driver.find_elements_by_class_name("name of the class") .只需使用driver.find_elements_by_class_name("name of the class") Insert one of the classes from above but be carefull, the class can only be used onces on the entire page or you might run into issues.从上面插入一个类,但要小心,该类只能在整个页面上使用一次,否则您可能会遇到问题。

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

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