0

Please I am not sure what I have done wrong. On the first page I have my code run the following:

next = self.driver.find_element_by_name("checkout_shipping")
actions = ActionChains(self.driver)
actions.move_to_element(next)
actions.click(next).perform()

after clicking next, I want my code to click deliver on the second page:

deliver = self.driver.find_element_by_name("final_shipping_option")
actions_check = ActionChains(self.driver)
actions_check.move_to_element(deliver)
actions_check.click(deliver).perform()

However the second page loads and does nothing. On terminal I get "Process finished with exit code 0" as though everything worked fine when it didn't.

1 Answers1

0

Selenium is a Library that essentially acts as a user. So it loads pages on a browser and manually preforms a click.

I believe your script is finding the correct Element with name "final_shipping_option" but maybe it clicks it too fast for the browser since it's still loading in the Webpage.

Consider trying a time.sleep(x) or something like this: Wait until page is loaded with Selenium WebDriver for Python

Another possibility is that the name of the element is incorrect, so you're clicking the wrong element? Try to click it via ID, or Class or even XPATH depending on if the page is very dynamic or not..

jasonmzx
  • 507
  • 5
  • 15
  • Thanks a lot, the XPATH fixed it. Please do you know why XPATH worked but element name didn't? Is there any disadvantage to using Xpath? – The Unknown Feb 24 '21 at 06:43