1 #Coding=utf-82 fromSeleniumImportWebdriver3 #From selenium.common.exceptions import nosuchelementexception4 ImportUnittest,os,time5 6Source=open ("F:\\script\\py_scripts\\login_parameter\\username.txt","R")#User name File7UN = source.read ()#Read user name8 source.close ()9 TenSource2=open ("F:\\script\\py_scripts\\login_parameter\\password.txt","R")#User name File OnePW = Source2.read ()#Read user name A source2.close () - - deflogin (): the #Driver=self.driver - #Driver.maximize_window () -DRIVER.FIND_ELEMENT_BY_ID ("username"). Clear () -DRIVER.FIND_ELEMENT_BY_ID ("username"). Send_keys (un) + Print(un) -DRIVER.FIND_ELEMENT_BY_ID ("Password"). Clear () +DRIVER.FIND_ELEMENT_BY_ID ("Password"). Send_keys (PW) A Print(PW) atDRIVER.FIND_ELEMENT_BY_ID ("loginbtn"). Click () -Time.sleep (3) - -Driver=Webdriver. Chrome () -Driver.get ("http://cloud.pingnanlearning.com/test/login/index.php") -Login ()
Python practice file referencing user name password login system