Fill forms using selenium or requests Fill forms using selenium or requests selenium selenium

Fill forms using selenium or requests


You cannot get access to Password field because it's not present on main page. To handle Password field you have to click Login button to get to Login page. Also you need to switch to iframe which contains authentication form

from selenium.webdriver.support.ui import WebDriverWait as waitfrom selenium.webdriver.support import expected_conditions as ECdriver.get("https://www.santandertotta.pt/pt_PT/Particulares.html")driver.find_element_by_xpath("//input[@title='Login de Particulares']").click()wait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it("ws"))user = driver.find_element_by_name("identificacionUsuario")user.send_keys("user")pas = driver.find_element_by_name("claveConsultiva")pas.send_keys("password")pas.submit()


Once you access the url https://www.santandertotta.pt/pt_PT/Particulares.html first you have to click on the element with text as Login then only the the Nome and Password field appears but to access those fileds you have to switch to the frame with id as ws inducing WebDriverWait. Next to locate the element of Nome you have to induce WebDriverWait again as follows :

from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECdriver=webdriver.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')driver.get("https://www.santandertotta.pt/pt_PT/Particulares.html")driver.find_element_by_xpath("//input[@class='ttAH_button03']").click()WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.ID, "ws")))WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='inputlong' and @id='identificacionUsuario']"))).send_keys("your_name")driver.find_element_by_xpath("//input[@id='claveConsultiva' and @name='claveConsultiva']").send_keys("your_password")driver.find_element_by_link_text("Entrar no NetBanco Particulares").click()

Here you can find a relevant discussion on Ways to deal with #document under iframe