woziji94520
2021-09-21 17:13
采纳率: 0%
浏览 26

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

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

img

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)

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • CSDN专家-Time 2021-09-21 17:29

    NoSuchElementException: Message: no such element: Unable to locate element
    你仔细检查一下你的页面是否有这个元素。

    打赏 评论

相关推荐 更多相似问题