コード例 #1
0
    def test_endlaniperror(self):
        """结束ip地址非法,提示信息检查"""
        L.info("test_endlaniperror START:结束ip地址非法,提示信息检查")
        driver = self.driver
        print("caseid:007")
        try:
            login(driver)
        except e.NoSuchElementException:
            L.info("登录系统失败")
            L.error(traceback.format_exc())

        time.sleep(2)
        driver.find_element_by_xpath("//div[@id='want_more_id']/div").click()
        driver.find_element_by_id("lang_dhcpsever").click()
        time.sleep(3)
        driver.find_element_by_id("startLanIp").clear()
        driver.find_element_by_id("startLanIp").send_keys("2")
        driver.find_element_by_id("endLanIp").clear()
        driver.find_element_by_id("endLanIp").send_keys("255")
        driver.find_element_by_id("savebutton5").click()
        time.sleep(1)
        errorinfo2 = driver.find_element_by_id("errorinfo_2")
        result = True
        try:
            if errorinfo2.is_displayed():
                self.assertEqual(errorinfo2.text, "地址池结束值错误,请重新输入。")
            else:
                result = False
        except e.NoSuchElementException:
            L.error(traceback.format_exc())
        self.assertTrue(result)
        L.info("test_endlaniperror STOP")
コード例 #2
0
 def test_wrongip(self):
     """输入错误格式的ip地址,检查提示语"""
     L.info("test_wrongip:输入错误格式的ip地址,检查提示语")
     driver = self.driver
     print("caseid:004")
     result = 0
     driver.get(self.baseurl)
     login(driver)
     driver.implicitly_wait(2)
     driver.find_element_by_xpath("//div[@id='want_more_id']/div").click()
     driver.find_element_by_id("lang_dhcpsever").click()
     time.sleep(3)
     # 清除输入框中的内容
     driver.find_element_by_id("lanIP").clear()
     wrongip = ['192.168.www.4', '192.!23.tt.com', '192.168.%$.#', '1 92.168.  34', '192.168.344.2', '192.-168.3.2']
     for ip in wrongip:
         driver.find_element_by_id("lanIP").send_keys(ip)
         driver.find_element_by_id("savebutton5").click()
         try:
             driver.find_element_by_id("errorinfo_1")
         except e.NoSuchElementException:
             L.error(traceback.format_exc())
         else:
             if (driver.find_element_by_id("errorinfo_1").text == "IP地址含非法字符,请重新输入。")or\
                     (driver.find_element_by_id("errorinfo_1").text == "IP地址格式错误,请重新输入。"):
                 result += 1
                 driver.find_element_by_id("lanIP").clear()
                 time.sleep(2)
                 print("result:"+str(result))
     self.assertEqual(len(wrongip), result)
     L.info("test_wrongip STOP")
コード例 #3
0
 def test_startipbigger(self):
     """开始ip地址大于结束ip地址"""
     L.info("test_startipbigger START:开始ip地址大于结束ip地址,提示信息检查")
     driver = self.driver
     print("caseid:008")
     driver.get(self.baseurl)
     login(driver)
     time.sleep(2)
     driver.find_element_by_xpath("//div[@id='want_more_id']/div").click()
     driver.find_element_by_id("lang_dhcpsever").click()
     time.sleep(3)
     driver.find_element_by_id("startLanIp").clear()
     driver.find_element_by_id("startLanIp").send_keys("234")
     driver.find_element_by_id("endLanIp").clear()
     driver.find_element_by_id("endLanIp").send_keys("12")
     driver.find_element_by_id("savebutton5").click()
     time.sleep(1)
     errorinfo2 = driver.find_element_by_id("errorinfo_2")
     result = True
     try:
         if errorinfo2.is_displayed():
             self.assertEqual(errorinfo2.text, "地址池结束值不能小于开始值,请重新输入。")
         else:
             result = False
     except e.NoSuchElementException:
         L.error(traceback.format_exc())
     self.assertTrue(result)
     L.info("test_startipbigger STOP")
コード例 #4
0
 def test_reboot(self):
     """重启功能检查,重启后,进入登录页"""
     L.info("test_reboot START:重启功能检查")
     driver = self.driver
     print("caseid:024")
     uploadpng = self.uploadpng
     driver.get(self.baseurl)
     login(driver)
     driver.implicitly_wait(3)
     try:
         driver.find_element_by_xpath(
             "//div[@id='want_more_id']/div").click()
         time.sleep(1)
         driver.find_element_by_id("ic_systemSetup").click()
         time.sleep(2)
         driver.find_element_by_id("lang_reboot").click()
         time.sleep(5)
         driver.find_element_by_id("btn_reboot_router").click()
     except e.NoSuchElementException:
         L.error(traceback.format_exc())
     try:
         driver.find_element_by_id("btn_reboot_confirm").click()
         WebDriverWait(driver, 120).until(
             EC.invisibility_of_element_located((By.ID, "DeviceRebooting")))
         time.sleep(3)
         self.assertEqual(driver.current_url,
                          "http://192.168.0.1/Login.html")
     except e.NoSuchElementException:
         L.error(traceback.format_exc())
     L.info("test_reboot STOP")
コード例 #5
0
    def test_firwareupdate(self):
        """固件格式错误时提示信息检查"""
        L.info("test_firwareupdate START:固件格式错误时提示信息检查")
        #固件格式错误时提示信息检查,由于目前没有正确的固件,固件升级中暂时只做一个用例,后续完善
        driver = self.driver
        print("caseid:023")
        uploadpng = self.uploadpng
        driver.get(self.baseurl)
        login(driver)
        driver.implicitly_wait(2)
        driver.find_element_by_xpath("//div[@id='want_more_id']/div").click()
        time.sleep(1)
        driver.find_element_by_id("ic_systemSetup").click()
        time.sleep(3)
        driver.find_element_by_id("lang_upgrade").click()
        time.sleep(5)
        driver.find_element_by_css_selector('label.styled_button_s').click()
        time.sleep(5)
        cmd = "./upgrade/upload.exe" + " " + uploadpng
        print(cmd)

        #调用autoit脚本选择文件
        L.info("开始用autoit3脚本控制选择本地文件")
        ps = subprocess.Popen(cmd)
        ps.wait()
        time.sleep(10)
        try:
            driver.find_element_by_id("btn_begin_upload").click()

            if (driver.find_element_by_id("errorinfo_update").is_displayed()):
                errorinfo = driver.find_element_by_id("errorinfo_update").text
                self.assertEqual(errorinfo, "文件类型错误,应选择*.bin或*.img。")
        except e.ElementNotVisibleException:
            L.error(traceback.format_exc())
        L.info("test_firwareupdate STOP")
コード例 #6
0
 def test_newpassworderror(self):
     """新密码格式错误时的,提示信息检查"""
     L.info("newpassworderror START:新密码格式错误时的,提示信息检查")
     driver = self.driver
     print("caseid:020")
     currpassword = self.currpassword
     driver.get(self.baseurl)
     login(driver)
     driver.implicitly_wait(30)
     driver.find_element_by_xpath("//div[@id='want_more_id']/div").click()
     time.sleep(1)
     driver.find_element_by_id("ic_systemSetup").click()
     time.sleep(3)
     driver.find_element_by_xpath("//li[@id='liaccount']/a").click()
     driver.find_element_by_id("current_password").send_keys(currpassword)
     driver.find_element_by_id("new_password").send_keys("123")
     time.sleep(3)
     driver.find_element_by_id("savebutton5").click()
     try:
         if (driver.find_element_by_id("errorinfo_2").is_displayed()):
             errorinfo = driver.find_element_by_id("errorinfo_2").text
             self.assertEqual(errorinfo, "新密码长度不正确,请输入8至63个字符。")
     except e.NoSuchElementException:
         L.error(traceback.format_exc())
     L.info("newpassworderror START")
コード例 #7
0
 def test_crrentpswderror(self):
     """原密码错误时的提示语检查"""
     L.info("test_crrentpswderror START:原密码错误时的提示语检查")
     driver = self.driver
     print("caseid:019")
     currpassword = self.currpassword
     newpassword = self.newpassword
     driver.get(self.baseurl)
     login(driver)
     driver.implicitly_wait(30)
     driver.find_element_by_xpath("//div[@id='want_more_id']/div").click()
     time.sleep(1)
     driver.find_element_by_id("ic_systemSetup").click()
     time.sleep(3)
     driver.find_element_by_xpath("//li[@id='liaccount']/a").click()
     driver.find_element_by_id("current_password").send_keys("1")
     driver.find_element_by_id("new_password").send_keys(newpassword)
     driver.find_element_by_id("confirm_password").send_keys(newpassword)
     time.sleep(3)
     driver.find_element_by_id("savebutton5").click()
     try:
         if (driver.find_element_by_id("errorinfo_1").is_displayed()):
             errorinfo = driver.find_element_by_id("errorinfo_1").text
             self.assertEqual(errorinfo, "原登录密码错误,请重新输入。")
     except e.NoSuchElementException:
         L.error(traceback.format_exc())
     L.info("test_crrentpswderror STOP")
コード例 #8
0
    def test_cancelreboot(self):
        """点击重启路由器后,点击取消"""
        L.info(" test_cancelreboot START:点击重启路由器后,点击取消,确认可以成功取消")
        driver = self.driver
        print("caseid:025")
        driver.get(self.baseurl)
        #登录系统
        login(driver)
        #进入无线名称页面将无线名称修改为frt_test
        time.sleep(2)
        try:
            driver.find_element_by_id("wirless").click()
            driver.find_element_by_id('wifiName_24').clear()
            driver.find_element_by_id('wifiName_24').send_keys("frt_test")
            time.sleep(5)
            driver.find_element_by_xpath("//input[@id='savebutton']").click()
        except e.InvalidElementStateException:
            L.error(traceback.format_exc())

        time.sleep(5)
        result = True
        try:
            driver.find_element_by_id("saveconfirm2_5G").click()
            WebDriverWait(driver, 20).until(
                EC.invisibility_of_element_located(
                    (By.ID, "CreatePopAlertMessage")))
            """js = "document.getElementById('wifiName_24').value;"
            t = driver.execute_script(js)

            if t!="frt_test":
                L.info("无线wifi名称未保存成功,测试终止")
                result=False
                self.assertTrue(True,result)

            else:"""
            driver.find_element_by_xpath(
                "//div[@id='want_more_id']/div").click()
            time.sleep(1)
            driver.find_element_by_id("ic_systemSetup").click()
            time.sleep(2)
            driver.find_element_by_id("lang_reboot").click()
            time.sleep(2)
            driver.find_element_by_id("btn_reboot_router").click()
            time.sleep(2)
            driver.find_element_by_id("btn_reboot_cancel").click()
        except e.ElementNotVisibleException:
            L.error(traceback.format_exc())
        L.info("test_cancelreboot STOP")
コード例 #9
0
 def test_logout(self):
     """退出功能测试"""
     L.info(" test_logout START:测试退出功能")
     loginurl = self.baseurl
     driver = self.driver
     print("caseid:026")
     driver.get(self.baseurl)
     # 登录系统
     login(driver)
     try:
         time.sleep(2)
         driver.find_element_by_id("logoutword").click()
         time.sleep(2)
     except e.ElementNotVisibleException:
         L.error(traceback.format_exc())
     current_url = driver.current_url
     self.assertEqual(current_url, loginurl + "/Login.html")
     L.info("test_logout STOP")
コード例 #10
0
 def test_login_nopasswordenter(self):
     """不输入密码时的提示信息检查"""
     L.info("test_login_nopasswordenter START:不输入密码时的提示信息检查")
     driver = self.driver
     print("caseid:013")
     driver.get(self.baseurl)
     driver.find_element_by_id("logIn_btn").click()
     error1=driver.find_element_by_id("errorinfo_1")
     time.sleep(1)
     result=True
     try:
         if error1.is_displayed():
             L.info(error1.text)
             self. assertEqual(error1.text,"请输入登录密码。")
         else :
             result=False
     except e.NoSuchElementException:
         L.error(traceback.format_exc())
     self.assertTrue(result)
     L.info("test_login_nopasswordenter STOP")
コード例 #11
0
    def test_nopassword(self):
        """不输入原密码时,直接点击保存,提示信息检查"""
        L.info("test_nopassword START:不输入原来的登录密码时,提示语检查")
        driver = self.driver
        print("caseid:015")
        driver.get(self.baseurl)
        login(driver)
        driver.implicitly_wait(30)
        driver.find_element_by_xpath("//div[@id='want_more_id']/div").click()
        time.sleep(1)

        driver.find_element_by_id("ic_systemSetup").click()
        time.sleep(3)
        driver.find_element_by_xpath("//li[@id='liaccount']/a").click()
        driver.find_element_by_id("savebutton5").click()
        try:
            if (driver.find_element_by_id("errorinfo_1").is_displayed()):
                errorinfo = driver.find_element_by_id("errorinfo_1").text
                self.assertEqual(errorinfo, "原登录密码不能为空,请重新输入。")
        except e.NoSuchElementException:
            L.error(traceback.format_exc())
        L.info("test_nopassword STOP")
コード例 #12
0
 def test_noip(self):
     """不输入IP 地址,检查提示信息"""
     L.info("test_noip Start:不输入IP 地址,检查提示信息")
     driver = self.driver
     print("caseid:003")
     driver.get(self.baseurl)
     login(driver)
     time.sleep(2)
     driver.find_element_by_xpath("//div[@id='want_more_id']/div").click()
     driver.find_element_by_id("lang_dhcpsever").click()
     time.sleep(3)
     #清除输入框中的内容
     driver.find_element_by_id("lanIP").clear()
     #driver.find_element_by_id("lanIP").send_keys("4444444")
    #L.info(driver.find_element_by_id("lanIP").text
     driver.find_element_by_id("savebutton5").click()
     try:
         element = driver.find_element_by_id("errorinfo_1")
     except e.NoSuchElementException:
         L.error(traceback.format_exc())
     else:
         self.assertEqual('请输入IP地址。', element.text)
     L.info("test_noip STOP")
コード例 #13
0
    def test_login_wrongpassword(self):
        """输入错误密码"""
        L.info("test_login_wrongpassword START:密码错误时的提示语检查")
        driver=self.driver
        print("caseid:014")
        wrongpassword=self.wrongpassword
        driver.get(self.baseurl)
        driver.find_element_by_id("admin_Password1").send_keys("123")
        driver.find_element_by_id("logIn_btn").click()
        time.sleep(1)
        error2 = driver.find_element_by_id("errorinfo_1")
        result=True
        try:

            if error2.is_displayed():
                L.info(error2.text)
                self.assertEqual(error2.text,"密码错误,请重新输入。")
            else:
                result=False
        except e.NoSuchElementException:
            L.error(traceback.format_exc())
        self.assertTrue(result, True)
        L.info("test_login_wrongpassword STOP")
コード例 #14
0
    def test_wificlose(self):
        """关闭WiFi功能检查"""
        L.info("test_wificlose START:关闭WiFi功能后,查看电脑的无线列表中是否还有wifi 信息")
        driver = self.driver
        print("caseid:042")
        driver.get(self.baseurl)
        login(driver)
        time.sleep(2)
        driver.find_element_by_id("wirless").click()
        time.sleep(1)
        driver.find_element_by_id("wlan_status").click()
        time.sleep(5)
        result = True
        try:
            driver.find_element_by_id("clowifyconfirm2g").click()
            WebDriverWait(driver, 20).until(
                EC.invisibility_of_element_located((By.ID, "CreatePopAlertMessage"))
            )
        except NoSuchElementException:
            L.error(traceback.format_exc())
        # file=os.popen("netsh wlan show network").read()
        # L.info(file)
        # if not re.search('SSID\s+\d+\s+:\frt_test',file):
        #     L.info("test pass")
        #     result=True
        # else:
        #     result=False
        # self.assertTrue(result)
        # 也可以用subprocess 调用实现

        # p = subprocess.Popen('netsh wlan show network', stdout=subprocess.PIPE)
        # print (p)
        # t=str(p.stdout.read())
        # t = t.split("\\n")
        # print(t)
        # for i in t:
        #     print(i)
        #     if not re.search('SSID\s+\d+\s+:\frt_test', i):
        #         L.info("test pass")
        # 测试完成,再次开启
        result = True
        p = subprocess.Popen('netsh wlan show network', stdout=subprocess.PIPE)
        #print(p.stdout.readlines())
        for line in p.stdout.readlines():
            if not re.search('SSID\s+\d+\s+:\frt_test', str(line)):
                L.info("no found")
            else:
                result = False
                break
        self.assertTrue(result)

        driver.find_element_by_id("wlan_status").click()
        time.sleep(2)
        try:

            WebDriverWait(driver, 20).until(
                EC.invisibility_of_element_located((By.ID, "CreatePopAlertMessage"))
            )
        except NoSuchElementException:
            L.error(traceback.format_exc())
        L.info("test_wificlose STOP")