fairgame icon indicating copy to clipboard operation
fairgame copied to clipboard

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

Open sircambridge opened this issue 3 years ago • 6 comments

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

sircambridge avatar May 29 '21 00:05 sircambridge

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

DakkJaniels avatar May 29 '21 01:05 DakkJaniels

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 avatar May 29 '21 04:05 sircambridge

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 avatar Jun 01 '21 23:06 sircambridge

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 avatar Jun 08 '21 22:06 sircambridge

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.

DakkJaniels avatar Jun 08 '21 23:06 DakkJaniels

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

sircambridge avatar Jun 27 '21 10:06 sircambridge