简体   繁体   English

查找元素的 XPath

[英]Find XPath of element

How do I find the XPath for the hamburger navigation icon (3 white lines) at https://freerice.com/game in the upper left corner?如何在左上角的https://freerice.com/game找到汉堡包导航图标(3 条白线)的 XPath? I am writing a Python program with selenium and would like it to click this button.我正在用 selenium 编写一个 Python 程序,并希望它点击这个按钮。

I've used it so far:到目前为止我已经使用过它:

b = driver.find_element_by_xpath('//*[@id="Path_7605"]')
b.click

This bit of code should do it:这段代码应该这样做:

driver.find_element_by_xpath("/html/body/div[2]/div/header/div[2]/a/span").click()

You can just use find_element_by_xpath and paste in the xpath of whatever element you want to target.您可以只使用find_element_by_xpath并粘贴您想要定位的任何元素的 xpath。

尝试这个:

driver.find_element_by_xpath("//*[@class='toolbar__menu-toggle-icon']").click();

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

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