Open
Conversation
* Add a --debug flag to keep the browser open on failure * Add safe_click function to wrap click actions with error handling
* get_by_role isn't truthy; check count or visibility * query_selector returns an object or None * Use page.title() method instead of query_selector * Use wait_for_selector() instead of checking if still on page * Check if there's a next link instead of waiting for it to timeout * Add message to make it clear script is done
dcwangmit01
requested changes
Dec 11, 2025
Owner
dcwangmit01
left a comment
There was a problem hiding this comment.
@pboushy Thanks for making a PR! I appreciate it. I thought I'd add some comments. I'll give you a few days to address the comments. If you don't get to it, I'll merge it anyways. Happy holidays.
| # Check if we're on the less fully featured page | ||
| test_less_featured_page = page.query_selector('a:has-text("Returns & Orders")') | ||
| if not test_less_featured_page: | ||
| if test_less_featured_page is None: |
Owner
There was a problem hiding this comment.
NITPICK: I think some of my old teammates would have said this is less Pythonic. I'm not the Python police, though. Just FYI.
|
|
||
|
|
||
| def amazon_invoice_downloader(): | ||
| global DEBUG_MODE |
Owner
There was a problem hiding this comment.
MUST: Would be great to avoid a global variable. This program uses "docopt" library, so you it should automatically be passed in at L342 in your PR. "run(playwright, args)"
Collaborator
Author
|
I'll work on this over the weekend. I didn't get to it last weekend due to some personal items. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In my most recent run, I kept running into a problem where it would crash immediately.
Since I've seen this in the past, I looked at ways to make it easier for a user/developer to investigate the webpage in the browser that playwright opens.
Because multiple different functions are used to locate the item to click, I decided to create a single wrapper function
safe_click()that takes the name of apagemethod, and the respective arguments.This makes it very easy for anyone to run the amazon-invoice-downloader with the
--debugflag, see the web interface, right click > inspect and determine what the issue is. It should make it far easier to make adjustments as Amazon changes their website.