|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.chrome.options import Options
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.chrome.service import service
- import time
- from selenium.webdriver.support import expected_conditions as ec
- opt = Options()
- #opt.add_argument('--headless')
- opt.add_experimental_option('excludeSwitches',['enable-automation'])
- driver = webdriver.Chrome(options=opt)
- driver.get('https://bancang.cn/')
- time.sleep(3)
- driver.find_element(By.XPATH,"//taro-text-core[@class='hydrated']").click()
复制代码
我想点击网页中的“我的”,我这样写运行无效,为什么
我测试没问题
- drv=wd.Chrome()
- drv.maximize_window()
- url="https://bancang.cn/"
- drv.get(url)
- time.sleep(1)
- zdgl=drv.find_element(By.XPATH,"//*[@id='/pages/index/index']/taro-view-core/taro-view-core[5]/taro-view-core[2]/taro-view-core[3]")
- zdgl.click()
复制代码
两个原因,要么就是你的元素还没有渲染时 你进行了点击操作(此时适当的sleep一下,或者还有一个直到xxx元素出现才做xxx的一个方法)
要么就是你的xpath 是错误的
|
-
|