Exemplo n.º 1
0
 def test01_booksStart(self):
     '''总账初始操作'''
     try:
         # 点击总账初始
         self.driver.find_element_by_xpath(
             "/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div/div/ul/li[7]/div/div/div/span").click()
         time.sleep(1)
         # 点击科目初始(政府)
         self.driver.find_element_by_xpath(
             "/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div/div/ul/li[7]/ul/li[2]/div/div/div/div[1]/span").click()
         # 点击会计科目(1001 ceshi现金)
         self.driver.find_element_by_xpath(
             "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div[1]/div/div[1]/div/div/div[2]/div[1]/div[2]/div[1]/div[2]/div[1]/div[2]/div[1]/div/span[3]").click()
         # 点击试算平衡
         self.driver.find_element_by_xpath(
             "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/ul/li[2]/span/button").click()
         time.sleep(1)
         # 点击取消
         self.driver.find_element_by_xpath("/html/body/div[87]/div[2]/div/div/div[3]/div/button[1]").click()
         # 点击导出
         # self.driver.find_element_by_xpath("/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/ul/li[6]/span/button").click()
         # 点击导入,再点击确定
         # self.driver.find_element_by_xpath("/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/ul/li[5]/span/button").click()
         # self.driver.find_element_by_xpath("/html/body/div[107]/div[2]/div/div/div/div/div[3]/button[2]/span").click()
         time.sleep(3)
     except Exception as e:
         print('错误信息:{}'.format(e))
         BasePage.takeScreenshot(self, '总账初始异常')
Exemplo n.º 2
0
    def test_1_sysManageOperate(self):
        '''统管理操作'''
        try:
            LoginPage.login(self, 'admin', 'admin')  #登录方法
            #点击系统管理下拉框
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div/div/ul/li[3]/div/i"
            ).click()
            time.sleep(2)
            #点击组织机构管理模块
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div/div/ul/li[3]/ul/li[1]/div/div/div/div[1]/span"
            ).click()
            #点击行政组织创建行政组织
            yuansu = WebDriverWait(self.driver, 10).until(
                EC.presence_of_element_located(
                    (By.XPATH,
                     '//*[@id="orgTree"]/div[1]/div[2]/div[7]/div/span[2]/span'
                     )))
            yuansu.click()  #选择行政组织
            self.driver.implicitly_wait(10)
            #点击“新建下级”
            self.driver.find_element_by_css_selector(
                "div:nth-child(1) > .va-toolbar-item > span").click()
            self.driver.implicitly_wait(10)
            seeds = string.digits
            random_str = random.choices(seeds, k=4)
            suiji = "".join(random_str)
            jigoudaima = '0' + suiji
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div[2]/div/div/div[3]/div/div/form/div/div[2]/div[1]/div/div/div[1]/input"
            ).send_keys(jigoudaima)
            time.sleep(2)
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div[2]/div/div/div[3]/div/div/form/div/div[2]/div[2]/div/div/div[1]/input"
            ).send_keys('测试' + str(random.randint(1, 10)))
            time.sleep(3)
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div[2]/div/div/div[3]/div/div/form/div/div[3]/div/div/div/div[1]/input"
            ).send_keys("ceshi02")
            time.sleep(3)
            self.driver.find_element_by_css_selector(
                "div:nth-child(4) > .va-toolbar-item > span").click()  #保存
            self.driver.implicitly_wait(10)

            self.driver.find_element_by_css_selector(
                "div:nth-child(5) > .va-toolbar-item > span").click()  #删除
            time.sleep(2)
            self.driver.find_element_by_xpath(
                '//input[contains(@placeholder,机构代码)]').send_keys(jigoudaima)
            self.driver.find_element_by_css_selector(
                ".vertical-center-modal .ivu-btn-primary > span").click()
            time.sleep(2)

        except Exception as e:
            print('错误信息:{}'.format(e))
            # self.test_name = sys._getframe().f_code.co_name  # 获取当前调用函数的名字
            BasePage.takeScreenshot(self, '系统管理操作异常')
Exemplo n.º 3
0
 def test_swipe(self):
     '''事件列表的滑动用例'''
     shijian = news(self.driver)
     screen = BasePage(self.driver)
     #进入事件列表
     shijian.classify()
     #向上滑动两次
     swipe_up(self, 2)
     screen.get_screen_shot()
 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()
Exemplo n.º 5
0
 def setUp(self):
     # 驱动浏览器
     self.driver = self.select.selectBrowser(self.browserName)
     #隐士等待10秒钟
     self.driver.implicitly_wait(10)
     #浏览器最大化
     self.driver.maximize_window()
     #打开被测网址
     base = BasePage(self.driver)
     base.open(self.url)
Exemplo n.º 6
0
    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()
Exemplo n.º 7
0
    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()
Exemplo n.º 8
0
    def test04_evdenceJoumal(self):
        '''序时账操作'''
        try:
            # 点击凭证
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div/div/ul/li[8]/div"
            ).click()
            # 点击序时账
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div/div/ul/li[8]/ul/li[4]/div/div/div/div[1]/span"
            ).click()
            time.sleep(3)
            # 日期范围
            # 开始时间
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div/div[3]/div/div/form/div[1]/div[1]/div[2]/div[1]/div[1]/div/input"
            ).click()
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div/div[3]/div/div/form/div[1]/div[1]/div[2]/div[1]/div[2]/div/div/div/div[2]/div/span[5]/em"
            ).click()
            time.sleep(1)
            # 结束时间
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div/div[3]/div/div/form/div[1]/div[1]/div[2]/div[2]/div[1]/div/input"
            ).click()
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div/div[3]/div/div/form/div[1]/div[1]/div[2]/div[2]/div[2]/div/div/div/div[1]/span[5]/i"
            ).click()
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div/div[3]/div/div/form/div[1]/div[1]/div[2]/div[2]/div[2]/div/div/div/div[2]/div/span[12]/em"
            ).click()
            time.sleep(1)
            # 输入摘要搜索条件
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div/div[3]/div/div/form/div[1]/div[2]/div[2]/div/input"
            ).send_keys("差旅费")
            time.sleep(2)
            # 点击查询结果按钮
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div/div[3]/div/div/form/div[2]/div[2]/button[1]/span"
            ).click()
            time.sleep(3)
            # 保存为方案
            #self.driver.find_element_by_xpath("/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div/div[3]/div/div/form/div[2]/div[2]/button[2]/span").click()
            # 清空
            #self.driver.find_element_by_xpath("/html/body/div[86]/div[2]/div/div/div[2]/form/div/div/div/input").clear()
            #self.driver.find_element_by_xpath("/html/body/div[86]/div[2]/div/div/div[2]/form/div/div/div/input").send_keys("序时账测试001")
            # 确认
            #self.driver.find_element_by_xpath("/html/body/div[86]/div[2]/div/div/div[3]/div/button[2]/span").click()

        except Exception as e:
            print('错误信息:{}'.format(e))
            BasePage.takeScreenshot(self, '序时账异常')
Exemplo n.º 9
0
    def test_person_submit_ok(self):  # 个人点击提交
        """
        这里一定要test开头,把测试逻辑代码封装到一个test开头的方法里。
        :return:
         """
        sn = 'T203193B40683'
        orderSn = BasePage.random_32(1)
        amount = 0.01
        shopOrderSn = BasePage.random_32(3)
        Url = "http://api.sunmi.com/api/invoice/app/invoice/1.0/?service=/syncInvoiceOrder&14c4b06b824ec593239362517f538b29=8afe757107b215bb4799880a14b8d4a1&76a2173be6393254e72ffa4d6df1030a=6bf4947b8998e1f9030a719ac3305509"
        r = BasePage.syncInvoiceOrder(amount, sn, shopOrderSn, orderSn, Url)

        input = Cloud(self.driver)  # input变量可以调用Cloud得方法
        url = "http://invoice.sunmi.com/?orderSn=" + orderSn
        input.open(url)
        time.sleep(2)
        # 获取url
        nowurl = input.Get_url()
        if nowurl == "http://invoice.sunmi.com/?orderSn=" + orderSn:
            # 切换到个人开票
            input.click(
                'xpath',
                '//*[@id="root"]/div/div/div[2]/div/div/div[1]/div/div/div/div/div[1]/div[1]'
            )
            # 点击邮件输入框,输入邮件地址
            input.send_keys(
                'xpath',
                '//div[3]/div[1]/div[2]/form/div[2]/div/div/span/span/input',
                '*****@*****.**')
            # 点击提交
            input.click('xpath',
                        '//form/div[4]/div/div/span/button')  #pageobjects包内的方法
            a = input.Get_text('xpath',
                               '//*[@id="root"]/div/div/div/div/div/p')

            try:
                assert a in ('开票已完成', '开票申请已提交')
                print(' Test Pass.')
            except Exception as e:
                input.get_windows_img()  # 调用基类截图方法
                print('Test Fail.', format(e))
        else:
            # 捕获当前文本
            a = input.Get_text('xpath',
                               '//*[@id="root"]/div/div/div/div/div/p')
            try:
                assert a in ('开票申请已提交')
                print(' Test Pass.')
            except Exception as e:
                input.get_windows_img()  # 调用基类截图方法
                print('Test Fail.', format(e))
Exemplo n.º 10
0
    def test03_evdenceCollect(self):
        '''凭证汇总操作'''
        try:

            # 点击凭证
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div/div/ul/li[8]/div"
            ).click()
            # 点击凭证汇总
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div/div/ul/li[8]/ul/li[3]/div/div/div/div[1]/span"
            ).click()
            time.sleep(3)
            # 凭证字选择
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div[2]/div/div[3]/div/div/form/div/div[2]/div/div/div[1]/div/i"
            ).click()
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div[2]/div/div[3]/div/div/form/div/div[2]/div/div/div[2]/ul[2]/li[2]"
            ).click()
            # 点击查询结果
            time.sleep(1)
            #self.driver.find_element_by_xpath("/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div[2]/div/div[3]/div/div/div/button[1]/span").click()
            #self.driver.find_element_by_xpath("/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div[2]/div/div[3]/div/div/div/button[1]/span").click()
            #time.sleep(3)
            # 保存为方案
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div[2]/div/div[3]/div/div/div/button[2]/span"
            ).click()
            self.driver.find_element_by_xpath(
                "/html/body/div[1]/div[2]/div[2]/div[2]/div/div/div/div/div/div/div[2]/div/div[3]/div/div/div/button[2]/span"
            ).click()
            # 清空方案名称输入框
            self.driver.find_element_by_xpath(
                "/html/body/div[94]/div[2]/div/div/div[2]/form/div/div/div/input"
            ).clear()
            # 填写新的方案名称
            self.driver.find_element_by_xpath(
                "/html/body/div[94]/div[2]/div/div/div[2]/form/div/div/div/input"
            ).send_keys("测试方案123")
            # 点击确认
            self.driver.find_element_by_xpath(
                "/html/body/div[94]/div[2]/div/div/div[3]/div/button[2]/span"
            ).click()
            time.sleep(2)
        #点击取消
        #self.driver.find_element_by_xpath("/html/body/div[94]/div[2]/div/div/div[3]/div/button[1]/span").click()

        except Exception as e:
            print('错误信息:{}'.format(e))
            BasePage.takeScreenshot(self, '凭证汇总异常')
Exemplo n.º 11
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()
Exemplo n.º 12
0
    def test_login_author_dy(self):
        '''专栏作家的订阅测试用例'''
        # 进入专栏作家详情页
        zl.zuojia_icon()
        # 点击订阅
        zl_author.dy_button()
        # 断言
        Text = self.driver.find_element_by_id(
            'com.gelonghui.glhapp:id/btn_subscribe')
        text = Text.text
        self.assertEqual('已订阅', text)

        screen = BasePage(self.driver)
        screen.get_screen_shot()
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
 def test_login_shoucang(self):
     '''专栏文章收藏'''
     # 进入专栏文章详情页
     zl.zl_details()
     # 点击收藏按钮
     text_shoucang01 = self.driver.find_element_by_id(
         'com.gelonghui.glhapp:id/tv_rd_fav_num').text
     zl.shoucang()
     screen = BasePage(self.driver)
     screen.get_screen_shot()
     # 断言
     Text = self.driver.find_element_by_id(
         'com.gelonghui.glhapp:id/tv_main_title')
     text_shoucang02 = Text.text
     self.assertEqual(text_shoucang01 + 1, text_shoucang02)
Exemplo n.º 15
0
 def log_out(self):
     self.driver.find_element_by_xpath(
         '//*[@id="topFrame"]/ul/li[4]/a/i').click()
     time.sleep(1)
     self.driver.find_element_by_xpath(
         '/html/body/div[6]/div[2]/div[2]/button[2]').click()
     time.sleep(1)
     txt = self.driver.find_element_by_xpath(
         '/html/body/div[1]/div/div/div/form/div/div[2]/a').text
     logoutpage = BasePage(self.driver)
     try:
         assert "修改密码" in txt
         logger.info("登出成功。")
     except Exception as e:
         logger.error("登出失败。", e)
         logoutpage.get_windows_img()  # 调用基类截图方法
Exemplo n.º 16
0
 def test_login_like(self):
     '''专栏文章点赞'''
     # 进入专栏文章详情页
     zl.zl_details()
     text_like01 = self.driver.find_element_by_id(
         'com.gelonghui.glhapp:id/tv_rd_like_num').text
     # 点击爱心按钮
     zl.like()
     screen = BasePage(self.driver)
     screen.get_screen_shot()
     # 断言
     Text = self.driver.find_element_by_id(
         'com.gelonghui.glhapp:id/tv_rd_like_num')
     text_like02 = Text.text
     #断言点赞成功,数量+1
     self.assertEqual(text_like01 + 1, text_like02)
Exemplo n.º 17
0
 def test_login_dingyue(self):
     '''专栏订阅测试用例'''
     # 进入专栏详情页
     zl.zl_details()
     # 点击订阅按钮
     zl.dingyue()
     # 未登录去登录
     android_login.login_text('17512064966', '995217')
     #订阅
     zl.dingyue()
     time.sleep(1)
     screen = BasePage(self.driver)
     screen.get_screen_shot()
     text_dingyue = self.driver.find_element_by_id(
         'com.gelonghui.glhapp:id/btn_subscribe').text
     self.assertEqual('已订阅', text_dingyue)
Exemplo n.º 18
0
 def get_pictures(self, selector):
     file_path = os.path.dirname(os.path.abspath('.')) + '/screenshots/'
     page = BasePage(self.driver)
     page.get_code_img()
     page_snap_obj = Image.open(file_path + 'code.png')
     img = page.find_element(selector)  # 验证码元素位置
     time.sleep(1)
     location = img.location
     size = img.size  # 获取验证码的大小参数
     left = location['x']
     top = location['y']
     right = left + size['width']
     bottom = top + size['height']
     image_obj = page_snap_obj.crop(
         (left, top, right, bottom))  # 按照验证码的长宽,切割验证码
     # image_obj.show()  # 打开切割后的完整验证码
     return image_obj
Exemplo n.º 19
0
 def test02_booksusing(self):
     '''总账启用'''
     try:
         #点击总账初始
         self.driver.find_element_by_xpath("/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div/div/ul/li[7]/div/div/div/span").click()
         #点击总账启用
         self.driver.find_element_by_xpath(
             "/html/body/div[1]/div[2]/div[1]/div/div[2]/div/div/div/ul/li[7]/ul/li[1]/div/div/div/div[1]/span").click()
         # 点击下一步到试算平衡
         self.driver.find_element_by_xpath("/html/body/div[107]/div[2]/div/div/div[3]/div/button/span").click()
         # 点击下一步到启用成功
         self.driver.find_element_by_xpath("/html/body/div[107]/div[2]/div/div/div[3]/div/button[3]/span").click()
         # 点击关闭,总账启用窗口关闭
         self.driver.find_element_by_xpath("/html/body/div[107]/div[2]/div/div/div[3]/div/button/span").click()
     except Exception as e:
         print('错误信息:{}'.format(e))
         BasePage.takeScreenshot(self, '总账启用异常')
Exemplo n.º 20
0
 def test_nologin_comment(self):
     '''专栏文章评论测试用例'''
     # 进入文章详情页
     zl.zl_details()
     # 点击评论按钮
     zl.comment()
     # 输入评论
     zl.send_comment('文章不错')
     # 提交评论
     zl.get_comment()
     time.sleep(1)
     screen = BasePage(self.driver)
     screen.get_screen_shot()
     # 断言
     text = self.driver.find_element_by_id(
         'com.gelonghui.glhapp:id/comment_content').text
     self.assertEqual('文章不错', text)
Exemplo n.º 21
0
 def log_in(self):
     self.driver.find_element_by_xpath('//*[@id="username"]').clear()
     self.driver.find_element_by_xpath('//*[@id="username"]').send_keys('yangfan5')
     self.driver.find_element_by_xpath('//*[@id="password"]').clear()
     self.driver.find_element_by_xpath('//*[@id="password"]').send_keys('ccs.xiangyun')
     self.driver.find_element_by_xpath('//*[@id="authcode"]').clear()
     self.driver.find_element_by_xpath('//*[@id="authcode"]').send_keys('aaaa')
     self.driver.find_element_by_xpath('//input[@name="submit"]').click()
     time.sleep(2)
     name = self.driver.find_element_by_xpath('//*[@id="_userName"]').text
     loginpage = BasePage(self.driver)
     try:
         assert "杨帆" in name
         logger.info("登录成功。")
     except Exception as e:
         logger.info("登录失败。", e)
         loginpage.get_windows_img()  # 调用基类截图方法
Exemplo n.º 22
0
    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()
Exemplo n.º 23
0
    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)
Exemplo n.º 24
0
 def test_return_key(self):
     '''事件详情页返回键用例'''
     details01 = news(self.driver)
     screen = BasePage(self.driver)
     #进入详情页
     details01.list_button()
     screen.get_screen_shot()
     #返回键
     details01.font_button()
     screen.get_screen_shot()
Exemplo n.º 25
0
 def test_font(self):
     '''事件详情页字体放大缩小用例'''
     details02 = news(self.driver)
     screen = BasePage(self.driver)
     # 进入详情页
     details02.list_button()
     #放大
     details02.font_button()
     time.sleep(2)
     screen.get_screen_shot()
     #缩小
     details02.font_button()
     time.sleep(2)
     screen.get_screen_shot()
Exemplo n.º 26
0
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)
Exemplo n.º 27
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')      
Exemplo n.º 28
0
 def test_baidu_search(self):
     """
     这里一定要test开头,把测试逻辑代码封装到一个test开头的方法里。
     :return:
     """
     homepage = Baidu(self.driver)
     ea = BasePage(self.driver)
     homepage.type_search('selenium')  # 调用页面对象中的方法
     ea.wait(10)
     homepage.send_submit_btn()  #调用页面对象类中的点击搜索按钮方法
     ea.wait(10)
     homepage.get_windows_img()
     time.sleep(5)  # 调用基类截图方法
     try:
         assert 'selenium' in homepage.get_page_title(
         )  # 调用页面对象继承基类中的获取页面标题方法
         print('Test Pass.')
     except Exception as e:
         print('Test Fail.', format(e))
Exemplo n.º 29
0
 def test_loginERP(self):
     user = LoginPage(self.driver)
     user.username_input('zhaolisi')
     user.password_input('Zls@8891')
     user.submit_btn()
     loginuser = YiDaoHome(self.driver)
     BasePage.sleep(1)
     loginuser.enter_firstpage()
     BasePage.sleep(1)
     loginuser.enter_ERP()
     BasePage.sleep(1)
     currentwinhandler = self.driver.current_window_handle
     handles = self.driver.window_handles
     for handle in handles:
         if handle != currentwinhandler:
             self.driver.switch_to.window(handle)
     currenturl = user.get_currentpageurl()
     try:
         assert currenturl == 'https://testing.be.yongche.org/'
         print('Test Pass')
     except Exception as e:
         print('Test Fail', format(e))
Exemplo n.º 30
0
 def setUp(self):
     bro = BasePage(self)
     self.driver = bro.open_browser()