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

"You have no items in cart." when screenshot clearly shows item in cart #798

Open
sircambridge opened this issue May 29, 2021 · 6 comments

Comments

@sircambridge
Copy link

sircambridge commented May 29, 2021

This only ever happened once, so i cant reproduce it, but fairgame managed to add an item to the cart, and got to the cart page, and the "Proceed to Checkout"(PTC) button is available, but somehow the "You have no items in cart. Going back to stock check."

see this screenshot that was taken.

notice the filename is "screenshot-no-items_05-28-2021_15_27_08"

image

what this tells me is somehow self.get_cart_count() == 0, even though clearly an item is in the cart.

its possible the state of the cart icon on the top right shows 0, even though the item is in the cart. is there a reason for this sanity check? its possible if we detect the PTC(Proceed to checkout) button, we should try and click it regardless of what self.get_cart_count() returns?

specifically this check :
https://github.com/Hari-Nagarajan/fairgame/blob/master/stores/amazon.py#L1123

@DakkJaniels
Copy link
Collaborator

It checks for the button first, so if it found that first, it would have clicked it. If it doesn't find it, it checks if the cart has nothing in it. Why is the screenshot cut off? What does the cart look like in the banner at the top?image

@sircambridge
Copy link
Author

sircambridge commented May 29, 2021

oops, I was looking at a different section of the code, deep within navigate_pages(), where the self.get_cart_count() happens before a PTC button check. I stand corrected, I dont think this is what is happening, the actual logic is in handle_cart()

this is the part that confused me:
image

good eye, the screenshot is cut off because thats how big the chrome window happened to be when the screenshot was taken, so in reality I have no idea what the cart icon number shows. I have since made the window bigger. @DakkJaniels do you think its possible the client side js on the amazon page simply doesnt update the dom element for the cart to 1 if its not visible? is the cart number loaded asynchronously?

is it possible there is a rare asynchronous condition where self.get_amazon_element(key="PTC") is not found, and self.get_cart_count() == 0 and the page fully loads right before the screenshot is taken? like here between lines 1420 and 1421. maybe i just had really bad luck and got caught in that tiny millisecond window where the dom was not fully loaded?

image

@sircambridge
Copy link
Author

closing this issue, i cannot reproduce this.

I have since successfully clicked the Proceed to Checkout button many times without this error.

I think this issue still exists, but there is only a very tiny window of race condition where this can happen.

@sircambridge
Copy link
Author

sircambridge commented Jun 8, 2021

guys im reopening this because it happened again.

screenshot no-items and an item is in the cart. this time I was able to capture the fact that the cart number on the top right is indeed == 0.

image

this happens very rarely, I would say I was able to add to cart maybe 50 or 60 times before this happened once. there must be some kind of async page loading race condition where the number is 0 for a split second.

I think we should continue checking for the PTC button until the timeout, and maybe dont bother with checking if self.get_cart_count() == 0 and early exit ? what do you guys suggest?

image

image

@sircambridge sircambridge reopened this Jun 8, 2021
@DakkJaniels
Copy link
Collaborator

Then it will sit there for 5-10 seconds until the timeout occurs, which also not something you would want to happen. Probably makes sense to just set a flag once it hits it the first time, then waits a half a second before it breaks the loop.

@sircambridge
Copy link
Author

sircambridge commented Jun 27, 2021

happened again on june 26th. I thought I had removed the get_cart_count, but i had not. I'm going to remove it and report back in a few weeks

image

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