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

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

Closed
bjhiltbrand opened this issue Aug 10, 2021 · 31 comments
Closed

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

bjhiltbrand opened this issue Aug 10, 2021 · 31 comments

Comments

@bjhiltbrand
Copy link
Contributor

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

@bjhiltbrand
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link

Chief-One commented Aug 13, 2021

@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
Copy link

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

@darkknight7777777
Copy link

Just started having this issue this month.

@jakehilborn
Copy link
Owner

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
Copy link

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

@Chief-One
Copy link

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

@jakehilborn
Copy link
Owner

@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
Copy link

Chief-One commented Aug 27, 2021

@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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Owner

@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
Copy link

@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
Copy link

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
Copy link
Owner

@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
Copy link

Chief-One commented Aug 27, 2021

@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
Copy link

@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
Copy link
Owner

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
Copy link
Owner

@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
Copy link

Chief-One commented Aug 27, 2021

@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
Copy link

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
Copy link
Owner

jakehilborn commented Aug 27, 2021

@Chief-One Pushed another update.

@Chief-One
Copy link

@jakehilborn - This one worked e2e!

@jakehilborn
Copy link
Owner

@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
Copy link

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

@stevenmirabito
Copy link

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

@d3vdays
Copy link

d3vdays commented Aug 29, 2021

Another thumbs up. Works great. Thanks.

@jakehilborn
Copy link
Owner

Fixed in release v2.1.1

@darkknight7777777
Copy link

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

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

7 participants