简体   繁体   中英

Python Selenium - Cannot find submit button

Link: https://mail.protonmail.com/create/new?language=en

Problem

chrome.find_element_by_xpath("//input[@type='submit']").click()

Python cannot find the submit button id, name, or class in the HTML code

HTML:

<button type="submit" class="btn btn-submit" name="submitBtn">Create Account</button>

First you need to switch to iframe witch contains submit button. The you can find it and submit.

from selenium import webdriver
import os
import time

browser = webdriver.Chrome(executable_path =os.path.abspath(os.getcwd()) + "/chromedriver")
browser.get("https://mail.protonmail.com/create/new?language=en")
# wait page to load
time.sleep(3)
# find iframe
iframe = browser.find_element_by_css_selector('iframe[data-name="bottom"]')
# switch into iframe
browser.switch_to.frame(iframe)
browser.find_element_by_class_name('btn.btn-submit').click()

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