Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon gift card reload fails with unable to locate element error #41

Closed
cy11100 opened this issue Dec 2, 2020 · 0 comments
Closed

Comments

@cy11100
Copy link
Contributor

cy11100 commented Dec 2, 2020

When I ran the code earlier, the script failed with the error:

v2.0.3-dev Windows Traceback (most recent call last):
  File "debbit.py", line 294, in web_automation_wrapper
    result = merchant.web_automation(driver, merchant, amount)
  File "xxx\debbit\src\program_files\merchants\amazon_gift_card_reload.py", line 152, in web_automation
    driver.find_element_by_xpath("//button[starts-with(text(),'Reload') and contains(text(),'" + utils.cents_to_str(amount) + "')]").click()
  File "xxx\src-hO995slM\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 "xxx\src-hO995slM\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "xxx\src-hO995slM\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "xxx\src-hO995slM\lib\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: //button[starts-with(text(),'Reload') and contains(text(),'0.58')]

There may have been some Amazon code change which only updated the final button after the amount field loses focus. The issue was fixed by adding 2 lines to the code before for element in driver.find_elements_by_xpath("//span[contains(text(),'ending in " + merchant.card[-4:] + "')]")::

    driver.find_element_by_id('asv-manual-reload-amount').send_keys(Keys.ENTER)
    time.sleep(1 + random.random() * 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants