EddieXu123 / Amazon-Bot

Done! Bot that signs into your Amazon account and buys your groceries, which you can enter in the code!
28 stars 11 forks source link

Unable to locate elements #1

Open Jamiex64 opened 3 years ago

Jamiex64 commented 3 years ago

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[1]/header/div/div[1]/div[2]/div/a[2]/span[1]"} (Session info: chrome=87.0.4280.88)

k3vl4r7 commented 3 years ago

same.

`Kevins-iMac:Amazon-Bot k3vl4r$ python3 amazon_bot.py

[WDM] - ====== WebDriver manager ====== [WDM] - Current google-chrome version is 89.0.4389 [WDM] - Get LATEST driver version for 89.0.4389 [WDM] - There is no [mac64] chromedriver for browser 89.0.4389 in cache [WDM] - Get LATEST driver version for 89.0.4389 [WDM] - Trying to download new driver from https://chromedriver.storage.googleapis.com/89.0.4389.23/chromedriver_mac64.zip [WDM] - Driver has been saved in cache [/Users/k3vl4r/.wdm/drivers/chromedriver/mac64/89.0.4389.23] Traceback (most recent call last): File "amazon_bot.py", line 143, in bot.log_on() File "amazon_bot.py", line 49, in log_on self.driver.find_element_by_xpath('/html/body/div[1]/header/div/div[1]/div[2]/div/a[2]/span[1]').click() File "/Library/Python/3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/Library/Python/3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { File "/Library/Python/3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/Library/Python/3.8/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":"/html/body/div[1]/header/div/div[1]/div[2]/div/a[2]/span[1]"} (Session info: chrome=89.0.4389.90)`

EddieXu123 commented 3 years ago

Hey thx for raising these concerns! The elements that are chosen were just the xpath of these elements on the web browser itself (you can replace these by right clicking the element you want the bot to select, click "inspect" and copy the xpath of the element in the inspect panel). Check out the following tutorial, which goes over how this works with Selenium!

https://www.youtube.com/watch?v=lvFAuUcowT4

barkely128 commented 3 years ago

I'll try to be useful:

Proceed to checkout

    self.driver.find_element_by_xpath(

And here's a newline. Probably why it doesn't work for other folks. Line 51 I believe.