How to press login button in selenium python 3

Viewed 2830

I am able to enter username and password, but not able to press login button in selenium. May you advise? I didn't put the specific website, sorry.

thanks so much for your help!

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument("--disable-infobars")
driver = webdriver.Chrome(executable_path = "C:\Python36-32\selenium\chromedriver",chrome_options=chrome_options)


driver.get("website")


elem = driver.find_element_by_name("UserName")
elem.send_keys("test")

elem = driver.find_element_by_name("Password")
elem.send_keys("test")

Above Work

Below, Not Sure Here

elem = driver.find_element_by_type("submit")
elem.click()

Outer HTML

<input value="" class="userid-button" type="submit">

Selector

#online_login > input.userid-button

XPath

//*[@id="online_login"]/input[3]

Element

<input value="" class="userid-button" type="submit">
2 Answers
Related