2018-03-23 14:44:36 2976瀏覽
學(xué)習(xí)了Python語言一段時(shí)間后,在公司的項(xiàng)目里也使用到了python來寫測試腳本,一些重復(fù)的操作都使用腳本來處理了。大大的提高工作效率,減少了一些手工重復(fù)的操作。driver.switch_to.frame("login_frame")在打開QQ郵箱首頁后,需要先切換到login_frame的框里才可以進(jìn)入輸入帳號密碼登錄操作。
#!/usr/bin/envpython #_*_coding:utf-8_*_ #Author:VincentLan importunittest,time fromseleniumimportwebdriver fromselenium.webdriver.common.keysimportKeys classQQ_mail(unittest.TestCase): defsetUp(self): self.driver=webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url="https://mail.qq.com" self.verificationErrors=[] self.accept_next_alert=True print("正在訪問QQ郵箱") deftest_mail_login(self): """QQ郵箱登錄""" driver=self.driver driver.maximize_window() driver.get(self.base_url+"/") driver.switch_to.frame("login_frame") driver.find_element_by_id("switcher_plogin").click() driver.find_element_by_id("u").clear() driver.find_element_by_id("u").send_keys("yourmailadd") driver.find_element_by_id("p").clear() driver.find_element_by_id("p").send_keys("yourpassword") driver.find_element_by_id("p").send_keys(Keys.ENTER) #driver.find_element_by_id("login_button").click() print("登錄QQ郵箱成功") """ deftearDown(self): self.driver.quit( self.assertEqual([],self.verificationErrors) """ if__name__=="__main__": unittest.main()
""" deftearDown(self): self.driver.quit() self.assertEqual([],self.verificationErrors) """
最后想要了解更多關(guān)于軟件測試培訓(xùn)發(fā)展前景趨勢,請關(guān)注扣丁學(xué)堂官網(wǎng)、微信等平臺,扣丁學(xué)堂IT職業(yè)在線學(xué)習(xí)教育平臺為您提供權(quán)威的軟件測試視頻教程系統(tǒng),通過千鋒扣丁學(xué)堂金牌講師在線錄制的軟件測試在線視頻教程,讓你快速掌握軟件測試從入門到精通開發(fā)實(shí)戰(zhàn)技能。
【關(guān)注微信公眾號獲取更多學(xué)習(xí)資料】
查看更多關(guān)于“軟件測試技術(shù)資訊”的相關(guān)文章>>