webdriver根据XPath相对路径获取元素

webdriver根据XPath相对路径获取元素

#encoding = utf-8
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()

#打开百度首页
driver.get("https://passport.meituan.com/account/unitivelogin?")
#根据相对路径获取元素
driver.find_element(by=By.XPATH,value="/html/body/div[5]/div/div[2]/form[1]/div[2]/input[2]").send_keys("134")
#暂停6秒
time.sleep(6)

  

posted @ 2023-06-23 10:07  冬天tao  阅读(47)  评论(0编辑  收藏  举报