selenium使用xpath定位报错

1.使用selenium的xpath定位一直报错,请教一下大家,是什么原因?

查过有一个大佬 写原因是因为没引入BY,但是引入之后仍报错,实在不知道怎么整了,救命~~~~

如下为报错信息

selenium使用xpath定位报错_第1张图片

 下面为定位代码:

#这块是导入的内容

from selenium import webdriver
driver = webdriver.Chrome()
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options

#这部分是定位的部分


#定位输入框 利用xpath   未定位到元素
text_label = driver.find_element(By.XPATH,'//*[@id="app"]/div/div[2]/section/div/form/div[1]/div/div/input')

# 在搜索框中输入点位
text_label.send_keys('点位')


# 定位搜索按钮
button = driver.find_element(By.XPATH,'//*[@id="app"]/div/div[2]/section/div/form/div[4]/div/button[1]')
print(button.get_attribute("outerHTML"))

# 执行单击操作
button.click()

你可能感兴趣的:(selenium,python,测试工具)