发布于2021-02-28 16:49 阅读(455) 评论(0) 点赞(24) 收藏(5)
0
1
2
3
4
5
6
7
8
这是我的代码:
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
browser = webdriver.Firefox()
browser.get('https://pbx.voxbaysolutions.com/#/page/signin')
browser.find_element_by_xpath('//input[@ng-model="user.name"]').send_keys('thj')
这是错误:
Traceback (most recent call last):
File "voxbay_automate.py", line 8, in <module>
browser.find_element_by_xpath('//input[@ng-model="user.name"]').send_keys('thj')
File "C:\Users\theju\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webd
river\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\theju\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webd
river\remote\webdriver.py", line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Users\theju\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webd
river\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\theju\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webd
river\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //input[@ng-model="user.name"]
提取元素
<input type="text" name="name" ng-model="user.name" class="form-control ng-pristine ng-invalid ng-invalid-required ng-touched" placeholder="User email" required="" tabindex="0" aria-required="true" aria-invalid="true">
等待网络元素加载,然后发送密钥:
WebDriverWait(browser, 30).until(EC.visibility_of_element_located((By.XPATH, '//input[@ng-model="user.name"]'))).send_keys('thj')
这些进口是必需的:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
0
1
2
3
4
作者:黑洞官方问答小能手
链接: https://www.pythonheidong.com/blog/article/863990/a72598a941b3acf3d208/
来源: python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!