Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
 def test_case_run(self):
     basepage = BasePage(self.driver)
     ts = TestSuites()
     #excel表内关键字列表 [('type', 'id=>kw', '输入搜索'), (), ()]
     action_list = KeyCases().key_case_list_all()
     test_step_dict = TestSteps().do_teststep_id()
     
     print action_list
     for i in range(len(action_list)):
         if action_list[i][0] == 'type':
             basepage.type(action_list[i][1], 'selenium')
             time.sleep(3)
             print 'selenium %d' %i
             print action_list[i][2]
             x = int(ts.get_key(test_step_dict, action_list[i][2]))
             print 'x:',x
             rb = open_workbook(r"D:\je_workspace\PythonCase\src\excel\testcase.xls")
             wb = copy(rb)
             sheet = wb.get_sheet(3)
             sheet.write(x+1, 5, 'pass')
             os.remove(r"D:\je_workspace\PythonCase\src\excel\testcase.xls")
             wb.save(r"D:\je_workspace\PythonCase\src\excel\testcase.xls")
             time.sleep(3)
             
             
             
             
             
         elif action_list[i][0] == 'search': 
             basepage.click(action_list[i][1])
             time.sleep(3) 
             print 'search'
             x = int(ts.get_key(test_step_dict, action_list[i][2]))
             print 'x:',x
             rb = open_workbook(r"D:\je_workspace\PythonCase\src\excel\testcase.xls")
             wb = copy(rb)
             sheet = wb.get_sheet(3)
             sheet.write(x+1, 5, 'pass')
             os.remove(r"D:\je_workspace\PythonCase\src\excel\testcase.xls")
             wb.save(r"D:\je_workspace\PythonCase\src\excel\testcase.xls")
             time.sleep(3)
             
         else:
             raise NameError ('invalid method')      
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)
Ejemplo n.º 5
0
from selenium import webdriver
from framework.base_page import BasePage
from logs.log import log1

driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
s = driver.window_handles

kw = ('id', 'kw')

base_driver = BasePage(driver)
base_driver.send(kw, 'selenium+python')
base_driver.framework_sleep(2)

su = ('id', 'su')
base_driver.click(su)
base_driver.get_img()
base_driver.framework_sleep(3)

log1.info(base_driver.get_title())

base_driver.framework_quit()
Ejemplo n.º 6
0
from selenium import webdriver
from framework.base_page import BasePage
import time


driver = BasePage("driver")
driver.wait(10)
driver.get("http://testhotel.hblckj.cn/login.html")
driver.send_keys("xpath=/html/body/div[2]/div[2]/form/div[1]/input","18640857881")
driver.send_keys("xpath=/html/body/div[2]/div[2]/form/div[2]/input","jt123456")
driver.click("xpath=/html/body/div[2]/div[2]/form/div[4]/div/a")
driver.wait(5)

driver.set_window_size(600,600)
# driver.sleep(3)
driver.max_window()
driver.get_window_img()
driver.clear("xpath=/html/body/div[3]/div/div[1]/div[2]/form/div[1]/input")

driver.right_click("xpath=/html/body/div[3]/div/div[1]/div[2]/form/div[1]/input")

driver.move_to_element("xpath=/html/body/div[1]/div/ul/li[1]/a")

driver.back()

driver.forward()

driver.get_attribute("xpath=/html/body/div[3]/div/div[1]/div[2]/form/div[5]/button","type")

driver.get_text("xpath=/html/body/div[3]/div/div[1]/div[2]/form/div[5]/button")
Ejemplo n.º 7
0
from selenium import webdriver
from framework.base_page import  BasePage

driver = webdriver.Chrome()
driver.get("https://www.baidu.com")

s = driver.window_handles

b_driver = BasePage(driver)
kw = ('id','kw')

b_driver.send(kw,'富璟科技')
b_driver.framework_sleep(3)
b_driver.send(kw,"凯捷中国")

su = ('id','su')

b_driver.click(su)
b_driver.get_img()
b_driver.framework_sleep(2)
b_driver.framework_quit()