I'm trying to enter text into a login page. The login page is: https://ppair.uspto.gov/TruePassSample/AuthenticateUserLocalEPF.html
using "inspect elements" in Internet Explorer (the website only load in Internet Explorer) it seems to me that the name for the "select Digital certificate" text field is: "username"
This is my script:
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# Digital Certificate Path
DigitalCertificateFolder = 'C:\FOLDER'
DigitalCertificateFile = 'FILE.epf'
DigitalCertificatePath = DigitalCertificateFolder + '\\' + DigitalCertificateFile
password = 'PASSWORD'
# get the path of IEDriverServer
dir = 'C:\FOLDER2'
ie_driver_path = dir + "\IEDriverServer.exe"
# create a new Internet Explorer session
driver = webdriver.Ie(ie_driver_path)
driver.implicitly_wait(30)
driver.maximize_window()
# navigate to the application home page
driver.get("https://ppair.uspto.gov/TruePassSample/AuthenticateUserLocalEPF.html")
# get the search textbox
Select_Digital_Certificate = driver.find_element_by_name("username")
Select_Digital_Certificate.send_keys(DigitalCertificatePath)
This is the output from inspect element in Internet Explorer:
<INPUT name=username style="CURSOR: auto; BACKGROUND-IMAGE: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QsPDhss3LcOZQAAAU5JREFUOMvdkzFLA0EQhd/bO7iIYmklaCUopLAQA6KNaawt9BeIgnUwLHPJRchfEBR7CyGWgiDY2SlIQBT/gDaCoGDudiy8SLwkBiwz1c7y+GZ25i0wnFEqlSZFZKGdi8iiiOR7aU32QkR2c7ncPcljAARAkgckb8IwrGf1fg/oJ8lRAHkR2VDVmOQ8AKjqY1bMHgCGYXhFchnAg6omJGcBXEZRtNoXYK2dMsaMt1qtD9/3p40x5yS9tHICYF1Vn0mOxXH8Uq/Xb389wff9PQDbQRB0t/QNOiPZ1h4B2MoO0fxnYz8dOOcOVbWhqq8kJzzPa3RAXZIkawCenHMjJN/+GiIqlcoFgKKq3pEMAMwAuCa5VK1W3SAfbAIopum+cy5KzwXn3M5AI6XVYlVt1mq1U8/zTlS1CeC9j2+6o1wuz1lrVzpWXLDWTg3pz/0CQnd2Jos49xUAAAAASUVORK5CYII=); BACKGROUND-REPEAT: no-repeat; BACKGROUND-ATTACHMENT: scroll; BACKGROUND-POSITION: right center" type=text size=38 lpcachedvisval="1" lpcachedvistime="1491220212">
When I try to run the script in the console to receive the following error: "NameError: name 'Select_Digital_Certificate' is not defined".
Can someone please explain to me what I'm doing wrong?
Required input field located inside an iframe
, so you need to switch to that iframe
before handling input
:
driver.get("https://ppair.uspto.gov/TruePassSample/AuthenticateUserLocalEPF.html")
driver.switch_to.frame('entrustTruePassGuiFrame')
Select_Digital_Certificate = driver.find_element_by_name("username")
...
To switch back to main HTML
document you might need to use
driver.switch_to.default_content()
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.