测试积点老人 发表于 2021-9-22 11:32:54

python接管指定端口后,定位元素找不到报错

想写一个简单的上传视频,调用指定端口,跳转链接成功后,找不到元素报错,希望能够给个解决代码方案,源码如下

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
url = "https://cp.kuaishou.com/article/publish/video"
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9918")
driver = webdriver.Chrome(executable_path=r'./chromedriver.exe', options=chrome_options)
driver.get(url)
driver.find_element(By.XPATH,"//span").click()



报错日志如下
```python
Traceback (most recent call last):
File "E:/chengxu1/2.py", line 14, in <module>
    driver.find_element(By.XPATH,"//span").click()
File "E:\Program Files\pythpn\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
    'value': value})['value']
File "E:\Program Files\pythpn\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
File "E:\Program Files\pythpn\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//span"}
(Session info: chrome=78.0.3904.70)


qqq911 发表于 2021-9-23 10:26:36

这是个debug地址啊

海海豚 发表于 2021-9-23 14:17:06

重新定位下元素

jingzizx 发表于 2021-9-23 17:09:35

重新定位
页: [1]
查看完整版本: python接管指定端口后,定位元素找不到报错