Esempio n. 1
0
 def teardown_method(self, method):
     test_method_name = self._testMethodName
     with allure.step('保存截图'):
         self.driver.save_screenshot('../TestResult/ScreenShot/%s.png' % test_method_name)
         f = open('../TestResult/ScreenShot/%s.png' % test_method_name, 'rb').read()
         allure.attach('自动化截图', f, allure.attach_type.PNG)
     with allure.step('---End---'):
         self.driver.quit()
Esempio n. 2
0
 def test_get_content_type_or_404(self):
     with allure.step('get'):
         self.assertIsInstance(
             helpers.get_content_type_or_404('contenttypes.contenttype'),
             ContentType
         )
     with allure.step('get None'):
         with self.assertRaises(Http404):
             helpers.get_content_type_or_404('contenttypes.nonexistent')
Esempio n. 3
0
 def test_get_content_type_or_None(self):
     with allure.step('get'):
         self.assertIsInstance(
             helpers.get_content_type_or_None('contenttypes.contenttype'),
             ContentType
         )
     with allure.step('get None'):
         self.assertIsNone(
             helpers.get_content_type_or_None('contenttypes.nonexistent')
         )
Esempio n. 4
0
 def test_order_6(self):
     """产线列表页入口-EAS用户下单-不开票-超过审批额"""
     with allure.step('读取账号配置信息'):
         login_name = self.page.config_reader('test_order.conf', 'EAS账号', 'login_name')
         password = self.page.config_reader('test_order.conf', 'EAS账号', 'password')
         allure.attach('账号信息: ', 'login_name: %s\npassword: %s' % (login_name, password))
     self.home.login(login_name, password)
     self.home.category_tree_click()
     self.product_list.list_add_to_cart()
     for i in range(10):
         try:
             self.cart.element_find(self.cart.quantity_input).send_keys(0)  # 修改数量为10,使其超出审批额1000
             time.sleep(2)
             break
         except StaleElementReferenceException:
             continue
     self.cart.element_find(self.cart.go_to_order).click()
     self.order.choose_none_invoice()
     self.order.submit_order_eas(none_invoice=True)
     for i in range(30):
         try:
             message = self.order_result.element_find(self.order_result.eas_message).text
             assert message == '您已成功提交请购单,等待审批结果!'
             break
         except AssertionError:
             continue
Esempio n. 5
0
 def test_get_content_type(self):
     ct = ContentType.objects.latest('pk')
     with allure.step('with basestring'):
         self.assertIsInstance(
             helpers.get_content_type('contenttypes.contenttype'),
             ContentType
         )
     with allure.step('with instance'):
         self.assertIsInstance(
             helpers.get_content_type(ct),
             ContentType
         )
     with allure.step('with model class'):
         self.assertIsInstance(
             helpers.get_content_type(ContentType),
             ContentType
         )
Esempio n. 6
0
 def get_so_by_url(self):
     with allure.step('通过URL获取SO单号'):
         order_id = ''
         while not order_id.startswith('SO'):
             url = self.driver.current_url
             order_id = url[-20:]
         print(order_id)
         return order_id
Esempio n. 7
0
 def compare_db_and_table(self, collection):
     page_data = self.get_data_from_table()
     db_data = self.get_data_from_db(collection)
     result = self.compare_values(page_data, db_data)
     if result["deleted"]:
         allure.step(
             "Удалены строки: collumn={deleted_name}, count={deleted_count}, price={deleted_price}".format(
                 result["deleted"][0]["name"], result["deleted"][0]["count"], result["deleted"][0]["price"]
             )
         )
     if result["added"]:
         allure.step(
             "Добавлены строки: collumn={added_name}, count={added_count}, price={added_price}".format(
                 added_name=result["added"][0]["name"],
                 added_count=result["added"][0]["count"],
                 added_price=result["added"][0]["price"],
             )
         )
Esempio n. 8
0
 def login(self, login_name, password):
     with allure.step('登陆'):
         self.element_find(self.login_button).click()
         time.sleep(1)
         self.driver.switch_to_frame(self.frame)
         self.element_find(self.username_send).send_keys(login_name)
         self.element_find(self.password_send).send_keys(password)
         self.element_find(self.login_action).click()
         self.driver.switch_to_default_content
Esempio n. 9
0
 def cancel_order(orderId, environment='staging', userId='508107841'):
     with allure.step('接口取消订单'):
         if environment == 'staging':
             url = 'http://oc-staging.ehsy.com/orderCenter/cancel'
         elif environment == 'production':
             url = 'http://oc.ehsy.com/orderCenter/cancel'
         data = {'orderId': orderId, 'userId': userId}
         r = requests.post(url, data=data)
         result = r.json()
         print(result['message'])
         assert result['message'] == '订单取消申请提交成功'
Esempio n. 10
0
def test_profile_ptrn_for_logged_in_user(chromedriver, test_page):
    """
     As logged in to linkedin user I open some user profiles in browser.
     Get actual data from result is captured by extension.
     Read expected results that should be present on the test page from patterns/data/linkedin/profile_page*.ini
     And check if expected data from the page is present within the captured results.
    """
    handler = pattern_handler
    test_page = '..' + config.linkedin_test_data + test_page
    linkidin = authorization.LinkidinAuthPage(chromedriver, test_page, 'project')
    linkidin.login(linkidin.sign_in_link, linkidin.login_form, linkidin.default_user)
    linkidin.open(config.read_options_for('linkedin', test_page))
    time.sleep(3)
    with allure.step('Read expected result from profile page'):
        expected = config.read_expected_results_from_file(test_page, 'profile after log in')
    with allure.step('Read attributes from result is captured by extension'):
        actual = handler.get_actual_data_from_js_console(chromedriver)
    print actual
    with allure.step('Check if captured results contain data expected data'):
        assert comparator.is_pattern_data_according_to_page(actual, expected),\
                 "Incorrect data was found in captured results. See mismatches in attached detailes."
Esempio n. 11
0
 def go_my_collection(self):
     with allure.step('进入个人中心-我的收藏'):
         element = self.element_find(self.my_ehsy)
         ActionChains(self.driver).move_to_element(element).perform()
         for i in range(10):
             try:
                 self.element_find(self.my_collection).click()
                 break
             except ElementNotVisibleException:
                 continue
             except WebDriverException:
                 continue
Esempio n. 12
0
def test_profile_ptrn_without_log_in(chromedriver, test_page):
    """
    SHOULD BE USED ONLY FOR UKRAINE AND SOME OTHER COUNTRIES. THIS TEST CASE IS NOT reproducible for American variant of Linkedin.
     As user that is not logged in to linkedin I open some user profiles in browser.
     Get actual data from result is captured by extension.
     Read expected results that should be present on the test page from patterns/data/linkedin/profile_page*.ini
     And check if expected data from the page is present within the captured results.
    """
    handler = pattern_handler
    test_page = '..' + config.linkedin_test_data + test_page
    linkidin = authorization.LinkidinAuthPage(chromedriver)
    linkidin.logout()
    linkidin.open(config.read_options_for('linkedin', test_page))
    time.sleep(3)
    with allure.step('Read expected result from profile page'):
        expected = config.read_expected_results_from_file(test_page, 'profile without log in')
    with allure.step('Read attributes from result is captured by extension'):
        actual = handler.get_actual_data_from_js_console(chromedriver)
        print actual
    with allure.step('Check if captured results contain data expected data'):
        assert comparator.is_pattern_data_according_to_page(actual, expected),\
                 "Incorrect data was found in captured results. See mismatches in attached detailes."
Esempio n. 13
0
def test_profile_ptrn_by_logged_in_user(chromedriver,profile):
    """
     As logged in to linkedin user I open some user profile in browser.
     Read data from the opened page via WEBDRIVER .
     Get data from result is captured by extension.
     And check if data from the page is present within the captured results.
     Tested attributes:
     {
         "bio" - summary,
         "full" - users fullname,
         "company" - current company name,
         "first" - firstname,
         "last" - lastname,
         "city" - locality,
         "jobtitle" - job,
         "linkedin" - link from the contact info,
         "twitter" - link from the contact info,
         "email" - address from the contact info
     }
     """  # initialization
    profile = '..' + config.linkedin_test_data + profile
    handler = pattern_handler
    linkidin = authorization.LinkidinAuthPage(chromedriver)
    test_page = linkidin_profile.LinkidinProfilePage(chromedriver, is_logged=True)
    # login by test user
    linkidin.login(linkidin.sign_in_link, linkidin.login_form, linkidin.default_user)
    # Open test page and get parsed data by Webdriver as expected results
    test_page.open(config.read_options_for('linkedin', test_page, 'project'))
    with allure.step('Read attributes from profile page'):
        expected = config.read_expected_results_from_file(profile, 'profile_after_log_in')
        expected_wd = test_page.parse_text()
    # read actual data from captured results
    with allure.step('Read attributes from result is captured by extension'):
        actual = handler.get_actual_data_from_js_console(chromedriver)
        print actual
    with allure.step('Check if captured results contain data from page'):
        assert comparator.is_pattern_data_according_to_page(actual, expected),\
            "Incorrect data was found in captured results. See mismatches in attached detailes."
Esempio n. 14
0
 def create_order_by_report_order(self):
     with allure.step('创建报价单-报价单转订单'):
         self.element_find(self.report_order_title).send_keys('测试报价单')
         self.element_find(self.report_order_province).send_keys('北京市')
         self.element_find(self.report_order_city).send_keys('北京市')
         self.element_find(self.report_order_invoice).click()
         self.element_find(self.report_order_price).click()
         self.element_find(self.create_report_order).click()
         for i in range(10):
             try:
                 self.element_find(self.report_order_change_to_order).click()
                 break
             except StaleElementReferenceException:
                 continue
Esempio n. 15
0
 def test_login_by_email_failure(self):
     """
     test email login failure flow
     """
     with allure.step('setup environment'):
         user = User.objects.get(email=self.email_login['username'])
         url = reverse('accounts:login')
     with allure.step('check'):
         response = self.client.get(url, follow=True)
         self.assertEqual(response.status_code, 200)
         context = response.context
         self.assertEqual(context['user'].is_authenticated(), False)
     with allure.step('login'):
         # login
         response = self.client.post(
             url,
             {'username': '******', 'password': '******'},
             follow=True
         )
         self.assertEqual(response.status_code, 200)
         context = response.context
         self.assertEqual(context['user'].is_authenticated(), False)
         self.assertNotEqual(context['user'], user)
Esempio n. 16
0
 def test_order_3(self):
     """品牌页入口-分销用户下单-增票"""
     with allure.step('读取账号配置信息'):
         login_name = self.page.config_reader('test_order.conf', '分销账号', 'login_name')
         password = self.page.config_reader('test_order.conf', '分销账号', 'password')
         allure.attach('账号信息: ', 'login_name: %s\npassword: %s' % (login_name, password))
     self.home.login(login_name, password)
     self.home.brand_click()
     self.product_list.brand_add_to_cart()
     self.cart.element_find(self.cart.go_to_order).click()
     self.order.choose_vat_invoice()
     self.order.submit_order()
     orderId = self.order_result.get_order_id()
     self.page.cancel_order(orderId, environment=self.environment)  # 接口取消订单
Esempio n. 17
0
 def test_order_4(self):
     """产线列表页入口-终端用户下单-普票"""
     with allure.step('读取账号配置信息'):
         login_name = self.page.config_reader('test_order.conf', '终端账号', 'login_name')
         password = self.page.config_reader('test_order.conf', '终端账号', 'password')
         allure.attach('账号信息: ', 'login_name: %s\npassword: %s' % (login_name, password))
     self.home.login(login_name, password)
     self.home.category_tree_click()
     self.product_list.list_add_to_cart()
     self.cart.element_find(self.cart.go_to_order).click()
     self.order.choose_normal_invoice()
     self.order.submit_order(account_period=True)
     orderId = self.order_result.get_so_by_url()
     self.page.cancel_order(orderId, environment=self.environment)  # 接口取消订单
Esempio n. 18
0
 def test_order_1(self):
     """产线大图页入口-个人用户下单-不开票"""
     with allure.step('读取账号配置信息'):
         login_name = self.page.config_reader('test_order.conf', '个人账号', 'login_name')
         password = self.page.config_reader('test_order.conf', '个人账号', 'password')
         allure.attach('账号信息: ', 'login_name: %s\npassword: %s' % (login_name, password))
     self.home.login(login_name, password)
     self.home.category_tree_click()
     self.product_list.bigImg_add_to_cart()
     self.cart.element_find(self.cart.go_to_order).click()
     self.order.choose_none_invoice()
     self.order.submit_order(none_invoice=True)
     orderId = self.order_result.get_order_id()
     self.page.cancel_order(orderId, environment=self.environment)  # 接口取消订单
Esempio n. 19
0
 def test_order_5(self):
     """产品详情页入口-终端用户下单-增票"""
     with allure.step('读取账号配置信息'):
         login_name = self.page.config_reader('test_order.conf', '终端账号', 'login_name')
         password = self.page.config_reader('test_order.conf', '终端账号', 'password')
         allure.attach('账号信息: ', 'login_name: %s\npassword: %s' % (login_name, password))
     self.home.login(login_name, password)
     self.home.search_sku()
     self.product_list.element_find(self.product_list.sku_result_click).click()
     self.page.switch_to_new_window()
     self.product_list.element_find(self.product_list.skuContent_add_button).click()
     self.product_list.element_find(self.product_list.skuContent_jump_to_cart).click()
     self.cart.element_find(self.cart.go_to_order).click()
     self.order.choose_vat_invoice()
     self.order.submit_order(account_period=True)
     orderId = self.order_result.get_so_by_url()
     self.page.cancel_order(orderId, environment=self.environment)  # 接口取消订单
Esempio n. 20
0
 def setup_method(self, method):
     with allure.step('---Start---'):
         self.driver = webdriver.Chrome()
         self.page = Page(self.driver)
         self.environment = self.page.config_reader('environment.conf', 'Environment', 'environment')
         if self.environment == 'staging':
             self.url = 'http://www-staging.ehsy.com'
             self.driver.get(self.url)
         else:
             self.url = 'http://purchase.ehsy.com'
             self.driver.get(self.url)
         self.driver.implicitly_wait(30)
         self.driver.maximize_window()
         self.cart = Cart(self.driver)
         self.home = Home(self.driver)
         self.order = Order(self.driver)
         self.order_result = OrderResult(self.driver)
         self.product_list = ProductList(self.driver)
         self.quick_order = QuickOrder(self.driver)
         self.report_order = ReportOrder(self.driver)
         allure.attach('初始化参数:', 'environment: ' + self.environment + '\nurl: ' + self.url + '\n')
Esempio n. 21
0
 def test_order_7(self):
     """产品详情页入口-EAS用户下单-增票-不超过审批额"""
     with allure.step('读取账号配置信息'):
         login_name = self.page.config_reader('test_order.conf', 'EAS账号', 'login_name')
         password = self.page.config_reader('test_order.conf', 'EAS账号', 'password')
         allure.attach('账号信息: ', 'login_name: %s\npassword: %s' % (login_name, password))
     self.home.login(login_name, password)
     self.home.search_sku()
     self.product_list.element_find(self.product_list.sku_result_click).click()
     self.page.switch_to_new_window()
     self.product_list.element_find(self.product_list.skuContent_add_button).click()
     self.product_list.element_find(self.product_list.skuContent_jump_to_cart).click()
     self.cart.element_find(self.cart.go_to_order).click()
     self.order.choose_vat_invoice()
     self.order.submit_order_eas()
     for i in range(10):
         try:
             orderId = self.order_result.get_order_id()
             break
         except NoSuchElementException:
             continue
     self.page.cancel_order(orderId, environment=self.environment)  # 接口取消订单
Esempio n. 22
0
 def test_order_8(self):
     """产品详情页入口-EIS用户下单"""
     with allure.step('读取EIS-URL'):
         url = self.page.config_reader('test_order.conf', 'EIS_URL', 'URL')
         allure.attach('EIS-URL: ', 'EIS_URL: %s' % url)
     self.driver.get(url)
     self.home.search_sku()
     self.product_list.element_find(self.product_list.sku_result_click).click()
     self.product_list.element_find(self.product_list.skuContent_add_button).click()
     self.product_list.element_find(self.product_list.skuContent_jump_to_cart).click()
     self.cart.submit_order_eis()
     while True:
         current_url = self.driver.current_url
         if self.environment == 'staging':
             if current_url == self.order_result.eis_staging_url:
                 break
             else:
                 continue
         elif self.environment == 'production':
             if current_url == self.order_result.eis_production_url:
                 break
             else:
                 continue
Esempio n. 23
0
 def list_add_to_cart(self):
     with allure.step('列表页加入购物车'):
         self.element_find(self.list_add_button).click()
         self.element_find(self.cart_button).click()
Esempio n. 24
0
 def get_order_id(self):
     with allure.step('通过文本获取SO单号'):
         orderId = self.element_find(self.order_id).text
         print(orderId)
         return orderId
Esempio n. 25
0
def test_false():
    with allure.step('Check value'):
        assert False
Esempio n. 26
0
def delete_all_devices_from_cloud():
    yield

    with allure.step("Delete all scenes, devices and assets from the Cloud"):
        api = frontapi2.FrontAPI2("staging.epiphan.cloud")
        api.delete_all()
Esempio n. 27
0
    def test_sudoku_class(self):
        """
        Testing Sudoku class

        Given a Sudoku data structure with size NxN, N > 0 and √N == integer,
        assert a method that validates if it has been filled out correctly.
        :return:
        """

        allure.dynamic.title("Testing Sudoku class")
        allure.dynamic.severity(allure.severity_level.NORMAL)
        allure.dynamic.description_html(
            '<h3>Codewars badge:</h3>'
            '<img src="https://www.codewars.com/users/myFirstCode'
            '/badges/large">'
            '<h3>Test Description:</h3>'
            "<p>Testing Sudoku class</p>"
            "<p>Given a Sudoku data structure with size NxN, "
            "N > 0 and √N == integer, assert a method that validates "
            "if it has been filled out correctly.</p>")

        test_data = [
            ([[7, 8, 4, 1, 5, 9, 3, 2, 6], [5, 3, 9, 6, 7, 2, 8, 4, 1],
              [6, 1, 2, 4, 3, 8, 7, 5, 9], [9, 2, 8, 7, 1, 5, 4, 6, 3],
              [3, 5, 7, 8, 4, 6, 1, 9, 2], [4, 6, 1, 9, 2, 3, 5, 8, 7],
              [8, 7, 6, 3, 9, 4, 2, 1, 5], [2, 4, 3, 5, 6, 1, 9, 7, 8],
              [1, 9, 5, 2, 8, 7, 6, 3, 4]], True, 'Testing valid 9x9'),
            ([[1, 4, 2, 3], [3, 2, 4, 1], [4, 1, 3, 2],
              [2, 3, 1, 4]], True, 'Testing valid 4x4'),
            ([[0, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9]], False, 'Values in wrong order'),
            ([[1, 2, 3, 4, 5], [1, 2, 3, 4], [1, 2, 3, 4],
              [1]], False, '4x5 (invalid dimension)'),
            ([[7, 8, 4, 1, 5, 9, 3, 2, 6], [5, 3, 9, 6, 7, 2, 8, 4, 1],
              [6, 1, 2, 4, 3, 8, 7, 5, 9], [9, 2, 8, 7, 1, 5, 4, 6, 3],
              [3, 5, 7, 8, 4, 6, 1, 9, 2], [4, 6, 1, 9, 2, 3, 5, 8, 7],
              [8, 7, 6, 3, 9, 4, 2, 1, 5], [2, 4, 3, 5, 6, 1, 9, 7, 8],
              [1, 9, 5, 2, 8, 7, 6, 3, 4]], True, 'Testing valid 9x9'),
            ([[1, 4, 2, 3], [3, 2, 4, 1], [4, 1, 3, 2],
              [2, 3, 1, 4]], True, 'Testing valid 4x4'),
            ([[1]], True, 'Testing valid 1x1'),
            ([[0, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9]], False, 'Values in wrong order'),
            ([[1, 2, 3, 4, 5], [1, 2, 3, 4], [1, 2, 3, 4],
              [1]], False, '4x5 (invalid dimension)'),
            ([
                [2],
            ], False, '1x1 with wrong value'),
            ([
                [''],
            ], False, 'Empty field(s)'),
            ([
                [0],
            ], False, 'Values not in valid range 1..N'),
            ([
                [True],
            ], False, 'Invalid value types (boolean)'),
            ([[1, 4, 4, 3, 'a'], [3, 2, 4, 1], [4, 1, 3, 3], [2, 0, 1, 4],
              ['', False, None,
               '4']], False, 'Sudoku breaking all rules at once'),
            ([[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 1, 5, 6, 4, 8, 9, 7],
              [3, 1, 2, 6, 4, 5, 9, 7, 8], [4, 5, 6, 7, 8, 9, 1, 2, 3],
              [5, 6, 4, 8, 9, 7, 2, 3, 1], [6, 4, 5, 9, 7, 8, 3, 1, 2],
              [7, 8, 9, 1, 2, 3, 4, 5, 6], [8, 9, 7, 2, 3, 1, 5, 6, 4],
              [9, 7, 8, 3, 1, 2, 6, 4, 5]], False,
             'Sudoku with invalid boxes (little squares), but valid rows and columns'
             ),
        ]

        for data, expected, message in test_data:
            with allure.step(
                    "Enter a Sudoku solution and verify if it a valid one."):

                actual_result = Sudoku(data).is_valid()

                print_log(expected=expected,
                          actual_result=actual_result,
                          message=message)

            with allure.step("Assert expected result vs actual."):
                self.assertEqual(expected, actual_result)
Esempio n. 28
0
 def change_language(self):
     self.button_change_language()
     self.button_more_change_language()
     self.select_lang_eng()
     with allure.step("at_page"):
         self.assert_lang('Eng')
Esempio n. 29
0
 def run_moveAllEmail_case(self, data):
     with allure.step("移动2封邮件到第一个可删除的自定义箱子中"):
         self.moveToBoxPageCommon.moveEmailToCustomBox()
     with allure.step("点击第一个可删除的自定义箱子"):
         self.click_ele(self.customBoxPage_canCancelParentCustomBoxList_loc)
     with allure.step("获取该箱子下的所有邮件主题"):
         emailSubjects = self.recipientBoxPageCommon.get_allEmailSubject()
         print(emailSubjects)
     if not emailSubjects:
         raise Exception("该自定义箱子下没有邮件,请检查移动操作")
     with allure.step("悬浮更多操作按钮"):
         self.mouseHover_visibleEle(
             self.customBoxPage_customBoxMoreOperateBtn_loc)
     time.sleep(1)
     with allure.step("悬浮移动全部邮件按钮"):
         self.mouseHover_visibleEle(self.customBoxPage_moveAllEmailBtn_loc)
     time.sleep(1)
     with allure.step("点击{}".format(data["boxCategory"])):
         purposeBoxCategory_loc = (
             By.XPATH,
             self.customBoxPage_moveToRecipientBoxBtn_loc[1].replace(
                 "收件箱", data["boxCategory"]))
         self.click_ele(purposeBoxCategory_loc)
     time.sleep(0.5)
     if data["boxCategory"] in ["客户箱", "供应商箱", "内部联系人箱", "自定义箱"]:
         if data["boxCategory"] == "客户箱":
             with allure.step("选中第一个客户箱"):
                 movedBoxName = self.moveToBoxPageCommon.selectCustomerOrSupplierBox(
                 )
         elif data["boxCategory"] == "供应商箱":
             with allure.step("选中第一个供应商箱"):
                 movedBoxName = self.moveToBoxPageCommon.selectCustomerOrSupplierBox(
                 )
         elif data["boxCategory"] == "内部联系人箱":
             with allure.step("选中第一个内部联系人箱"):
                 movedBoxName = self.moveToBoxPageCommon.selectInnerBox()
         elif data["boxCategory"] == "自定义箱":
             with allure.step("选中第一个自定义箱"):
                 movedBoxName = self.moveToBoxPageCommon.selectCustomBox(
                     index=1)
         with allure.step("点击确认移动按钮"):
             self.moveToBoxPageCommon.click_sureMove()
     elif data["boxCategory"] in ["收件箱", "已发箱", "群发箱"]:
         movedBoxName = data["boxCategory"]
         data["boxCategory"] = None
     else:
         with allure.step("输入自定义箱名"):
             movedBoxName = random_name() + "test@$" + ",可删除" + str(
                 random_number(1))
             self.sendKeys(
                 self.customBoxPage_addCustomBoxPage_customBoxNameInput_loc,
                 key=movedBoxName)
         with allure.step("点击保存按钮"):
             self.click_ele(
                 self.customBoxPage_addCustomBoxPage_saveCustomBoxBtn_loc)
     with allure.step("查看是否还有邮件"):
         self.recipientBoxPageCommon.click_refreshBtn()
         time.sleep(1)
         if self.is_element_exist(
                 self.recipientBoxPage_emailSubject_loc[1]):
             raise Exception("全部移到后,该箱子仍然有邮件")
     with allure.step("跳转到对应的箱子:{},查看是否有邮件".format(data["boxCategory"])):
         self.recipientBoxPageCommon.click_purposeBox(
             boxCategory=data["boxCategory"], boxName=movedBoxName)
     with allure.step("获取所有的邮件主题"):
         emailSubjects_moved = self.recipientBoxPageCommon.get_allEmailSubject(
         )
     with allure.step("判断移动前的邮件是否在移动之后的箱子里面"):
         for subject in emailSubjects:
             if subject not in emailSubjects_moved:
                 raise Exception(
                     "移动前的邮件:{},不在移动之后的箱子里面,移动之后箱子的所有邮件:{}".format(
                         emailSubjects, emailSubjects_moved))
Esempio n. 30
0
 def click_compare_button(self):
     self.logger.info('click_compare_button')
     with allure.step("сравниваем"):
         return self._click(self.COMPARE_BTN)
Esempio n. 31
0
 def check_wishlist_alert(self, wait):
     self.logger.info('check_wishlist_alert')
     with allure.step("ожидаем подтверждения"):
         return self._wait_for_presence_of_element_located(
             (self.ALERT_MESSAGE), wait)
Esempio n. 32
0
 def click_fishlist_button(self):
     self.logger.info('click_fishlist_button')
     with allure.step("добавляем в вишлист (ну или в рыбалист)"):
         return self._click(self.WISH_LIST_BTN)
Esempio n. 33
0
 def check_cart_status(self, wait, text):
     self.logger.info('check_cart_status')
     with allure.step("проверяем статус корзины"):
         return self._wait_for_text_to_be_present_in_element(
             (self.CART_STATUS), wait, text)
Esempio n. 34
0
 def click_cart(self):
     self.logger.info('click_cart')
     with allure.step("кликаем корзину"):
         return self._click(self.CART)
Esempio n. 35
0
def allureLogs(text):
    with allure.step(text):
        pass
Esempio n. 36
0
"""
Allure报告模块
"""

import allure


def add_common_report(case, http, expected):
    """
    添加常用报告信息
    :param case: 测试用例名称
    :param http: 请求对象
    :param expected: 预期结果
    :return:
    """
    with allure.step('测试用例名称'):
        allure.attach(case, 'case')

    with allure.step('请求对象'):
        allure.attach(http['path'], 'path')
        allure.attach(http['method'], 'method')

        with allure.step('headers'):
            keys = http['headers'].keys()
            values = http['headers'].values()
            for k, v in zip(keys, values):
                allure.attach(v, k)

        with allure.step('params'):
            keys = http['params'].keys()
            values = http['params'].values()
Esempio n. 37
0
    def test_growing_plant(self):
        """
        Testing growing_plant function

        Task

        Each day a plant is growing by upSpeed meters.
        Each night that plant's height decreases by downSpeed
        meters due to the lack of sun heat. Initially, plant
        is 0 meters tall. We plant the seed at the beginning
        of a day. We want to know when the height of the plant
        will reach a certain level.

        Example

        For upSpeed = 100, downSpeed = 10 and desiredHeight = 910,
        the output should be 10.

        For upSpeed = 10, downSpeed = 9 and desiredHeight = 4,
        the output should be 1. Because the plant reach to the desired
        height at day 1(10 meters).

        Input/Output

        [input] integer upSpeed
        A positive integer representing the daily growth.
        Constraints: 5 ≤ upSpeed ≤ 100.

        [input] integer downSpeed
        A positive integer representing the nightly decline.
        Constraints: 2 ≤ downSpeed < upSpeed.

        [input] integer desiredHeight
        A positive integer representing the threshold.
        Constraints: 4 ≤ desiredHeight ≤ 1000.

        [output] an integer

        The number of days that it will take for the plant to
        reach/pass desiredHeight (including the last day in the
        total count).
        """

        allure.dynamic.title('Testing growing_plant function')
        allure.dynamic.severity(allure.severity_level.NORMAL)
        allure.dynamic.description_html(
            '<h3>Codewars badge:</h3>'
            '<img src="https://www.codewars.com/users/myFirstCode'
            '/badges/large">'
            '<h3>Test Description:</h3>'
            "<p></p>")

        with allure.step('Enter upSpeed, downSpeed and '
                         'desiredHeight and verify the output'):

            test_data = [
                ((100, 10, 910), 10),
                ((10, 9, 4), 1),
                ((5, 2, 0), 1),
                ((5, 2, 5), 1),
                ((5, 2, 6), 2),
            ]

            for input_data, expected in test_data:

                upSpeed = input_data[0]
                downSpeed = input_data[1]
                desiredHeight = input_data[2]

                print_log(input_data=input_data, expected=expected)

                self.assertEqual(
                    expected, growing_plant(upSpeed, downSpeed, desiredHeight))
Esempio n. 38
0
 def check_compare_alert(self, wait):
     self.logger.info('check_compare_alert')
     with allure.step("ожидаем сравнения"):
         return self._wait_for_presence_of_element_located(
             (self.ALERT_MESSAGE), wait)
Esempio n. 39
0
def test_add_contact_in_group(db, orm, app):

    with allure.step(
            'I check if exist any group with any contact in database '):
        if len(db.get_group_list()) == 0:
            app.group.create(Group(name="test"))

        contacts_in_groups_list = sorted(
            set([item.id for item in db.get_all_contacts_in_groups_list()]))
        if len(db.get_contact_list()) == 0 or len(
                db.get_contact_list()) == len(contacts_in_groups_list):
            contact = Contact(firstname="Test",
                              lastname="Testov",
                              address="addressTest",
                              homephone="1111",
                              mobile="22222",
                              workphone="3333",
                              fax="44444",
                              email="rttyru@com",
                              email2="*****@*****.**",
                              homepage="wwwfghgj",
                              secondaryphone="5555")
            app.contacts.create_new_contact(contact)

    with allure.step(
            'I got a difference between list of all contacts from db and list of contacts in groups '
    ):
        contacts_not_in_group = []
        if len(db.get_contact_list()) > len(contacts_in_groups_list):
            set_contacts_in_groups_list = sorted(
                set([item.id
                     for item in db.get_all_contacts_in_groups_list()]))
            list_of_id_contacts_in_groups = [
                clear(elem) for elem in set_contacts_in_groups_list
            ]
            contacts_id_list_from_db = sorted(
                [item.id for item in db.get_contact_list()])
            contacts_not_in_group = list(
                set(contacts_id_list_from_db) -
                set(list_of_id_contacts_in_groups))

    with allure.step('Random contact selected from contacts not in group'):
        if len(contacts_not_in_group) > 1:
            contact_id = random.choice(contacts_not_in_group)
        else:
            contact_id = contacts_not_in_group[0]
        contact = db.get_contact_from_id(contact_id)[0]

    with allure.step('Random group selected from group list'):
        old_groups = db.get_group_list()
        group = random.choice(old_groups)

    with allure.step('When I add a contact %s to the group' % contact):
        old_list_of_contacts_in_selected_group = sorted(
            orm.get_contacts_in_group(group))
        app.contacts.add_contact_in_group(contact.id, group.id)

    with allure.step(
            'Then the selected groups list of contacts is equal to the old list with the added contact'
    ):
        assert len(old_list_of_contacts_in_selected_group) + 1 == len(
            orm.get_contacts_in_group(group))
Esempio n. 40
0
def policy_creation_should_succeeded(admin_client: ADCMClient, role: Role, adcm_object: AnyADCMObject, user: User):
    """Try to create policy based on give role and expect creation to succeed"""
    with allure.step(f'Create policy based on role "{role.display_name}" and expect it to succeeded'):
        policy_name = f'Test role {random_string(5)}'
        with catch_failed(ErrorMessage, 'Policy should be created'):
            admin_client.policy_create(name=policy_name, role=role, objects=[adcm_object], user=[user])
def test_ont_mac_learn(login):
    '''
    用例描述
    测试目的: 测试onu端口mac地址学习是否正常
    测试步骤:
    步骤1: 发现未注册的ONU
    步骤2: 在OLT上通过MAC的方式将ONU注册上线
    步骤3:配置onu端口vlan为transparent
    步骤4:在OLT配置ONU的service-port
    步骤5:打流测试,查看onu端口mac地址表
    1)上下行各发送流00:00:00:22:22:21递增5条,在olt上查看onu端口mac地址表
    down_stream_header = (
        'ethernetII_1.sourceMacAdd=00:00:00:11:11:11 vlan_1.id=2000 ethernetII_1.destMacAdd=00:00:00:22:22:21',
        'ethernetII_1.sourceMacAdd=00:00:00:11:11:12 vlan_1.id=2000 ethernetII_1.destMacAdd=00:00:00:22:22:22')
    up_stream_header = (
        'ethernetII_1.sourceMacAdd=00:00:00:22:22:21 vlan_1.id=2000 ethernetII_1.destMacAdd=00:00:00:11:11:11',
        'ethernetII_1.sourceMacAdd=00:00:00:22:22:22 vlan_1.id=2000 ethernetII_1.destMacAdd=00:00:00:11:11:12',)

    预期结果: 上下行正常通,在olt上查看onu端口mac地址表有5条(00:00:00:22:22:21递增5条)
    '''
    renix_info("=========ONU MAC地址上报测试=========")
    cdata_info("=========ONU MAC地址上报测试=========")
    tn = login
    Vlan_list = [2000]

    with allure.step('步骤1:发现未注册的ONU。'):
        assert autofind_onu(tn, Epon_PonID, Epon_OnuID, Epon_ONU_MAC)
    with allure.step('步骤2:在OLT上通过MAC认证的方式将ONU注册上线。'):
        assert auth_by_mac(tn, Epon_PonID, Epon_OnuID, Ont_Lineprofile_ID, Ont_Srvprofile_ID, Epon_ONU_MAC)
    with allure.step("步骤3:配置onu端口vlan为transparent"):
        assert ont_port_transparent(tn, Epon_PonID, Epon_OnuID, Ont_Port_ID)
    with allure.step('步骤4:在OLT配置ONU的service-port。'):
        assert add_service_port(tn, Epon_PonID, Epon_OnuID, Vlan_list)
    with allure.step("步骤5:打流测试,查看onu端口mac地址表"):
        # 清除测试仪的对象,防止影响下个用例的执行
        time.sleep(5)
        reset_rom_cmd = ResetROMCommand()
        reset_rom_cmd.execute()

        # 发流量测试,发送两条流2000+pri2,和vlan2000+pri3
        # port_location = ['//192.168.0.180/1/9', '//192.168.0.180/1/10']
        duration = 5
        down_stream_header = (
            'ethernetII_1.sourceMacAdd=00:00:00:11:11:11 vlan_1.id=2000  ethernetII_1.destMacAdd=00:00:00:22:22:21 ipv4_1.source=192.168.1.11 ipv4_1.destination=192.168.1.21',
            'ethernetII_1.sourceMacAdd=00:00:00:11:11:12 vlan_1.id=2000  ethernetII_1.destMacAdd=00:00:00:22:22:22 ipv4_1.source=192.168.1.12 ipv4_1.destination=192.168.1.22',
            'ethernetII_1.sourceMacAdd=00:00:00:11:11:13 vlan_1.id=2000  ethernetII_1.destMacAdd=00:00:00:22:22:23 ipv4_1.source=192.168.1.13 ipv4_1.destination=192.168.1.23',
            'ethernetII_1.sourceMacAdd=00:00:00:11:11:14 vlan_1.id=2000  ethernetII_1.destMacAdd=00:00:00:22:22:24 ipv4_1.source=192.168.1.14 ipv4_1.destination=192.168.1.24',
            'ethernetII_1.sourceMacAdd=00:00:00:11:11:15 vlan_1.id=2000  ethernetII_1.destMacAdd=00:00:00:22:22:25 ipv4_1.source=192.168.1.15 ipv4_1.destination=192.168.1.25',)

        up_stream_header = (
            'ethernetII_1.sourceMacAdd=00:00:00:22:22:21 vlan_1.id=2000 ethernetII_1.destMacAdd=00:00:00:11:11:11 ipv4_1.source=192.168.1.21 ipv4_1.destination=192.168.1.11',
            'ethernetII_1.sourceMacAdd=00:00:00:22:22:22 vlan_1.id=2000 ethernetII_1.destMacAdd=00:00:00:11:11:12 ipv4_1.source=192.168.1.22 ipv4_1.destination=192.168.1.12',
            'ethernetII_1.sourceMacAdd=00:00:00:22:22:23 vlan_1.id=2000 ethernetII_1.destMacAdd=00:00:00:11:11:13 ipv4_1.source=192.168.1.23 ipv4_1.destination=192.168.1.13',
            'ethernetII_1.sourceMacAdd=00:00:00:22:22:24 vlan_1.id=2000 ethernetII_1.destMacAdd=00:00:00:11:11:14 ipv4_1.source=192.168.1.24 ipv4_1.destination=192.168.1.14',
            'ethernetII_1.sourceMacAdd=00:00:00:22:22:25 vlan_1.id=2000 ethernetII_1.destMacAdd=00:00:00:11:11:15 ipv4_1.source=192.168.1.25 ipv4_1.destination=192.168.1.15',
        )
        # 获取所有流量的统计值
        result_stats = unicast_test(port_location=port_location, down_stream_header=down_stream_header,
                                    up_stream_header=up_stream_header, num=5, dataclassname=PortStats,
                                    duration=duration)

        #判断流上下行接收是否正常
        result_stream  = check_port_static(result_stats[0],result_stats[1])
        #判断olt上是否能查看onu学习的mac地址
        tn = login
        result_show = ont_mac_learn(tn,Epon_PonID,Epon_OnuID,Ont_Port_ID)
        result_mac = 'PASS'

        if '00:00:00:22:22:21' in result_show and '00:00:00:22:22:22' in result_show and '00:00:00:22:22:23' in result_show \
                and '00:00:00:22:22:24' in result_show and '00:00:00:22:22:25' in result_show:
            result_mac = 'PASS'
        else:
            result_mac = 'FAIL'

        if result_mac == 'PASS':
            cdata_error("ONT MAC地址上报:MAC地址学习正常")
        else:
            cdata_error("ONT MAC地址上报:MAC地址学习失败")

        if result_stream == 'PASS':
            cdata_error("ONT MAC地址上报:打流正常")
        else:
            cdata_error("ONT MAC地址上报:打流失败")

        assert result_stream=='PASS' and result_mac =='PASS'
Esempio n. 42
0
 def click_delivery_date(self):
     self.logger.info('click_delivery_date')
     with allure.step("кликаем на дате доставки"):
         return self._click(self.DELIVERY_DATE)
Esempio n. 43
0
 def run_addApprovalRule_case(self, casename, condition, keyword,
                              is_approval):
     with allure.step("回到邮件首页"):
         self.click_ele(self.emailHomePage_loc)
     with allure.step("审批掉所有的邮件"):
         self.recipientBoxPageCommon.run_approvalMail_case()
     with allure.step("切换到dmktest001"):
         self.switch_operator(operator="dmktest_001")
     with allure.step("点击邮箱设置按钮"):
         self.click_ele(self.mailSettingBtn_loc)
     with allure.step("点击审批规则按钮"):
         self.click_ele(
             self.mailSettingPageApprovalRulePage_approvalRuleBtn_loc)
         time.sleep(0.5)
     with allure.step("输入审批规则名字"):
         self.find_element(
             self.mailSettingPageApprovalRulePage_approvalRuleNameInput_loc
         ).clear()
         self.find_element(
             self.mailSettingPageApprovalRulePage_approvalRuleNameInput_loc
         ).send_keys("审批规则测试")
     # with allure.step("点击审批人选择框"):
     #     self.find_element(self.mailSettingPageApprovalRulePage_approvalPersonBtn_loc).click()
     # time.sleep(0.3)
     # with allure.step("选择审批人-管理员"):
     #     self.find_element(self.mailSettingPageApprovalRulePage_approvalPerson_loc).click()
     with allure.step("点击审批条件选择框"):
         self.find_element(
             self.mailSettingPageApprovalRulePage_approvalConditionBtn_loc
         ).click()
     time.sleep(0.3)
     with allure.step("选中审批条件"):
         mailSettingPageApprovalRulePage_approvalCondition_loc = (
             By.XPATH,
             self.mailSettingPageApprovalRulePage_approvalCondition_loc[1].
             replace("全部审批(强制)", condition))
         self.screenshotImg(
             mailSettingPageApprovalRulePage_approvalCondition_loc)
         time.sleep(0.2)
         self.find_element(
             mailSettingPageApprovalRulePage_approvalCondition_loc).click()
     time.sleep(0.3)
     if "全部审批" not in condition:
         self.find_element(
             self.
             mailSettingPageApprovalRulePage_approvalConditionContainKeyInput_loc
         ).clear()
         self.find_element(
             self.
             mailSettingPageApprovalRulePage_approvalConditionContainKeyInput_loc
         ).send_keys(keyword)
     with allure.step("点击保存按钮"):
         self.find_element(
             self.mailSettingPageApprovalRulePage_saveApprovalRuleBtn
         ).click()
     with allure.step("回到首页,点击写邮件"):
         self.find_element(self.emailHomePage_loc).click()
         self.find_element(self.writeEmailBtn_loc).click()
     time.sleep(2)
     with allure.step("输入收件人"):
         self.find_element(self.writeMailPage_recipientInput_loc).send_keys(
             random_email())
     with allure.step("输入邮件主题"):
         subject = random_name() + "-审批规则测试-" + time.strftime(
             "%Y%m%d.%H.%M.%S")
         logger.info("用例:{},测试审批规则的邮件主题:{}".format(casename, subject))
         logger.info("用例:{},测试审批规则的邮件主题:{}".format(casename, subject))
         self.find_element(
             self.writeMailPage_emailSubjectInput_loc).send_keys(subject)
     with allure.step("输入邮件内容"):
         try:
             self.switch_frame(self.emailEditFrame_loc)
             self.find_element(self.emailBodyInEmailEdit_loc).send_keys(
                 random_text())
         except Exception as e:
             print(e)
         finally:
             self.switch_parentFrame()
     with allure.step("点击发送按钮"):
         self.find_element(self.writeMailPage_sendEmailBtn_loc).click()
     if "可选" in condition:
         with allure.step("输入审批备注"):
             self.find_element(
                 self.writeMailPage_submitApprovalInput_loc).send_keys(
                     "邮件审批测试{}".format(time.strftime("%Y%m%d.%H.%M.%S")))
         if is_approval == "1":
             self.find_element(
                 self.writeMailPage_submitApprovalBtn_loc).click()
         elif is_approval == "0":
             self.find_element(self.writeMailPage_noApprovalBtn_loc).click()
     time.sleep(1)
     with allure.step("回到设置tab"):
         self.find_element(self.recipientBoxPage_settingTabBtn_loc).click()
     if "直接发送" not in casename:
         with allure.step("禁用审批规则,查看是否有正在审批的邮件的判断"):
             self.mouseHover(
                 self.mailSettingPageApprovalRulePage_approvalRuleList_loc)
             time.sleep(0.3)
             self.find_element(
                 self.
                 mailSettingPageApprovalRulePage_disableApprovalRuleBtn_loc
             ).click()
         with allure.step("获取toast提示"):
             toastText = self.find_element(self.toast_loc).text
             if toastText != "该审批规则有正在审批中的邮件,无法操作":
                 raise Exception(
                     "禁用有正在审批的邮件的审批规则,toast提示:{},不对".format(toastText))
         time.sleep(1)
         with allure.step("删除审批规则,查看是否有正在审批的邮件的判断"):
             self.mouseHover(
                 self.mailSettingPageApprovalRulePage_approvalRuleList_loc)
             time.sleep(0.3)
             self.find_element(
                 self.mailSettingPageApprovalRulePage_approvalRuleDelBtn_loc
             ).click()
             self.find_element(
                 self.
                 mailSettingPageApprovalRulePage_approvalRuleSureDelBtn_loc
             ).click()
         with allure.step("获取toast提示"):
             toastText = self.find_element(self.toast_loc).text
             if toastText != "该审批规则有正在审批中的邮件,无法操作":
                 raise Exception(
                     "禁用有正在审批的邮件的审批规则,toast提示:{},不对".format(toastText))
     time.sleep(3)
     with allure.step("回到邮件首页tab"):
         self.find_element(self.emailHomePage_loc).click()
     if is_approval == "0":
         with allure.step("点击已发箱,查看邮件"):
             self.find_element(
                 self.recipientBoxPage_hasSendBoxBtn_loc).click()
     else:
         with allure.step("点击待发箱。查看邮件"):
             self.find_element(
                 self.recipientBoxPage_waitSendBoxBtn_loc).click()
     with allure.step("查看是否有刚刚提交审批的邮件"):
         allEmailSubjectText = self.get_elementText(
             self.recipientBoxPage_emailSubject_loc, index="all")
         if subject not in allEmailSubjectText:
             raise Exception("待发箱或者已发箱没有主题是{}的邮件".format(subject))
     if "直接发送" not in casename:
         with allure.step("切换到dmktest账号"):
             self.switch_operator()
         with allure.step("审批所有的邮件"):
             self.recipientBoxPageCommon.run_approvalMail_case(
                 subject=subject)
         with allure.step("切换到dmktest001"):
             self.switch_operator(operator="dmktest_001")
     with allure.step("判断已发箱是否有已经审批的邮件"):
         self.hasMailInBox(subject=subject)
Esempio n. 44
0
 def set_product_qty(self, value):
     self.logger.info('set_product_qty')
     with allure.step("устанавливаем кол-во продуктов"):
         return self._input(self.PRODUCT_QTY, value)
Esempio n. 45
0
def test_true():
    with allure.step('Check value'):
        assert True
Esempio n. 46
0
 def click_add_to_cart_button(self):
     self.logger.info('click_add_to_cart_button')
     with allure.step("добваляем в корзину"):
         return self._click(self.ADD_TO_CART_BTN)
Esempio n. 47
0
 def bigImg_add_to_cart(self):
     with allure.step('大图页加入购物车'):
         self.element_find(self.big_img_icon).click()
         time.sleep(2)
         self.element_find(self.bigImg_add_button).click()
         self.element_find(self.jump_to_cart).click()
Esempio n. 48
0
 def test_my_foo(self):
     allure.attach('foo', 'my foo')
     with allure.step('step one'):
         self.assertEqual(self.instance.foo, 10)
     with allure.step('step two'):
         self.assertEqual(self.instance.foo2(), self.instance.foo)
Esempio n. 49
0
 def assert_isNotContain(desc_msg, expect_var, actual_var):
     desc_msg = "{}不应被包含".format(desc_msg)
     with allure.step('结果校验:{}'.format(desc_msg)):
         AllureHelper.attachText("", "期望关键信息:不包含 {}".format(expect_var))
         AllureHelper.attachText("", "实际输出信息:{}".format(actual_var))
         assert expect_var not in str(actual_var)
Esempio n. 50
0
    def assert_result(self, valuesection, typesection='coltype'):
        #定义结果集
        resultlist = []
        # 获取列表和列类型字典
        coltype = self.get_col_value(typesection)
        # 获取数据
        data = self.get_col_type(valuesection)[0]
        # 处理获取到的数据
        for k, v in data.items():
            if coltype[k] in self.strlist:
                if '*' in str(v):
                    result = True
                else:
                    result = False
                    #加入allure false内容输入出
                    with allure.step("日期类型错误字段"):
                        allure.attach("脱敏错误数据类型为", str(k))
                        allure.attach("值为", str(v))

                    self.logger.info('失败的字段为{}值为{}'.format(k, v))
            elif coltype[k] in self.numlist:
                if '108' or '10' or '1' in str(v):
                    result = True
                else:
                    result = False
                    #加入allure false内容输入出
                    with allure.step("日期类型错误字段"):
                        allure.attach("脱敏错误数据类型为", str(k))
                        allure.attach("值为", str(v))

                    self.logger.info('失败的字段为{}值为{}'.format(k, v))
            elif coltype[k] in self.datelist:
                if '1970-01-01' in str(v):
                    result = True
                else:
                    result = False
                    #加入allure false内容输入出
                    with allure.step("日期类型错误字段"):
                        allure.attach("脱敏错误数据类型娄", str(k))
                        allure.attach("值为", str(v))

                    self.logger.info('失败的字段为{}值为{}'.format(k, v))
            elif coltype[k] in self.floatlist:
                if '0.8' or '8.8' or '.8' in str(v):
                    result = True
                else:
                    result = False
                    #加入allure false内容输入出
                    with allure.step("日期类型错误字段"):
                        allure.attach("脱敏错误数据类型娄", str(k))
                        allure.attach("值为", str(v))

                    self.logger.info('失败的字段为{}值为{}'.format(k, v))
            elif coltype[k] in self.otherlist:
                if 'None' in str(v):
                    result = True
                else:
                    result = False
                    #加入allure false内容输入出
                    with allure.step("日期类型错误字段"):
                        allure.attach("脱敏错误数据类型娄", str(k))
                        allure.attach("值为", str(v))
                    self.logger.info('失败的字段为{}值为{}'.format(k, v))
            resultlist.append(result)
        return resultlist
Esempio n. 51
0
 def get(self, path="/", params=None, headers=None):
     url = f"{self.base_address}{path}"
     with allure.step(f'GET request to: {url}'):
         return requests.get(url=url, params=params, headers=headers)
Esempio n. 52
0
 def assert_equal(desc_msg, except_var, actual_var):
     with allure.step('结果校验:{}'.format(desc_msg)):
         AllureHelper.attachText("", "期望{}:{}".format(desc_msg, except_var))
         AllureHelper.attachText("", "实际{}:{}".format(desc_msg, actual_var))
         assert except_var == actual_var
     return (except_var, actual_var)
Esempio n. 53
0
def test_create_quick_order(driver, main_page, order_form):
    logger.info('Create quick order')
    with allure.step('Открыть форму быстрой заявки, если она не отображается'):
        order_form.open_form(driver)
    with allure.step('Очистить поля формы'):
        with allure.step('Очистить {}'.format(STREET_TITLE)):
            locators.element_is_clickable(driver, order_form.street).clear()
        with allure.step('Очистить {}'.format(HOUSE_TITLE)):
            locators.element_is_clickable(driver, order_form.house).clear()
        with allure.step('Очистить {}'.format(FLAT_TITLE)):
            locators.element_is_clickable(driver, order_form.flat).clear()
        with allure.step('Очистить {}'.format(NAME_TITLE)):
            locators.element_is_clickable(driver, order_form.name).clear()
        with allure.step('Очистить {}'.format(PHONE_TITLE)):
            locators.element_is_clickable(driver, order_form.phone).clear()
    with allure.step('Ввод данных, {}'.format(STREET_TITLE)):
        locators.element_is_clickable(driver,
                                      order_form.street).send_keys('Тестовая')
    with allure.step('Время для подгрузки js-скрипта'):
        time.sleep(settings.PAUSE_TIME)
    with allure.step('Ввод данных, {}'.format(HOUSE_TITLE)):
        locators.element_is_clickable(driver, order_form.house).send_keys(
            random.randint(1, 999))
    with allure.step('Время для подгрузки js-скрипта'):
        time.sleep(settings.PAUSE_TIME)
    with allure.step('Ввод данных, {}'.format(FLAT_TITLE)):
        locators.element_is_clickable(driver, order_form.flat).send_keys(
            random.randint(1, 999))
    with allure.step('Ввод данных, {}'.format(NAME_TITLE)):
        locators.element_is_clickable(driver,
                                      order_form.name).send_keys('автотест')
    with allure.step('Ввод данных, {}'.format(PHONE_TITLE)):
        locators.element_is_clickable(driver,
                                      order_form.phone).send_keys('9998887766')
    with allure.step('Проверка отображения кнопки отправки заявки'):
        apl = locators.element_is_clickable(driver, order_form.apply_btn)
    with allure.step('Получить текущий URL до отправки заявки'):
        url_before = driver.current_url
    logger.info('Send quick order')
    with allure.step('Нажать кнопку отправки заявки'):
        apl.click()
    with allure.step('Проверка ,что форма быстрой заявки не отображается'):
        locators.element_is_not_found(driver,
                                      order_form.fast_order_form,
                                      time=settings.PAUSE_TIME + 7)
    with allure.step('Получить текущий URL после отправки заявки'):
        url_after = driver.current_url
    logger.info('URLs not equal')
    with allure.step(
            'Проверка, что URL до и после отправки заявки не совпадают'):
        assert url_after != url_before
Esempio n. 54
0
 def test_case_1(self, test_case_8):
     print('---1号用例完成---')
     with allure.step('测试步骤:'):
         allure.attach('测试步骤1')
         allure.attach('测试步骤2')
Esempio n. 55
0
def test_form_elements(driver, main_page, order_form):
    logger.info('Form elements')
    with allure.step('Открыть форму быстрой заявки, если она не отображается'):
        order_form.open_form(driver)
    with allure.step('Проверка возможности ввода данных для поля Улица'):
        locators.element_is_clickable(driver, order_form.street)
    with allure.step('Проверка возможности ввода данных для поля Дом'):
        locators.element_is_clickable(driver, order_form.house)
    with allure.step('Проверка возможности ввода данных для поля Квартира'):
        locators.element_is_clickable(driver, order_form.flat)
    with allure.step('Проверка возможности ввода данных для поля ФИО'):
        locators.element_is_clickable(driver, order_form.name)
    with allure.step('Проверка возможности ввода данных для поля Телефон'):
        locators.element_is_clickable(driver, order_form.phone)
    with allure.step(
            'Проверка интерактивности чек-бокса "Обработка персональных данных"'
    ):
        locators.element_is_clickable(driver, order_form.chk_box)
    with allure.step('Проверка интерактивности иконки смены региона'):
        locators.element_is_clickable(driver, order_form.change_region_btn)
    with allure.step('Проверка интерактивности иконки закрытия формы'):
        btn = locators.element_is_clickable(driver, order_form.close_btn)
    with allure.step('Закрыть форму быстрой заявки'):
        btn.click()
    logger.info('Closed form is not present')
    with allure.step('Проверка, что закрытая форма не отображается'):
        assert locators.element_is_not_found(driver,
                                             order_form.fast_order_form)
Esempio n. 56
0
 def post(self, path="/", params=None, data=None, json=None, headers=None):
     url = f"{self.base_address}{path}"
     with allure.step(f'POST request to: {url}'):
         return requests.post(url=url, params=params, data=data, json=json, headers=headers)
Esempio n. 57
0
 def click_product_details_tabs(self):
     self.logger.info('click_product_details_tabs')
     with allure.step("переходим по табам с деталями"):
         details = self._elements(self.PRODUCT_DETAILS)
         for detail in details:
             detail.click()
Esempio n. 58
0
 def brand_click(self):
     with allure.step('进入品牌页'):
         self.element_find(self.brand_bosch).click()
         self.switch_to_new_window()
Esempio n. 59
0
    def test_field_iotDevice_list(self, test_data):

        first_layer = test_data["first_layer"]
        sencod_layer = test_data["sencod_layer"]
        third_layer = test_data["third_layer"]

        if first_layer:
            allure.dynamic.epic(first_layer)
        if sencod_layer:
            allure.dynamic.feature(sencod_layer)
        if third_layer:
            allure.dynamic.story(third_layer)

        module_key = sys._getframe().f_code.co_name.split("_")[2]
        test_data = self.parse_csv_param(test_data, module_key)

        pageNo = test_data["pageNo"]
        pageSize = test_data["pageSize"]
        areaCodesList = test_data["areaCodesList"]
        deviceStatus = test_data["deviceStatus"]
        deviceCodeOrBar = test_data["deviceCodeOrBar"]
        deviceType = test_data["deviceType"]
        manufacturerType = test_data["manufacturerType"]
        lensType = test_data["lensType"]
        hardwareVersion = test_data["hardwareVersion"]
        startDateTime = test_data["startDateTime"]
        endDateTime = test_data["endDateTime"]

        with allure.step("步骤: 请求接口"):

            res_json = api_object_admin.bns_iotDevice_list(
                pageNo=pageNo,
                pageSize=pageSize,
                areaCodesList=areaCodesList,
                deviceStatus=deviceStatus,
                deviceCodeOrBar=deviceCodeOrBar,
                deviceType=deviceType,
                manufacturerType=manufacturerType,
                lensType=lensType,
                hardwareVersion=hardwareVersion,
                startDateTime=startDateTime,
                endDateTime=endDateTime,
            )

        with allure.step("步骤: 提取接口的业务状态码"):

            actual_code = JsonHelper.parseJson_by_objectpath(
                res_json, "$.response_data.code")

        with allure.step("校验: 业务状态码是否正确"):

            self.assert_actual_equal_expect("业务状态码", actual_code,
                                            test_data["expect_code"])

        if test_data["clean_data"]:

            with allure.step("步骤: 数据清理操作"):

                # TODO: 调用删除接口
                pass

        generator_objs_list = test_data.get("generator_objs_list")
        if generator_objs_list:
            for generator_obj in generator_objs_list:
                try:
                    generator_obj.__next__()
                except StopIteration:
                    pass
Esempio n. 60
-1
 def brand_add_to_cart(self):
     with allure.step('品牌页加入购物车'):
         for i in range(10):
             try:
                 self.element_find(self.brand_add_button).click()
                 break
             except ElementNotVisibleException:
                 time.sleep(0.2)
                 continue
         self.element_find(self.jump_to_cart).click()