Error clicking a button using Selenium

I code the Add to Cart function on WellGosh.com using Selenium in Python.

I have a code that is the right size to add to the cart and log into my account and go to the correct delivery address, but when I try to confirm the delivery method (fedex), it will not allow me to click the continue button.

Here is a sample code to verify:

def Checkout():
#brings you to your cart
driver.get('https://wellgosh.com/checkout/cart')

#clicks to checkout
checkout=driver.find_element_by_xpath('//*[@id="shopping-cart-table"]/tfoot/tr/td/div[2]/a')
checkout.click()

#Log in
login=driver.find_element_by_xpath('//*[@id="login-email"]')
login.send_keys(e_mail)
password=driver.find_element_by_xpath('//*[@id="login-password"]')
password.send_keys(Pass)
LogIn=driver.find_element_by_xpath('//*[@id="checkout-step-login"]/div/div[2]/div/button')
LogIn.click()
cont=driver.find_element_by_xpath('//*[@id="billing-buttons-container"]/button')
cont.click()
driver.implicitly_wait(100)
element = driver.find_element_by_xpath('//*[@id="shipping-method-buttons-container"]/button')
element.click()

I get this error:

selenium.common.exceptions.ElementNotVisibleException: Message: item not displayed

This is a snippet of HTML code:

    </script>
    </div>
    <div class="buttons-set" id="shipping-method-buttons-container">
        <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><i class="fa fa-chevron-left plain"></i>Back</a></p>
        <button type="button" class="button btn-continue" onclick="shippingMethod.save()">Continue</button>
        <span id="shipping-method-please-wait" class="please-wait zoooooom" style="display:none;">
            <i class="fa fa-cog fa-spin plain"></i>
        </span>
    </div>
</form>
+4
source share
2 answers

Try under the code and let me know if your problem solved:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC

wait(driver, 10).until(visibility_of_element_located((By.XPATH, '//button[text()="Continue"]'))).click()
0
source

, javascript, onclick ? , HTML :

driver.execute_script ( "shippingMethod.save()" )

: iFrames, iFrame, / .

-2

Source: https://habr.com/ru/post/1669102/


All Articles