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

"Reload" button now says "Buy Now" #63

Closed bjhiltbrand closed 2 years ago

bjhiltbrand commented 2 years ago

Looks like Amazon has changed the "Reload" button to a "Buy Now" text. This renders the current xpath locator invalid.

bjhiltbrand commented 2 years ago

Actually, as I look at the script, I think the flow has changed on Amazon's side. The original locator is still in the DOM, but it's not clickable. Not only that, but it looks like once you fill in an amount and click buy now, it takes you to a full checkout page, that doesn't resemble what the script is looking for anymore.

jakehilborn commented 2 years ago

I've gotten a few reports for this issue so you certainly aren't the only one getting A/B tested with a new page. I have some time next week to look into this so I'll get a new version of debbit released that handles the new website changes.

Chief-One commented 2 years ago

@jakehilborn Ran into the same issue. Just the other day I was praising how well Debbit is working with Amazon and now they have changed it up to break the functionality.

jamesgol commented 2 years ago

This is the same as #59, started happening to me again a few days ago.

darkknight7777777 commented 2 years ago

Just started having this issue this month.

jakehilborn commented 2 years ago

The latest code on the master branch fixes this issue. I need to get the new version built and uploaded though. If you want to try this out before release v2.1.1 is out then replace the file program_files/merchants/amazon_gift_card_reload.py with the latest copy of the same file. If you're running from source you can just pull the latest code.

jamesgol commented 2 years ago

I just updated and it looks like it's working. Thanks!

Chief-One commented 2 years ago

Running from source, replaced the file and its getting following error "essage: Unable to locate element:[id="orderSummaryPrimaryActionBtn"]"

jakehilborn commented 2 years ago

@Chief-One Bummer, I was going to push out a new release tonight but I should fix that. Can you that error report to me by either following these instructions or zipping up your failures folder and emailing it to jakehilborn@gmail.com?

Chief-One commented 2 years ago

@jakehilborn I have attached the zipped-up failures folder. Redacted personal info but tags and all remaining info should be there. Looks like they are naming the button something else. failures.zip

bjhiltbrand commented 2 years ago

For what it's worth, the changes made recently worked for me. My checkout page shows a button that says "Use this payment method", whereas yours says "continue" I would venture to guess that since this is the button that the script is failing to locate, that the id is different. Do you know how to find locators (xpath, css, etc.) for an element on a webpage? If so, could you take a screenshot of that page and what the locators are?

bjhiltbrand commented 2 years ago

Scratch that, turns out the script saves an html version of the page at failure. That's handy.

It looks like a slightly different flow for your scenario - one where you simply choose a card that was previously saved, without having to click a button saying to specifically use that card...

bjhiltbrand commented 2 years ago

Side note, @jakehilborn, I don't think you need the for loop on line 144. You could try this xpath and see if it gives you what you're after:

//span[contains(@class, 'pmts-cc-number') and contains(text(),'ending in " + merchant.card[-4:] + "')]/ancestor::div[contains(@class,'pmts-instrument-box')]/descendant::input[@type='radio']

Disclaimer: I have not tried that locator in a test run yet.

jakehilborn commented 2 years ago

@Chief-One Could you try the amazon script from this feature branch? If anything, it should get one step closer to fully functional. There may be 1 or 2 more buttons to fix. It looks like your checkout cart is different than others I've seen.

https://github.com/jakehilborn/debbit/blob/secondary_amazon_checkout/src/program_files/merchants/amazon_gift_card_reload.py

Chief-One commented 2 years ago

@jakehilborn Didn't work, the script is looking for a button with ID "continue", not sure if one exists with that

failures.zip

Chief-One commented 2 years ago

Looks like its named "ppw-widgetEvent:SetPaymentPlanSelectContinueEvent" and there are two tags with that name so if you are modifying it to grab it by name then need to index it as well from the list

jakehilborn commented 2 years ago

@Chief-One My bad, I read the stack trace wrong. I just fixed a different wait condition, so now it should at least get a bit further. I pushed the latest code to the feature branch so that hyperlink above should have the latest fix. The good part is that the error reports contain the html file. It allows me to open that html file with debbit and poke around the DOM using selenium with a debugger.

Chief-One commented 2 years ago

@jakehilborn

: # Find Continue text, the grandparent element of the text is the clickable Continue button driver.find_element_by_xpath("//span[contains(text(),'Continue')]").find_element_by_xpath('../..').click()

Should be sibling to parent and not grandparent

Screen Shot 2021-08-26 at 11 32 31 PM

``

Chief-One commented 2 years ago

@jakehilborn - Tried the latest one and moved further but complaining about "ap_password"

File "/Users/**/Library/Mobile Documents/com~apple~CloudDocs/Development/Debbit/src/debbit.py", line 294, in web_automation_wrapper result = merchant.web_automation(driver, merchant, amount) File "/Users/**/Library/Mobile Documents/com~apple~CloudDocs/Development/Debbit/src/program_files/merchants/amazon_gift_card_reload.py", line 58, in web_automation driver.find_element_by_id('ap_password').send_keys(merchant.psw) File "/Users/**/.local/share/virtualenvs/src-nhT6G4Bk/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 360, in find_element_by_id return self.find_element(by=By.ID, value=id_) File "/Users/**/.local/share/virtualenvs/src-nhT6G4Bk/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { File "/Users/**/.local/share/virtualenvs/src-nhT6G4Bk/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/Users/**/.local/share/virtualenvs/src-nhT6G4Bk/lib/python3.8/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: [id="ap_password"]

jakehilborn commented 2 years ago

Right, right. That actually makes sense since I forgot to also change the condition for checking if it's on the login page. I just pushed another fix.

jakehilborn commented 2 years ago

@jakehilborn

: # Find Continue text, the grandparent element of the text is the clickable Continue button driver.find_element_by_xpath("//span[contains(text(),'Continue')]").find_element_by_xpath('../..').click()

Should be sibling to parent and not grandparent

Screen Shot 2021-08-26 at 11 32 31 PM

``

I tried the grandparent thing out on the error report HTML file and it does look like it will work. Alternatively, finding the element by name works mostly well. But, it finds 3 instances even though the webpage only has 2 continue buttons. If I take that approach I'll need to add a loop that tries them in succession with some error handling.

Screen Shot 2021-08-26 at 9 44 34 PM

Chief-One commented 2 years ago

@jakehilborn - So with the latest change, it reached final checkout page and failed on it. Let me grab logs for it and upload failures.zip

Added

Chief-One commented 2 years ago
Screen Shot 2021-08-26 at 11 58 48 PM

@jakehilborn - FInal order placement button also has new text looks like so script can account for ti

jakehilborn commented 2 years ago

@Chief-One Pushed another update.

Chief-One commented 2 years ago

@jakehilborn - This one worked e2e!

jakehilborn commented 2 years ago

@Chief-One Great! Thanks a lot for helping debug this payment flow. Could you do me one more favor? Can you delete the cookies folder (it's inside the program_files folder) and then run debbit? There is this verify card workflow that may or may not work.

Screen Shot 2021-08-27 at 10 14 12 AM
Chief-One commented 2 years ago

@jakehilborn - Deleted cookies folder, ran the entire thing again, and worked without any issue! Thanks man

stevenmirabito commented 2 years ago

Can also confirm the latest master works great with the new page, including the verify card workflow. 🎉

d3vdays commented 2 years ago

Another thumbs up. Works great. Thanks.

jakehilborn commented 2 years ago

Fixed in release v2.1.1

darkknight7777777 commented 2 years ago

I'm still getting the below error in windows after downloading the latest version. I've tried 2 diff devices on 2 separate days to verify it's not a device issue. I know I'm probably doing something wrong since everyone else says it's working. Any ideas?

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"]