Closed eoprede closed 4 years ago
I like this idea - are we sure this works throughout every part of the process including auto checkout?
And I'm thinking this could be made a little simpler, like a smile
boolean in the config that adds the subdomain if True
. Obviously not as flexible, but seems to be the only current use case and avoids the problem of a malformed user-supplied URL
I have not tested auto checkout, as it is trying to use a wrong credit card for me (I think there;s an enhancement request to allow specifying credit card). But as far as I understand, the web site matters only in the beginning, from there on code looks for elements on the page and I believe those are the same. But you are bringing another good point - the change in base url worked fine 7 days ago, however there has been quite a lot code change in the last 7 days. All of the references to BASE_URL that I see in the code should work fine with smile, however I haven't tested most recent version of the code.
As for the adding option as argument - my personal opinion is that options should be used for something that is likely to change in between orders (like whether I am using whole foods or fresh as a service), while going to smile instead of regular amazon is something that I would want to be doing all the time. So my vote would be to keep it in config. I agree, letting users provide URL could result in errors, but I am hoping most of users can handle instructions "if you want to go to smile, uncomment following 2 lines". Smile is the only option that I can think of right now, outside of rare cases of using some proxy or something like that, but who knows what will Amazon roll out next week?
Just tested Fresh order with checkout, order was placed just fine, but got the following error in the end (ignore the notification error in the middle):
[2020-04-21 23:26:42] {main_loop} INFO: Selecting slot: Tomorrow::7:00 AM - 9:00 AM [2020-04-21 23:26:42] {navigate} INFO: Navigating <Route beginning at 'https://smile.amazon.com/gp/buy/shipoptionselect/handlers/display.html' with 3 stops> [2020-04-21 23:26:42] {navigate_waypoint} INFO: Navigating <Waypoint ('xpath', "//*[contains(@class, 'ufss-overview-continue-button')]") -> 'gp/buy/payselect/handlers/display.html'> [2020-04-21 23:26:43] {wrapper} ERROR: Action failed: Traceback (most recent call last): File "C:\Users\gesha\Documents\whole-foods-deliverance\deliverance\notify.py", line 27, in wrapper return func(*args, **kwargs) File "C:\Users\gesha\Documents\whole-foods-deliverance\deliverance\notify.py", line 50, in send_telegram raise requests.exceptions.HTTPError(response) requests.exceptions.HTTPError: {'ok': False, 'error_code': 404, 'description': 'Not Found'} [2020-04-21 23:26:49] {navigate_waypoint} INFO: Navigated to 'gp/buy/payselect/handlers/display.html' [2020-04-21 23:26:49] {navigate_waypoint} INFO: Navigating <Waypoint ('id', 'continue-top') -> 'gp/buy/spc/handlers/display.html'> [2020-04-21 23:26:57] {navigate_waypoint} INFO: Navigated to 'gp/buy/spc/handlers/display.html' [2020-04-21 23:26:57] {navigate_waypoint} INFO: Navigating <Waypoint ('xpath', "//input[contains(@class, 'place-your-order-button')]") -> 'gp/buy/thankyou/handlers/display.html'> [2020-04-21 23:27:04] {handle_redirect} WARNING: Redirected to: 'https://smile.amazon.com/gp/buy/spc/handlers/static-submit-decoupled.html/ref=ox_spc_place_order' [2020-04-21 23:27:04] {alert} INFO: Alerting user with message: 'Encountered an error'
Nice! I suppose that could be fixed by allowing multiple possible destinations in the final waypoint config.
To your earlier comment, I agree with your point - I'm not saying it should be a command line arg, but a simpler config entry like: use_smile = true
As for payment options, we're getting there. I've made the element class and locators for that page, I just need to find a way to fit the selection logic between waypoints in a way that isn't terrible and doesn't make me want to rewrite the whole thing even more than I already do
I've changed config file to use boolean use_smile, as discussed. Also it would seem that the issue with final redirect I saw may be coming from Fresh, not from smile - there's an issue open for it.
A very simple PR to let users specify custom URL (specifically Amazon Smile). The rest of the code seems to work totally fine with the custom URL.