jakehilborn / debbit

Automate spending requirements for high interest checking accounts / credit cards
https://jakehilborn.github.io/debbit/
MIT License
261 stars 29 forks source link

Error Message: Unable to locate element #68

Open drkui opened 2 years ago

drkui commented 2 years ago

I'm receiving the following error when trying to run Debbit.

ERROR: 2021-09-18 18:08:52,947 debit_card_amazon_gift_card_reload error: Traceback (most recent call last):
  File "debbit.py", line 294, in web_automation_wrapper
  File "C:\Debbit\program_files\merchants\amazon_gift_card_reload.py", line 160, in web_automation
    driver.find_element_by_xpath("//span[contains(text(),'Continue')]").find_element_by_xpath('../..').click()
  File "selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
  File "selenium\webdriver\remote\webdriver.py", line 976, in find_element
  File "selenium\webdriver\remote\webdriver.py", line 321, in execute
  File "selenium\webdriver\remote\errorhandler.py", line 242, in check_response
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //span[contains(text(),'Continue')]
darkknight7777777 commented 2 years ago

I had a similar error the other day, it looks like the elements noted in the last line are different so I'm not sure if this is the same issue or not.

v2.1.2 Windows Traceback (most recent call last): File "debbit.py", line 294, in web_automation_wrapper File "C:\debbit-v2.1.2-win64\program_files\merchants\amazon_gift_card_reload.py", line 191, in web_automation if driver.find_element_by_id('subtotals-marketplace-spp-bottom').text != expected_order_total: File "selenium\webdriver\remote\webdriver.py", line 360, in find_element_by_id File "selenium\webdriver\remote\webdriver.py", line 976, in find_element File "selenium\webdriver\remote\webdriver.py", line 321, in execute File "selenium\webdriver\remote\errorhandler.py", line 242, in check_response selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [id="subtotals-marketplace-spp-bottom"]

shbach commented 2 years ago

I'm also getting an "Unable to locate element" issue:

v2.1.3-dev Linux Traceback (most recent call last):
  File "/home/shbach/debbit/src/debbit.py", line 294, in web_automation_wrapper
    result = merchant.web_automation(driver, merchant, amount)
  File "/home/shbach/debbit/src/program_files/merchants/amazon_gift_card_reload.py", line 160, in web_automation
    driver.find_element_by_xpath("//span[contains(text(),'Continue')]").find_element_by_xpath('../..').click()
  File "/home/shbach/.local/share/virtualenvs/src-VrT7s6Vy/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "/home/shbach/.local/share/virtualenvs/src-VrT7s6Vy/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "/home/shbach/.local/share/virtualenvs/src-VrT7s6Vy/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/shbach/.local/share/virtualenvs/src-VrT7s6Vy/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //span[contains(text(),'Continue')]

I think it's because the page changed. There is an extra step needed before reaching the continue button. After the "Buy now" button is pressed it takes you to the "Review your order" page. To select the card you would have to press "Payment method Change" and then finally you get to the "Select a payment method" page where there is a continue button.

Edit: I tried this on a different amazon account and if you haven't reloaded a gift card before, after pressing the "Buy now" button it takes you to the "Select a payment method" page (where there is a continue button). However, once you've selected a payment method, any future attempts to reload the gift card will skip directly to the "Review your order" page after pressing "Buy now." Because of this debbit may work on the first run, but any subsequent runs will fail.

jakehilborn commented 2 years ago

Debbit v2.1.3 has been released. I hope this fixes your continue button issue. There have been a few bug fixes so I can't say with 100% certainty. I've enhanced the error reporting emails though so I'll be able to better tell if anything is still broken in v2.1.3.

darkknight7777777 commented 2 years ago

now getting this in cmd on windows:

INFO: 2021-12-15 19:35:54,025 No purchases yet complete for December 2021
INFO: 2021-12-15 19:35:54,025
INFO: 2021-12-15 19:35:54,056 Now bursting 16 legacy bank debit_amazon_gift_card_reload purchases
\\VBoxSvr\shared\debbit\src\debbit.py:509: DeprecationWarning: firefox_profile has been deprecated, please use an Options object
\\VBoxSvr\shared\debbit\src\debbit.py:516: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
\\VBoxSvr\shared\debbit\src\debbit.py:516: DeprecationWarning: firefox_profile has been deprecated, please pass in an Options object
\\VBoxSvr\shared\debbit\src\debbit.py:516: DeprecationWarning: service_log_path has been deprecated, please pass in a Service object
INFO: 2021-12-15 19:36:12,904 Spending 57 cents with legacy bank debit_amazon_gift_card_reload now
ERROR: 2021-12-15 19:37:37,494 legacy bank debit_amazon_gift_card_reload error: Traceback (most recent call last):
  File "\\VBoxSvr\shared\debbit\src\debbit.py", line 294, in web_automation_wrapper
  File "C:\debbit-v2.1.3-win64\program_files\merchants\amazon_gift_card_reload.py", line 165, in web_automation
    driver.find_element_by_xpath("//span[contains(text(),'Continue')]").find_element_by_xpath('../..').click()
  File "selenium\webdriver\remote\webdriver.py", line 520, in find_element_by_xpath
  File "selenium\webdriver\remote\webdriver.py", line 1244, in find_element
  File "selenium\webdriver\remote\webdriver.py", line 424, in execute
  File "selenium\webdriver\remote\errorhandler.py", line 247, in check_response
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //span[contains(text(),'Continue')]
Stacktrace:
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:181:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:393:5
element.find/</<@chrome://remote/content/marionette/element.js:299:16

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ntpath.py", line 647, in realpath
FileNotFoundError: [WinError 53] The network path was not found: '\\\\VBoxSvr\\shared\\debbit\\src\\debbit.py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "\\VBoxSvr\shared\debbit\src\debbit.py", line 294, in web_automation_wrapper
  File "coverage\control.py", line 323, in _should_trace
  File "coverage\inorout.py", line 269, in should_trace
  File "coverage\files.py", line 75, in canonical_filename
  File "coverage\files.py", line 165, in abs_file
  File "ntpath.py", line 651, in realpath
  File "ntpath.py", line 601, in _getfinalpathname_nonstrict
FileNotFoundError: [WinError 53] The network path was not found: '\\\\VBoxSvr\\shared\\debbit\\src\\debbit.py'

Exception in thread Thread-1:
Traceback (most recent call last):
  File "ntpath.py", line 647, in realpath
FileNotFoundError: [WinError 53] The network path was not found: '\\\\VBoxSvr\\shared\\debbit\\src\\debbit.py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "threading.py", line 932, in _bootstrap_inner
  File "threading.py", line 870, in run
  File "\\VBoxSvr\shared\debbit\src\debbit.py", line 113, in burst_loop
  File "\\VBoxSvr\shared\debbit\src\debbit.py", line 307, in web_automation_wrapper
  File "coverage\control.py", line 323, in _should_trace
  File "coverage\inorout.py", line 269, in should_trace
  File "coverage\files.py", line 75, in canonical_filename
  File "coverage\files.py", line 165, in abs_file
  File "ntpath.py", line 651, in realpath
  File "ntpath.py", line 601, in _getfinalpathname_nonstrict
FileNotFoundError: [WinError 53] The network path was not found: '\\\\VBoxSvr\\shared\\debbit\\src\\debbit.py'

Press any key to close this window...
jakehilborn commented 2 years ago

@shbach @darkknight7777777 Can you try replacing the file program_files/merchants/amazon_gift_card_reload.py with the lastest version on the master branch? I've attempted to fix the Unable to locate element: //span[contains(text(),'Continue')] bug but I do not get this workflow on Amazon so I can't verify the fix myself.

@darkknight7777777 Thanks for the most recent bug report. I've fixed the error about The network path was not found: '\\\\VBoxSvr\\shared\\debbit\\src\\debbit.py' so release v2.1.4 won't have it. I will release v2.1.4 once I get this Amazon bug fixed.

jakehilborn commented 2 years ago

@darkknight7777777 I went ahead and fixed the The network path was not found: '\\\\VBoxSvr\\shared\\debbit\\src\\debbit.py' bug and republished v2.1.3. You'll need to download the fixed v2.1.3 build in order to try out the latest amazon_gift_card_reload.py code.

darkknight7777777 commented 2 years ago

back to the original error it looks like:

debbit.py:509: DeprecationWarning: firefox_profile has been deprecated, please use an Options object
debbit.py:516: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
debbit.py:516: DeprecationWarning: firefox_profile has been deprecated, please pass in an Options object
debbit.py:516: DeprecationWarning: service_log_path has been deprecated, please pass in a Service object
INFO: 2021-12-16 09:08:41,420 Spending 57 cents with legacy bank debit_amazon_gift_card_reload now
ERROR: 2021-12-16 09:10:23,093 legacy bank debit_amazon_gift_card_reload error: Traceback (most recent call last):
  File "debbit.py", line 294, in web_automation_wrapper
  File "C:\debbit-v2.1.3-win64\program_files\merchants\amazon_gift_card_reload.py", line 165, in web_automation
    driver.find_element_by_xpath("//span[contains(text(),'Continue')]").find_element_by_xpath('../..').click()
  File "selenium\webdriver\remote\webdriver.py", line 520, in find_element_by_xpath
  File "selenium\webdriver\remote\webdriver.py", line 1244, in find_element
  File "selenium\webdriver\remote\webdriver.py", line 424, in execute
  File "selenium\webdriver\remote\errorhandler.py", line 247, in check_response
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //span[contains(text(),'Continue')]
Stacktrace:
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:181:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:393:5
element.find/</<@chrome://remote/content/marionette/element.js:299:16

debbit.py:594: DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
debbit.py:601: DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
INFO: 2021-12-16 09:10:25,925 1 of 5 legacy bank debit_amazon_gift_card_reload attempts done, trying again in 60 seconds
jakehilborn commented 2 years ago

@darkknight7777777 I didn't include the attempt at the fixed amazon_gift_card_reload code in the v2.1.3 republish. Can you try replacing the file program_files/merchants/amazon_gift_card_reload.py with the lastest version on the master branch? It may fix your issue, or if not it will at least show a new error message that gets me one step closer to the fix.

darkknight7777777 commented 2 years ago

sorry about that, I misread your last comment. It looks like the new file fixes the issue for me. Thanks for the great work on this, it's a huge time saver.

shbach commented 2 years ago

@jakehilborn I tried out the latest version and I didn't get an "Unable to locate element" error so I think this fix is working (but I'm back to getting the error mentioned in issue #72).

jakehilborn commented 2 years ago

@shbach Taking a look