您的位置:68399皇家赌场 > 域名注册 > selenium python自动化测试

selenium python自动化测试

发布时间:2019-05-03 21:48编辑:域名注册浏览(67)

    from selenium import webdriver
    import unittest
    import importlib,sys
    import time
    importlib.reload(sys)
    sys.getdefaultencoding()
    class TestLogin(unittest.TestCase):
        #指定浏览器
        def setUp(self):
            self.driver = webdriver.Firefox()
            #打开URL
            self.driver.get("http://192.168.33.133:7001/console/login/LoginForm.jsp")
    
        def test_login(self):
            #登录操作
            title = self.driver.title
            print(title)
            now_url = self.driver.current_url
            print(now_url)
            j_username = "weblogic"
            j_password = "weblogic123"
            time.sleep(5)
            #执行登录
            #用户名定位
            self.driver.find_element_by_id("j_username").clear()
            self.driver.find_element_by_id("j_username").send_keys(j_username)
            #密码定位
            self.driver.find_element_by_id("j_password").clear()
            self.driver.find_element_by_id("j_password").send_keys(j_password)
            #点击登录
            #self.driver.find_element_by_css_selector("btn btn-primary").click()
            self.driver.find_element_by_class_name("formButton").click()
            time.sleep(3)
            self.driver.find_element_by_class_name("statusLabel").click()
            #登录成功断言
            #login_name = self.driver.find_element_by_xpath('html/body/div[3]/div[2]/ul/[1]li/a/strong').text
            #login_name = login_name.strip('您好:')
            #assert login_name == j_username
    
            # 关闭浏览器
    
        #def tearDown(self):
        #    self.driver.quit()
    
        if __name__ == "__main__":
            unittest.main()
    

    本文由68399皇家赌场发布于域名注册,转载请注明出处:selenium python自动化测试

    关键词: 68399皇家赌场