Sebastian Bucarion
Sebastian Bucarion

Reputation: 29

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>

Upvotes: 0

Views: 182

Answers (1)

Zaraki Kenpachi
Zaraki Kenpachi

Reputation: 5740

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()

Upvotes: 2

Related Questions