pythontester192 / IG-Bot

Easy Instagram Automation Bot For Beginners
63 stars 26 forks source link

AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector' #1

Open mecrayavcin opened 2 years ago

mecrayavcin commented 2 years ago

Ehen i run it, it gives this error?

`c:\Users\Messi\Desktop\bot\IG-Bot-main\like_cmt_follow.py:18: DeprecationWarning: executable_path has been deprecated, please pass in a Service object browser = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options)

DevTools listening on ws://127.0.0.1:56093/devtools/browser/9082e5e2-ee79-48de-b666-a885c610ca91 Traceback (most recent call last): File "c:\Users\Messi\Desktop\bot\IG-Bot-main\like_cmt_follow.py", line 84, in main() File "c:\Users\Messi\Desktop\bot\IG-Bot-main\like_cmt_follow.py", line 22, in main username_input = browser.find_element_by_css_selector("input[name='username']") AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector' (bot) PS C:\Users\Messi\Desktop\bot>`

How can i fix this? Thanks

pythontester192 commented 2 years ago

Ehen i run it, it gives this error?

`c:\Users\Messi\Desktop\bot\IG-Bot-main\like_cmt_follow.py:18: DeprecationWarning: executable_path has been deprecated, please pass in a Service object browser = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options)

DevTools listening on ws://127.0.0.1:56093/devtools/browser/9082e5e2-ee79-48de-b666-a885c610ca91 Traceback (most recent call last): File "c:\Users\Messi\Desktop\bot\IG-Bot-main\like_cmt_follow.py", line 84, in main() File "c:\Users\Messi\Desktop\bot\IG-Bot-main\like_cmt_follow.py", line 22, in main username_input = browser.find_element_by_css_selector("input[name='username']") AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector' (bot) PS C:\Users\Messi\Desktop\bot>`

How can i fix this? Thanks

----------Try This One-------------

from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager

options = Options() options.add_argument("--lang=en") browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options) browser.get("https://www.instagram.com")

Brodazen commented 2 years ago

Hi, after applying your edit, I get an error: username_input = browser.find_element_by_css_selector("input[name='username']") AttributeError: 'WebDriver' object has no attribute 'find_element_by_css_selector'

will you help an amateur? : D

Brodazen commented 2 years ago

I solved the problem The problem is in the wrong version of selenium. This should help : pip install selenium == 4.2.0 --force-reinstall

vijays4404 commented 2 years ago

pip install selenium == 4.2.0 --force-reinstall

@Brodazen Thank you you solved my problem

Vishalyzd commented 1 year ago

Latest Error in Nov 2022 - COuld You please help?

Type your comment: Looks Great! C:\Users\dell\Desktop\IG-Bot-main\IG-Bot-main\like_cmt_follow.py:47: DeprecationWarning: find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath) instead like_post = browser.find_element_by_xpath("//section[@class= '_aamu _aat0']/span[1]/button") Traceback (most recent call last): File "C:\Users\dell\Desktop\IG-Bot-main\IG-Bot-main\like_cmt_follow.py", line 84, in main() File "C:\Users\dell\Desktop\IG-Bot-main\IG-Bot-main\like_cmt_follow.py", line 47, in main like_post = browser.find_element_by_xpath("//section[@class= '_aamu _aat0']/span[1]/button") File "C:\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 526, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "C:\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 1251, in find_element return self.execute(Command.FIND_ELEMENT, { File "C:\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 430, in execute self.error_handler.check_response(response) File "C:\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//section[@class= '_aamu _aat0']/span[1]/button"}

Vishalyzd commented 1 year ago

Even after using above changes

[12164:14312:1124/015214.518:ERROR:util.cc(129)] Can't create base directory: C:\Program Files\Google\GoogleUpdater C:\Users\dell\Desktop\IG-Bot-main\IG-Bot-main\like_cmt_follow.py:47: DeprecationWarning: find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath) instead like_post = browser.find_element_by_xpath("//section[@class= '_aamu _aat0']/span[1]/button") Traceback (most recent call last): File "C:\Users\dell\Desktop\IG-Bot-main\IG-Bot-main\like_cmt_follow.py", line 84, in main() File "C:\Users\dell\Desktop\IG-Bot-main\IG-Bot-main\like_cmt_follow.py", line 47, in main like_post = browser.find_element_by_xpath("//section[@class= '_aamu _aat0']/span[1]/button") File "C:\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 526, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "C:\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 1251, in find_element return self.execute(Command.FIND_ELEMENT, { File "C:\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 430, in execute self.error_handler.check_response(response) File "C:\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//section[@class= '_aamu _aat0']/span[1]/button"} (Session info: chrome=107.0.5304.107) Stacktrace: Backtrace: Ordinal0 [0x005BACD3+2075859] Ordinal0 [0x0054EE61+1633889] Ordinal0 [0x0044B7BD+571325] Ordinal0 [0x0047AC2F+764975] Ordinal0 [0x0047AE1B+765467] Ordinal0 [0x004AD0F2+970994] Ordinal0 [0x00497364+881508] Ordinal0 [0x004AB56A+963946] Ordinal0 [0x00497136+880950] Ordinal0 [0x0046FEFD+720637] Ordinal0 [0x00470F3F+724799] GetHandleVerifier [0x0086EED2+2769538] GetHandleVerifier [0x00860D95+2711877] GetHandleVerifier [0x0064A03A+521194] GetHandleVerifier [0x00648DA0+516432] Ordinal0 [0x0055682C+1665068] Ordinal0 [0x0055B128+1683752] Ordinal0 [0x0055B215+1683989] Ordinal0 [0x00566484+1729668] BaseThreadInitThunk [0x768FFA29+25] RtlGetAppContainerNamedObjectPath [0x779F7BBE+286] RtlGetAppContainerNamedObjectPath [0x779F7B8E+238]