Ejemplo n.º 1
0
    def group_add(self, group_data):
        try:
            self.login_page = login_page(group_data)
            self.driver = self.login_page.login()

            self.AST = self.login_page.login_pass()
            if self.AST == "AST":
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.navigation).click()
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.asset_menu).click()
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.group_menu).click()
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.group_button).click()
                self.driver.implicitly_wait(10)

                self.driver.find_element_by_xpath(self.server_group).send_keys(
                    self.server_group_data)
                self.driver.find_element_by_xpath(self.describe).send_keys(
                    self.describe_data)
                self.driver.find_element_by_xpath(
                    self.choice_server).send_keys(self.host_name_data)
                self.driver.find_element_by_xpath(self.server_right).click()

                self.driver.find_element_by_xpath(self.submit_button).click()

            else:
                self.driver.get_screenshot_as_file(screenshot())
                print('登录有误!!!')
        except Exception as e:
            self.driver.get_screenshot_as_file(screenshot())
            print('主机添加页面有误!!!', e)
Ejemplo n.º 2
0
 def test_login_error_5(self):
     u'''用户名正确、密码错误,登录失败'''
     self.login_data = login().login_test_data()[4]
     self.login_page = login_page(self.login_data)
     self.login_page.login()
     user_ps_null_error = self.login_page.login_user_ps_null_error()
     self.assertEqual('AdminSet', user_ps_null_error, '登录失败')
     print('55555')
     self.login_page.tearDown()
Ejemplo n.º 3
0
 def test_login_error_3(self):
     u'''用户名正确、密码错误,登录失败'''
     self.login_data = login().login_test_data()[2]
     self.login_page = login_page(self.login_data)
     self.login_page.login()
     user_ps_error = self.login_page.login_user_ps_error()
     self.assertEqual('账号密码不匹配', user_ps_error, '登录失败')
     print('333333')
     self.login_page.tearDown()
Ejemplo n.º 4
0
 def test_login_error_2(self):
     u'''用户名错误、密码正确,登录失败'''
     self.login_data = login().login_test_data()[1]
     self.login_page = login_page(self.login_data)
     self.login_page.login()
     user_ps_error = self.login_page.login_user_ps_error()
     self.assertEqual('账号密码不匹配', user_ps_error, '登录失败')
     print('22222')
     self.login_page.tearDown()
Ejemplo n.º 5
0
 def test_login_pass_1(self):
     u'''用户名正确、密码正确,登录成功'''
     self.login_data = login().login_test_data()[0]
     self.login_page = login_page(self.login_data)
     self.login_page.login()
     login_pass = self.login_page.login_pass()
     self.assertEqual('AST', login_pass, '登录成功')
     print('11111')
     self.login_page.tearDown()
Ejemplo n.º 6
0
    def computer_update(self, computer_data):
        try:
            self.login_page = login_page(computer_data)
            self.driver = self.login_page.login()

            self.AST = self.login_page.login_pass()
            if self.AST == 'AST':
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.navigation).click()
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.asset_menu).click()
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.computer_menu).click()
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.update_button).click()
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.sign).clear()
                self.driver.find_element_by_xpath(self.sign).send_keys(
                    self.sign_data)
                self.driver.find_element_by_xpath(self.computer_name).clear()
                self.driver.find_element_by_xpath(
                    self.computer_name).send_keys(self.computer_name_data)
                self.driver.find_element_by_xpath(self.address).clear()
                self.driver.find_element_by_xpath(self.address).send_keys(
                    self.address_data)
                self.driver.find_element_by_xpath(self.computer_phone).clear()
                self.driver.find_element_by_xpath(
                    self.computer_phone).send_keys(self.computer_phone_data)
                self.driver.find_element_by_xpath(self.manager).clear()
                self.driver.find_element_by_xpath(self.manager).send_keys(
                    self.manager_data)
                self.driver.find_element_by_xpath(self.phone).clear()
                self.driver.find_element_by_xpath(self.phone).send_keys(
                    self.phone_data)
                self.driver.find_element_by_xpath(self.cabinet).clear()
                self.driver.find_element_by_xpath(self.cabinet).send_keys(
                    self.cabinet_data)
                self.driver.find_element_by_xpath(self.ip).clear()
                self.driver.find_element_by_xpath(self.ip).send_keys(
                    self.ip_data)
                self.driver.find_element_by_xpath(self.bandwidth).clear()
                self.driver.find_element_by_xpath(self.bandwidth).send_keys(
                    self.bandwidth_data)
                self.driver.find_element_by_xpath(self.remarks).clear()
                self.driver.find_element_by_xpath(self.remarks).send_keys(
                    self.remarks_data)
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.submit_button).click()
            else:
                self.driver.get_screenshot_as_file(screenshot())
        except Exception as e:
            self.driver.get_screenshot_as_file(screenshot())
            self.tearDown()
            print(e)
Ejemplo n.º 7
0
    def host_update(self, host_data):
        try:
            self.login_page = login_page(host_data)
            self.driver = self.login_page.login()

            self.AST = self.login_page.login_pass()
            if self.AST == 'AST':
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.navigation).click()
                self.driver.find_element_by_xpath(self.asset_menu).click()
                self.driver.find_element_by_xpath(self.host_menu).click()
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.update_button).click()
                self.driver.implicitly_wait(10)
                host_update = self.driver.find_element_by_xpath(
                    self.host_update_news).text
                assert '修改主机信息' == host_update
                # self.driver.switch_to.default_content()
                iframe = self.driver.find_element_by_xpath(self.iframe)
                self.driver.switch_to.frame(iframe)
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.host_name).clear()
                self.driver.find_element_by_xpath(self.host_name).send_keys(
                    self.host_name_data)
                self.driver.find_element_by_xpath(self.ip).clear()
                self.driver.find_element_by_xpath(self.ip).send_keys(
                    self.ip_data)

                # Select(self.driver.find_element_by_xpath(self.number).send_keys(self.number_data))
                Select(self.driver.find_element_by_xpath(
                    self.computer)).select_by_visible_text(self.computer_data)

                self.driver.find_element_by_xpath(self.other_ip).clear()
                self.driver.find_element_by_xpath(self.other_ip).send_keys(
                    self.other_ip_data)
                self.driver.find_element_by_xpath(self.asset_number).clear()
                self.driver.find_element_by_xpath(self.asset_number).send_keys(
                    self.asset_number_data)

                Select(self.driver.find_element_by_xpath(
                    self.device_type)).select_by_visible_text(
                        self.device_type_data)
                Select(self.driver.find_element_by_xpath(
                    self.device)).select_by_visible_text(self.device_data)

                self.driver.find_element_by_xpath(self.system).clear()
                self.driver.find_element_by_xpath(self.system).send_keys(
                    self.system_data)
                self.driver.find_element_by_xpath(self.equipment).clear()
                self.driver.find_element_by_xpath(self.equipment).send_keys(
                    self.equipment_data)
                self.driver.find_element_by_xpath(self.upper_time).clear()
                self.driver.find_element_by_xpath(self.upper_time).send_keys(
                    self.upper_time_data)
                self.driver.find_element_by_xpath(self.cpu_type).clear()
                self.driver.find_element_by_xpath(self.cpu_type).send_keys(
                    self.cpu_type_data)
                self.driver.find_element_by_xpath(self.cpu_number).clear()
                self.driver.find_element_by_xpath(self.cpu_number).send_keys(
                    self.cpu_number_data)
                self.driver.find_element_by_xpath(self.memory).clear()
                self.driver.find_element_by_xpath(self.memory).send_keys(
                    self.memory_data)
                self.driver.find_element_by_xpath(self.disk).clear()
                self.driver.find_element_by_xpath(self.disk).send_keys(
                    self.disk_data)
                self.driver.find_element_by_xpath(self.sn_number).clear()
                self.driver.find_element_by_xpath(self.sn_number).send_keys(
                    self.sn_number_data)
                self.driver.find_element_by_xpath(self.position).clear()
                self.driver.find_element_by_xpath(self.position).send_keys(
                    self.position_data)
                self.driver.find_element_by_xpath(self.remarks).clear()
                self.driver.find_element_by_xpath(self.remarks).send_keys(
                    self.remarks_data)
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(
                    self.preservation_button).click()
            else:
                self.driver.get_screenshot_as_file(screenshot())
                print('登录有误!!!')
        except Exception as e:
            self.driver.get_screenshot_as_file(screenshot())
            print('页面元素定位或者测试数据有误!!!', e)
Ejemplo n.º 8
0
    def host_add(self, host_data):
        try:
            self.login_page = login_page(host_data)
            self.driver = self.login_page.login()

            self.AST = self.login_page.login_pass()
            if self.AST == 'AST':
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.navigation).click()
                self.driver.find_element_by_xpath(self.asset_menu).click()
                self.driver.find_element_by_xpath(self.host_menu).click()
                self.driver.implicitly_wait(10)
                self.driver.find_element_by_xpath(self.add_button).click()
                self.driver.implicitly_wait(10)
                add_host_content = self.driver.find_element_by_xpath(
                    self.add_host_content).text
                assert '添加主机条目' == add_host_content

                self.driver.find_element_by_xpath(self.host_name).send_keys(
                    self.host_name_data)
                self.driver.find_element_by_xpath(self.ip).send_keys(
                    self.ip_data)

                # Select(self.driver.find_element_by_xpath(self.number).send_keys(self.number_data))
                Select(self.driver.find_element_by_xpath(
                    self.computer)).select_by_visible_text(self.computer_data)
                self.driver.implicitly_wait(10)

                self.driver.find_element_by_xpath(self.other_ip).send_keys(
                    self.other_ip_data)
                self.driver.find_element_by_xpath(self.asset_number).send_keys(
                    self.asset_number_data)

                Select(self.driver.find_element_by_xpath(
                    self.device_type)).select_by_visible_text(
                        self.device_type_data)
                Select(self.driver.find_element_by_xpath(
                    self.device)).select_by_visible_text(self.device_data)

                self.driver.find_element_by_xpath(self.system).send_keys(
                    self.system_data)
                self.driver.find_element_by_xpath(self.equipment).send_keys(
                    self.equipment_data)
                self.driver.find_element_by_xpath(self.upper_time).send_keys(
                    self.upper_time_data)
                self.driver.find_element_by_xpath(self.cpu_type).send_keys(
                    self.cpu_type_data)
                self.driver.find_element_by_xpath(self.cpu_number).send_keys(
                    self.cpu_number_data)
                self.driver.find_element_by_xpath(self.memory).send_keys(
                    self.memory_data)
                self.driver.find_element_by_xpath(self.disk).send_keys(
                    self.disk_data)
                self.driver.find_element_by_xpath(self.sn_number).send_keys(
                    self.sn_number_data)
                self.driver.find_element_by_xpath(self.position).send_keys(
                    self.position_data)
                self.driver.find_element_by_xpath(self.remarks).send_keys(
                    self.remarks_data)

                self.driver.find_element_by_xpath(self.submit_button).click()

                return self.host_name_data
            else:
                self.driver.get_screenshot_as_file(screenshot())
                print('登录有误!!!')
        except Exception as e:
            self.driver.get_screenshot_as_file(screenshot())
            print('主机添加页面有误!!!', e)
Ejemplo n.º 9
0
 def setUpClass(cls):
     print("from setupclass")
     cls.test_login_page = login_page()