jprouty / mint-amazon-tagger

Tool for labeling Mint transaction from Amazon purchases
MIT License
224 stars 36 forks source link

Stuck at "Switch Accounts" for Amazon Login Flow #86

Closed cwmoriarty closed 1 year ago

cwmoriarty commented 2 years ago

Seeing selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="ap_email"]"} as an error at the "Switch Accounts" page.

Nothing gets ".click"ed. I'm wondering if the element "text" isn't exactly "Add account" ?

Here's the HTML on that page: <div class="a-column a-span12 a-text-left">Add account</div>

https://github.com/jprouty/mint-amazon-tagger/blob/3642c33e7d04751ff5fdccbd45285883022ce1d1/mintamazontagger/orderhistory.py#L138

cwmoriarty commented 2 years ago

Similar issue if the account shows on the switcher page. I don't know much about the DOM, but from the inspector text looks totally empty and outerText might be better for the comparison?

outerText: "Switch accounts\nSign out\nChristopher W Moriarty\ncwm@cwmoriarty.com\nAdd account\nLearn more about when to add accounts.\n Conditions of Use  Privacy Notice  Help \n© 1996-2021, Amazon.com, Inc. or its affiliates"
text: ""

https://github.com/jprouty/mint-amazon-tagger/blob/3642c33e7d04751ff5fdccbd45285883022ce1d1/mintamazontagger/orderhistory.py#L123

jprouty commented 2 years ago

Hi @cwmoriarty, unfortunately I wasn't able to replicate the issue you're describing. Would you mind attaching a screen shot of the last thing you see before the app gets stuck? Also, any intermediate screens might be helpful too

Based on the line you mentioned, it's not getting stuck on clicking "Add account" but instead when looking for the user id box to add the new account. It might be that you have a slow internet connection (there are some ~3 second sleeps in place today).

As a work around, I've added a mode that allows you to manually log in yourself bypassing all of this code. Be aware of https://github.com/jprouty/mint-amazon-tagger/issues/87 as this is making the workflow especially difficult right now.

jprouty commented 2 years ago

I'm going to close this out until we can replicate / get more information. Thanks.

cwmoriarty commented 2 years ago

Amazingly, this just started happening again. I'll check out --amazon_user_will_login, that's a great idea considering this is trying to work through a possibly changing-thing.

Note: I don't have any additional accounts or anything.

A run after clearing cookies:

image

If I click "sign in".

image

And it's only after I enter an email address that an ap_password element appears.

image

After forcing the chromedriver window to login (and setting a cookie):

image

Thanks!

cwmoriarty commented 2 years ago

I should note, technically this is a different error. Similar issue with the orderhistory.py login flow.

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="ap_password"]"}

cwmoriarty commented 2 years ago

Odd, not sure if this the result of using --amazon_user_will_login but it doesn't look like "Request report" is being clicked before moving to the next report type. So it ends up like this:

image

jprouty commented 2 years ago

Hmm; I'm sorry you're having all this trouble! It certainly seems like you're hitting a rough patch on the amazon flow.

How would you describe your internet connect / computer performance? There's some implicit waits in the flow, and if they are too short it's possible that the automation framework is expecting your page to have loaded before it might be done or ready/rendered. This would explain why it's hit and miss.

I just verified --amazon_user_will_login works for my on MacOS 12.1 intel w/ Chrome 98 with no issues (all 3 report times downloaded). I've added some extra logging and cut a new version as 1.42. If you wouldn't mind trying again with that version that would be helpful. If it fails, could you provide me (Either here or direct over email: jeff.prouty@gmail.com) the tagger log (you can find it at /Users/$USER/MintAmazonTagger/Tagger\ Logs/DATE.log).

Thanks! Jeff

jprouty commented 2 years ago

@cwmoriarty Is this issue still happening for you? Thanks

jprouty commented 1 year ago

@cwmoriarty Please reopen if this issue persists. The Amazon user choice flow has been reworked since this bug has been filed. 🤞