51Testing软件测试论坛
标题:
python接管指定端口后,定位元素找不到报错
[打印本页]
作者:
测试积点老人
时间:
2021-9-22 11:32
标题:
python接管指定端口后,定位元素找不到报错
想写一个简单的上传视频,调用指定端口,跳转链接成功后,找不到元素报错,希望能够给个解决代码方案,源码如下
[attach]134518[/attach]
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)
复制代码
作者:
qqq911
时间:
2021-9-23 10:26
这是个debug地址啊
作者:
海海豚
时间:
2021-9-23 14:17
重新定位下元素
作者:
jingzizx
时间:
2021-9-23 17:09
重新定位
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2