class GrphicVideo(unittest.TestCase): @classmethod def setUpClass(cls): browser = BrowserEngine(cls) cls.driver = browser.open_browser(cls) @classmethod def tearDownClass(cls): cls.driver.close() def test_graphic_videoplay(self): self.initbase = BasePage(self.driver) self.driver.get("https://www.iqiyi.com/v_19rsjaio7k.html") time.sleep(10) try: self.assertTrue("神话" in self.initbase.find_element("s => span.header-link").text) except Exception as e: logger.error("Fail to play video: %s" % e) self.initbase.get_windows_screen() def test_graphic_muiscplay(self): self.initbase = BasePage(self.driver) self.driver.get("https://www.kugou.com/song/#hash=BE6372BA684D2B195FEB691FD8DFC6CC&album_id=528482") self.initbase.click('toggle') time.sleep(10) try: self.assertTrue("Five Hundred Miles" in self.initbase.find_element("c => audioName").text) except Exception as e: logger.error("Fail to play music: %s" % e) self.initbase.get_windows_screen()
class WlanConnect(unittest.TestCase): @classmethod def setUpClass(cls): browser = BrowserEngine(cls) cls.driver = browser.open_browser(cls) @classmethod def tearDownClass(cls): cls.driver.close() def test_wlan_login_fail(self): wlan_dict={#"miss_username":['','19911992'], "miss_password":['*****@*****.**',''], "incorrect_username":['weix.b.sun.com','19911992'], "incorrect_password":['*****@*****.**','12345678']} self.initbase = BasePage(self.driver) for key in wlan_dict: self.driver.get('https://gia-captiveportal.intel.com/guest/guest_hello_c.php?mac=84:3a:4b:c8:a8:f0&_browser=1') self.initbase.type('s => input#ID_form80308bd3_weblogin_username',wlan_dict[key][0]) self.initbase.type('s => input#ID_form80308bd3_weblogin_password',wlan_dict[key][1]) js_bottom = "var q=document.documentElement.scrollTop=10000" self.driver.execute_script(js_bottom) time.sleep(1) self.initbase.click('s => input#ID_form80308bd3_weblogin_visitor_accept_terms') self.initbase.click('s => input#ID_form80308bd3_weblogin_submit') self.initbase.get_windows_screen() try: if key.find("username"): self.assertTrue('Invalid username' in self.initbase.find_element("ERROR_form39b008c_weblogin_username").text) else: self.assertTrue('enter a value' in self.initbase.find_element("ERROR_form39b008c_weblogin_password").text) except Exception as e: logger.error("No error message was printed: %s" %e) def test_wlan_login_pass(self): username="******" password="******" self.initbase = BasePage(self.driver) self.driver.get('https://gia-captiveportal.intel.com/guest/guest_hello_c.php?mac=84:3a:4b:c8:a8:f0&_browser=1') self.initbase.type('s => input#ID_form80308bd3_weblogin_username',username) self.initbase.type('s => input#ID_form80308bd3_weblogin_password',password) js_bottom = "var q=document.documentElement.scrollTop=10000" self.driver.execute_script(js_bottom) time.sleep(1) self.initbase.click('s => input#ID_form80308bd3_weblogin_visitor_accept_terms') self.initbase.click('s => input#ID_form80308bd3_weblogin_submit') self.initbase.get_windows_screen() try: self.assertTrue('Logging in' in self.initbase.find_element("s => div#content-marker > p").text) except Exception as e: logger.error("No logging message was printed: %s" %e) self.initbase.get_windows_screen()
class WlanDisconnect(unittest.TestCase): @classmethod def setUpClass(cls): browser = BrowserEngine(cls) cls.driver = browser.open_browser(cls) @classmethod def tearDownClass(cls): cls.driver.close() def test_wlan(self): self.initbase = BasePage(self.driver) self.initbase.click("l => 新闻") try: self.assertTrue("热点要闻" in self.initbase.find_element( 's => a[data-control="pane-news"]').text) except Exception as e: logger.error("Fail to connect wlan: %s" % e) self.initbase.get_windows_screen() #Please update Wi-Fi by local name def test_wlan_Disconnect(self): self.initbase = BasePage(self.driver) subprocess.check_call("netsh interface set interface Wi-Fi disabled", shell=True) self.driver.get("https://wwww.baidu.com") try: self.assertTrue("No internet" in self.initbase.find_element( 's => span[jsselect = "heading"]').text) except Exception as e: logger.error("Fail to disconnect wlan: %s" % e) self.initbase.get_windows_screen() finally: subprocess.check_call( "netsh interface set interface Wi-Fi enabled", shell=True) time.sleep(10)