简体   繁体   中英

Python Selenium not able to find element for Create New Account button on website

Here is my code so far, note that the web page loads up with a captcha. I countered this with adding a time.sleep so I can run tests. When I try to submit the form by submitting "Create new account", I get an error saying the element has no attribute for 'submit'. I tried finding the element using xpath, css_selectos, tags, class names, etc.

from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time

browser = webdriver.Chrome()
browser.get('https://www.bstn.com/en/register/address')
time.sleep(35)

elam = browser.find_element_by_css_selector("[value='Create new account']")
elam.Submit()

If you are trying to click on Create new account button after filling information then please find below xpath to click on it

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

    WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//input[@class='button radius charcheck-submit']"))).click()

Another solution with action class

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver import ActionChains

    actionChains = ActionChains(driver)
    submit = WebDriverWait(driver, 10).until(
        EC.visibility_of_element_located((By.XPATH, "//input[@class='button radius charcheck-submit']")))
    actionChains.move_to_element(submit).click().perform()

Working code

from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

browser = webdriver.Chrome(executable_path=r"C:\New folder\chromedriver.exe")
# browser = webdriver.Chrome()
browser.get('https://www.bstn.com/en/register/address')
time.sleep(35)
WebDriverWait(browser, 10).until(
EC.element_to_be_clickable((By.XPATH, "//input[@class='button radius charcheck-submit']"))).click()

Here is my code so far, note that the web page loads up with a captcha. I countered this with adding a time.sleep so I can run tests. When I try to submit the form by submitting "Create new account", I get an error saying the element has no attribute for 'submit'. I tried finding the element using xpath, css_selectos, tags, class names, etc.

from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time

browser = webdriver.Chrome()
browser.get('https://www.bstn.com/en/register/address')
time.sleep(35)

elam = browser.find_element_by_css_selector("[value='Create new account']")
elam.Submit()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM