TA的每日心情 无聊 昨天 09:47
签到天数: 528 天
连续签到: 1 天
[LV.9]测试副司令
1 测试积点
想写一个简单的上传视频,调用指定端口,跳转链接成功后,找不到元素报错,希望能够给个解决代码方案,源码如下
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[text()='上传视频']").click()
报错日志如下
```python
Traceback (most recent call last):
File "E:/chengxu1/2.py", line 14, in <module>
driver.find_element(By.XPATH,"//span[text()='上传视频']").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[text()='上传视频']"}
(Session info: chrome=78.0.3904.70)
复制代码
我来回答