我正在使用一个名为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()
我怎么才能解决这个问题?
发布于 2022-07-02 05:19:08
因为它提到了WebDriver,所以我假设这与Selenium?find_element_by_css_selector
无关,如果要使用像PyCharm这样的IDE,它会告诉您:
find_element_by_css_selector不受欢迎。请改用find_element(by=By.CSS_SELECTOR,value=css_selector)
因此,与其使用find_element_by_css_selector
,不如考虑使用:
Sel_user = browser.findElement(By.cssSelector, username_selector)
有关更多信息,请参阅正式文档:https://selenium-python.readthedocs.io/locating-elements.html#locating-elements-by-css-selectors。
https://stackoverflow.com/questions/72836613
复制相似问题