pcomputo / Whole-Foods-Delivery-Slot

Automated script for Whole Foods and Amazon Fresh delivery slot
Apache License 2.0
443 stars 152 forks source link

[Win 10] amazon_fresh_delivery_slot_chrome.py Crashes after first reset #23

Closed 901 closed 4 years ago

901 commented 4 years ago
soup = bs4.BeautifulSoup(html)
Traceback (most recent call last):
  File "amazon_fresh_delivery_slot_chrome.py", line 61, in <module>
    getWFSlot('https://www.amazon.com/gp/buy/shipoptionselect/handlers/display.html?hasWorkingJavascript=1')
  File "amazon_fresh_delivery_slot_chrome.py", line 31, in getWFSlot
    no_slots_from_web = driver.find_element_by_xpath('/html/body/div[5]/div/div/div[2]/div/div/form/div[3]/div[4]/div/div[2]/div[2]/div[6]/div/div[2]/div/div[2]/div/div[20]/div[1]/div[1]/div/div/div/span').text
  File "C:\Users\Aditya\Desktop\Whole-Foods-Delivery-Slot-master\Whole-Foods-Delivery-Slot-master\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "C:\Users\Aditya\Desktop\Whole-Foods-Delivery-Slot-master\Whole-Foods-Delivery-Slot-master\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
    'value': value})['value']
  File "C:\Users\Aditya\Desktop\Whole-Foods-Delivery-Slot-master\Whole-Foods-Delivery-Slot-master\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Aditya\Desktop\Whole-Foods-Delivery-Slot-master\Whole-Foods-Delivery-Slot-master\venv\lib\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[5]/div/div/div[2]/div/div/form/div[3]/div[4]/div/div[2]/div[2]/div[6]/div/div[2]/div/div[2]/div/div[20]/div[1]/div[1]/div/div/div/span"}
  (Session info: chrome=81.0.4044.92)

I am able to sign in and go to the Schedule page, but it crashes after the first refresh of the page with the above stacktrace

OS: Windows 10 Browser: Chrome 81 Driver: ChromeDriver 81 URL: Amazon.com/.../

pcomputo commented 4 years ago

It works end to end on my machine, I think what happened in your case, there was a slot that opened up. I was catching the wrong exception. Fixed it. Thanks for pointing out.