如何修复webdriver'对象没有CSS选择器查找元素?
我在沙盒上使用callow。我遇到这些错误:
Traceback (most recent call last):
File "C:\Users\Joe\callow\callow.py", line 163, in <module>
wizard()
File "C:\Users\Joe\callow\callow.py", line 93, in wizard
brutes(username, username_selector, password_selector, submit_selector, pass_list, website)
File "C:\Users\Joe\callow\callow.py", line 119, in brutes
Sel_user = browser.find_element_by_css_selector(username_selector) # Finds Selector
AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector'
错误起源于:
try:
Sel_user = browser.find.element_by_css_selector(username_selector) # Finds Selector
except selenium.common.exceptions.NoSuchElementException:
print((color.RED + '\n[!]'+ color.CWHITE + ' Username feild selector is invalid.'))
sys.stdout.flush()
exit()
try:
Sel_pas = browser.find_element_by_css_selector(password_selector) # Finds Selector
except selenium.common.exceptions.NoSuchElementException:
print((color.RED + '\n[!]'+ color.CWHITE + ' Password feild selector is invalid.'))
sys.stdout.flush()
exit()
try:
enter = browser.find.element_by_css_selector(submit_selector) # Finds Selector
except selenium.common.exceptions.NoSuchElementException:
print((color.RED + '\n[!]'+ color.CWHITE + ' Login button selector is invalid.'))
sys.stdout.flush()
exit()
如何解决此问题?
I am using callow on a sandbox. I get these errors:
Traceback (most recent call last):
File "C:\Users\Joe\callow\callow.py", line 163, in <module>
wizard()
File "C:\Users\Joe\callow\callow.py", line 93, in wizard
brutes(username, username_selector, password_selector, submit_selector, pass_list, website)
File "C:\Users\Joe\callow\callow.py", line 119, in brutes
Sel_user = browser.find_element_by_css_selector(username_selector) # Finds Selector
AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector'
Error originated from:
try:
Sel_user = browser.find.element_by_css_selector(username_selector) # Finds Selector
except selenium.common.exceptions.NoSuchElementException:
print((color.RED + '\n[!]'+ color.CWHITE + ' Username feild selector is invalid.'))
sys.stdout.flush()
exit()
try:
Sel_pas = browser.find_element_by_css_selector(password_selector) # Finds Selector
except selenium.common.exceptions.NoSuchElementException:
print((color.RED + '\n[!]'+ color.CWHITE + ' Password feild selector is invalid.'))
sys.stdout.flush()
exit()
try:
enter = browser.find.element_by_css_selector(submit_selector) # Finds Selector
except selenium.common.exceptions.NoSuchElementException:
print((color.RED + '\n[!]'+ color.CWHITE + ' Login button selector is invalid.'))
sys.stdout.flush()
exit()
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
既然它提到了Webdriver,我假设这与硒有关?
find_element_by_css_selector
已弃用,如果您要使用像Pycharm这样的IDE,它将告诉您:,而不是使用
find_element_by_css_selector
,请使用以下内容:请参阅官方文档以获取更多信息: https://selenium-python.readthedocs.io/locating-elements.html#locating-elements-elements-elements-by-css-selectors 。
Since it mentions WebDriver, I'm assuming this is to do with Selenium?
find_element_by_css_selector
is deprecated, and if you were to use an IDE like PyCharm, it would tell you:So instead of using
find_element_by_css_selector
, consider using:Refer to the official documentation for more information: https://selenium-python.readthedocs.io/locating-elements.html#locating-elements-by-css-selectors.
请不要忘记导入对象以访问CSS_SELECTOR属性。我必须导入以下内容以自动化Chrome浏览器中的任务。
Please don't forget to import the By object to access the CSS_SELECTOR property. I had to import the following to automate tasks in the Chrome browser.