chinhtle / reserve-tfl

Script for reserving The French Laundry on Tock
36 stars 31 forks source link

Python Error: Unable to locate element? #13

Open erichweiler opened 2 weeks ago

erichweiler commented 2 weeks ago

I think I have this working with python3 on a Mac. After tweaking the config parameters in the script and making sure the required modules were installed (mostly selenium), the script appears to run (with no actual reservations available, just testing), I see chrome open and close on the Tock website quickly and repeat, but I see this on the command line while running the script:

# ./reserve_tfl.py                                                                                                                                                                                              130 ↵
Looking for availability on month: December, days: ['12', '13', '11'], between times: 4:30 PM and 8:30 PM
Exception in thread Thread-1 (run_reservation):
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/me/reserve-tfl/reserve-tfl/./reserve_tfl.py", line 168, in run_reservation
    r.reserve()
  File "/Users/me/reserve-tfl/reserve-tfl/./reserve_tfl.py", line 98, in reserve
    if not self.search_month():
  File "/Users/me/reserve-tfl/reserve-tfl/./reserve_tfl.py", line 121, in search_month
    span = header.find_element(By.CSS_SELECTOR, "span.H1")
  File "/Users/me/Library/Python/3.10/lib/python/site-packages/selenium/webdriver/remote/webelement.py", line 417, in find_element
    return self._execute(Command.FIND_CHILD_ELEMENT, {"using": by, "value": value})["value"]
  File "/Users/me/Library/Python/3.10/lib/python/site-packages/selenium/webdriver/remote/webelement.py", line 395, in _execute
    return self._parent.execute(command, params)
  File "/Users/me/Library/Python/3.10/lib/python/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/Users/me/Library/Python/3.10/lib/python/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"span.H1"}
  (Session info: chrome=129.0.6668.90); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
0   chromedriver                        0x0000000100e4c248 cxxbridge1$str$ptr + 1907280
1   chromedriver                        0x0000000100e44730 cxxbridge1$str$ptr + 1875768
2   chromedriver                        0x0000000100a58260 cxxbridge1$string$len + 89488
3   chromedriver                        0x0000000100a9c50c cxxbridge1$string$len + 368700
4   chromedriver                        0x0000000100a92ad0 cxxbridge1$string$len + 329216
5   chromedriver                        0x0000000100ad67d0 cxxbridge1$string$len + 606976
6   chromedriver                        0x0000000100a9112c cxxbridge1$string$len + 322652
7   chromedriver                        0x0000000100a91d7c cxxbridge1$string$len + 325804
8   chromedriver                        0x0000000100e144d8 cxxbridge1$str$ptr + 1678560
9   chromedriver                        0x0000000100e18e40 cxxbridge1$str$ptr + 1697352
10  chromedriver                        0x0000000100df95ec cxxbridge1$str$ptr + 1568244
11  chromedriver                        0x0000000100e19710 cxxbridge1$str$ptr + 1699608
12  chromedriver                        0x0000000100deab90 cxxbridge1$str$ptr + 1508248
13  chromedriver                        0x0000000100e35828 cxxbridge1$str$ptr + 1814576
14  chromedriver                        0x0000000100e35980 cxxbridge1$str$ptr + 1814920
15  chromedriver                        0x0000000100e443d0 cxxbridge1$str$ptr + 1874904
16  libsystem_pthread.dylib             0x0000000180cf5f94 _pthread_start + 136
17  libsystem_pthread.dylib             0x0000000180cf0d34 thread_start + 8

Looking for availability on month: December, days: ['12', '13', '11'], between times: 4:30 PM and 8:30 PM
^CTraceback (most recent call last):
  File "/Users/me/reserve-tfl/reserve-tfl/./reserve_tfl.py", line 189, in <module>
    continuous_reservations()
  File "/Users/me/reserve-tfl/reserve-tfl/./reserve_tfl.py", line 186, in continuous_reservations
    execute_reservations()
  File "/Users/me/reserve-tfl/reserve-tfl/./reserve_tfl.py", line 181, in execute_reservations
    t.join()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1096, in join
    self._wait_for_tstate_lock()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1116, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):

It then continues to re-open and click through the Tock website, as expected. Is that error non-fatal? Like, can I ignore it, or might it actually mess up my efforts when I try to use this for real?

Thanks for writing this, it looks amazing!

pedrowill-dev commented 1 week ago

share image about element with devtools open, please!