class TestBaiDu(unittest.TestCase):
    URL = Config().get('URL')
    print(URL)
    excel = DATA_PATH + '/baidu.xlsx'

    def sub_setUp(self):
        # 初始页面是main page,传入浏览器类型打开浏览器
        self.page = BaiDuMainPage(browser_type='chrome').get(
            self.URL, maximize_window=False)

    def sub_tearDown(self):
        self.page.quit()

    def test_search(self):
        datas = ExcelReader(self.excel).data
        for d in datas:
            with self.subTest(data=d):
                self.sub_setUp()
                self.page.search(d['search'])
                time.sleep(2)
                self.page = BaiDuResultPage(self.page)  # 页面跳转到result page
                links = self.page.result_links
                for link in links:
                    logger.info(link.text)
                self.sub_tearDown()
Beispiel #2
0
class TestBaiDu(unittest.TestCase):
    URL = Config().get('URL')
    excel = DATA_PATH + '/baidu.xlsx'

    locator_kw = (By.ID, 'kw')
    locator_su = (By.ID, 'su')
    locator_result = (By.XPATH, '//div[contains(@class, "result")]/h3/a')

    def sub_setUp(self):
        self.page = BaiDuMainPage(browser_type='chrome').get(
            self.URL, maximize_window=True)

    def sub_tearDown(self):
        self.page.quit()

    def test_search(self):
        datas = ExcelReader(self.excel).data
        print(datas)
        for d in datas:
            with self.subTest(data=d):
                self.sub_setUp()
                self.page.search(d["search"])
                time.sleep(3)
                self.page = BaiDuResultPage(self.page)
                links = self.page.result_links
                for link in links:
                    logger.info(link.text)
                self.sub_tearDown()
Beispiel #3
0
 def test_search(self):
     datas = ExcelReader(self.excel).data
     for d in datas:
         with self.subTest(data=d):
             self.sub_setUp()
             self.page.search(d['search'])
             time.sleep(2)
             self.page = BaiDuResultPage(self.page)  # 页面跳转到result page
             links = self.page.result_links
             for link in links:
                 logger.info(link.text)
             self.sub_tearDown()
Beispiel #4
0
 def test_search(self):
     datas = ExcelReader(self.excel).data
     print(datas)
     for d in datas:
         with self.subTest(data=d):
             self.sub_setUp()
             self.page.search(d["search"])
             time.sleep(3)
             self.page = BaiDuResultPage(self.page)
             links = self.page.result_links
             for link in links:
                 logger.info(link.text)
             self.sub_tearDown()
    def test_search(self):
        '''对小心走火、小坦克、jianhao_he执行百度搜索操作'''
        datas = ExcelReader(excel=self.excel).data

        for d in datas:
            print(d)
            with self.subTest(data=d):
                self.sub_setUp()
                self.page.search(d['A'])
                self.page = BaiDuResultPage(self.page)
                links = self.page.result
                for link in links:
                    logger.info(link.text)
                self.sub_tearDown()
Beispiel #6
0
    def test_search(self):
        datas = ExcelReader(self.excel).data
        for d in datas:
            with self.subTest(data=d):
                self.sub_setUp()
                self.page.search(d['search'])
                time.sleep(2)
                self.page = BaiDuResultPage(self.page)  # 页面跳转到result page
                links = self.page.result_links
                for link in links:
                    logger.info(link.text)
                self.sub_tearDown()


# if __name__ == '__main__':
#     #unittest.main()
#
#     report = REPORT_PATH + '\\report.html'
#     print(report)
#     with open(report, 'wb') as f:
#         runner = HTMLTestRunner(f, verbosity=2, title='栾鹏全栈', description='修改html报告')
#         runner.run(TestBaiDu('test_search'))

# e = Email(title='百度搜索测试报告',
#           message='这是今天的测试报告,请查收!',
#           receiver='...',
#           server='...',
#           sender='...',
#           password='******',
#           path=report
#           )
# e.send()
Beispiel #7
0
class TestBaiDu(unittest.TestCase):

    URL = Config().get('URL')
    excel = DATA_PATH + 'test.xlsx'

    def sup_setUp(self):
        self.page = BaiDuMainPage(browser_type='chrome').get(
            self.URL, maximize_window=False)

    def sub_tearDown(self):
        self.driver.quit()

    # def test_search_0(self):
    # 	self.driver.find_element(*self.locator_kw).send_keys('selenium')
    # 	self.driver.find_element(*self.locator_su).click()
    # 	time.sleep(2)

    # 	links = driver.find_elements(*self.locator_result)
    # 	for link in links:
    # 		print(link.text)

    # def test_search_1(self):
    # 	self.driver.find_element(*self.locator_kw).send_keys('Python selenium')
    # 	self.driver.find_element(*self.locator_su).click()
    # 	time.sleep(2)

    # 	links = driver.find_elements(*self.locator_result)
    # 	for link in links:
    # 		print(link.text)

    def test_search(self):
        datas = ExcelReader(self.excel).data
        for d in datas:
            with self.subTest(data=d):
                self.sub_setUP()
                self.page.search(d['search'])
                time.sleep(2)

                self.page = BaiDuResultPage(self.page)  #跳转到reult page

                links = self.page.result_links()
                for link in links:
                    print(link.text)
                self.sub_tearDown()
Beispiel #8
0
 def test_search(self):
     #可以对用例简单说明
     u"""百度搜索"""
     datas = ExcelReader(self.excel).data
     for d in datas:
         with self.subTest(data=d):
             self.sub_setUp()
             self.page.search(d['search'])
             #self.driver.find_element(*self.locator_kw).send_keys(d['search'])
             #self.driver.find_element(*self.locator_su).click()
             #self.driver.implicitly_wait(5)
             time.sleep(2)
             self.page.save_screen_shot('test_baidu')  #调用截图方法
             self.page = BaiDuResultPage(self.page)  #页面跳转到result page
             links = self.page.result_links
             #links = self.driver.find_elements(*self.locator_result)  # ????????
             for link in links:
                 # print(link.text)
                 logger.info(link.text)
             self.sub_tearDown()
Beispiel #9
0
 def test_search(self):
     datas = ExcelReader(self.excel).data
     for d in datas:
         with self.subTest(data=d):
             self.sub_setUp()
             self.page.search(d['search'])
             time.sleep(2)
             self.page = BaiDuResultPage(self.page)  # 页面跳转到result page
             links = self.page.result_links
             for link in links:
                 logger.info(link.text)
             self.sub_tearDown()
Beispiel #10
0
class TestBaiDu(unittest.TestCase):
    URL = Config().get('URL')
    excel = DATA_PATH + '/baidu.xlsx'

    def sub_setUp(self):
        # 初始页面是main page,传入浏览器类型打开浏览器
        self.page = BaiDuMainPage(browser_type='chrome').get(self.URL, maximize_window=False)

    def sub_tearDown(self):
        self.page.quit()

    def test_search(self):
        datas = ExcelReader(self.excel).data
        for d in datas:
            with self.subTest(data=d):
                self.sub_setUp()
                self.page.search(d['search'])
                time.sleep(2)
                self.page = BaiDuResultPage(self.page)  # 页面跳转到result page
                links = self.page.result_links
                for link in links:
                    logger.info(link.text)
                self.sub_tearDown()
Beispiel #11
0
class Testbaidu(unittest.TestCase):
    URL = Config().get('URL')
    excel = DATA_PATH + '/baidu.xlsx'

    def sub_setUp(self):  #self  本身的意思     setup开始的时候先执行   一次
        #初始页面main page,传入浏览器类型打开浏览器
        self.page = BaiDuMainPage(browser_type='chrome').get(self.URL)

    def sub_tearDown(self):  #tesrdown    结束的时候执行一次
        self.page.quit()

    def test_search(self):
        datas = ExcelReader(self.excel).data
        for d in datas:
            with self.subTest(data=d):
                self.sub_setUp()
                self.page.search(d['search'])
                time.sleep(2)
                self.page = BaiDuResultPage(self.page)  #跳转到result page
                links = self.page.result_links
                for link in links:
                    logger.info(link.text)
                self.sub_tearDown()
Beispiel #12
0
class TestBaiDu(unittest.TestCase):
    URL = Config().get('URL')
    excel = os.path.join(DATA_PATH , 'baidu_search.xlsx')

    def sub_setUp(self):
        self.page = BaiDuMainPage(browser_type='chrome').get(self.URL)
    def sub_tearDown(self):
        self.page.quit()

    def test_search(self):
        '''对小心走火、小坦克、jianhao_he执行百度搜索操作'''
        datas = ExcelReader(excel=self.excel).data

        for d in datas:
            print(d)
            with self.subTest(data=d):
                self.sub_setUp()
                self.page.search(d['A'])
                self.page = BaiDuResultPage(self.page)
                links = self.page.result
                for link in links:
                    logger.info(link.text)
                self.sub_tearDown()
Beispiel #13
0
class TestBaiDu(unittest.TestCase):
    #URL = 'https://www.baidu.com/'
    URL = Config().get('URL')
    #base_path = os.path.abspath(os.path.join(os.getcwd(), '..\..'))#获取路径
    #driver_path = os.path.abspath(base_path+'\drivers\geckodriver.exe')

    excel = os.path.join(DATA_PATH, 'baidu.xlsx')
    locator_kw = (By.ID, 'kw')
    locator_su = (By.ID, 'su')
    locator_result = (By.XPATH, '//div[contains(@class, "result")]/h3/a')

    def sub_setUp(self):
        #初始页面是main page,传入浏览器类型打开浏览器
        self.page = BaiDuMainPage(browser_type='chrome').get(
            self.URL, maxmize_windows=False)

        #self.driver = webdriver.Firefox(executable_path=os.path.join(DRIVER_PATH,'geckodriver.exe'))#用框架里的浏览器驱动
        #self.driver.get(self.URL)

    def sub_tearDown(self):
        #self.driver.quit()
        self.page.quit()

    def test_search(self):
        #可以对用例简单说明
        u"""百度搜索"""
        datas = ExcelReader(self.excel).data
        for d in datas:
            with self.subTest(data=d):
                self.sub_setUp()
                self.page.search(d['search'])
                #self.driver.find_element(*self.locator_kw).send_keys(d['search'])
                #self.driver.find_element(*self.locator_su).click()
                #self.driver.implicitly_wait(5)
                time.sleep(2)
                self.page.save_screen_shot('test_baidu')  #调用截图方法
                self.page = BaiDuResultPage(self.page)  #页面跳转到result page
                links = self.page.result_links
                #links = self.driver.find_elements(*self.locator_result)  # ????????
                for link in links:
                    # print(link.text)
                    logger.info(link.text)
                self.sub_tearDown()
Beispiel #14
0
 def sub_setUp(self):
     # 初始页面是main page,传入浏览器类型打开浏览器
     self.page = BaiDuMainPage(browser_type='chrome').get(
         self.URL, maximize_window=False)
Beispiel #15
0
 def sub_setUp(self):  #self  本身的意思     setup开始的时候先执行   一次
     #初始页面main page,传入浏览器类型打开浏览器
     self.page = BaiDuMainPage(browser_type='chrome').get(self.URL)
Beispiel #16
0
 def sup_setUp(self):
     self.page = BaiDuMainPage(browser_type='chrome').get(
         self.URL, maximize_window=False)
Beispiel #17
0
 def sub_setUp(self):  #self  本身的意思     setup开始的时候先执行   一次
     self.page = BaiDuResultPage(browser_type='chrome').get(
         self.URL, maximize_windows=False)
Beispiel #18
0
 def sub_setUp(self):
     self.page = BaiDuMainPage(browser_type='chrome').get(self.URL)
Beispiel #19
0
 def sub_setUp(self):
     # 初始页面是main page,传入浏览器类型打开浏览器
     self.page = BaiDuMainPage(browser_type='chrome').get(self.URL, maximize_window=False)