简体   繁体   中英

Login in to a website having JS generated Login Form using Python Selenium

I am trying to automate a process using Selenium, wherein I need to login to https://saccess.nic.in . The Page Source of the website is Pure JS. I only know Python and I am using the following code

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

FIRST_URL = "https://saccess.nic.in"

options = Options()
options.add_argument("--start-maximized")
browser = webdriver.Firefox(options=options)

browser.get(FIRST_URL)
browser.implicitly_wait(10)
first_user = browser.find_element_by_id('uname')

But I can't find the element and get the error selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [id="uname"]

So, I have found the answer to my question after bit of more research. The form was lying inside the frame so I added the following line to my code

driver.switch_to.frame(driver.find_element_by_tag_name("frame"))

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