class TestCase95DevManageBatchSaleByNoDev(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.driver.wait(1) self.driver.clear_cookies() self.assert_text = AssertText() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_dev_manage_batch_sale_by_no_dev(self): # 打开途强在线首页-登录页 self.base_page.open_page() self.log_in_base.log_in() # 点击进入设备管理 self.dev_manage_page.enter_dev_manage() # 点击批量 self.dev_manage_page.click_batch_sale_button() self.dev_manage_page.click_close_batch_sale_button() self.dev_manage_page.click_batch_sale_button() # 验证界面 get_sale_title = self.dev_manage_page.get_sale_title_text_in_sale_dev() self.assertEqual(self.assert_text.batch_sale_text(), get_sale_title) # 搜索框输入多个设备IMEI,点击添加(设备之间用enter键、逗号隔开) self.dev_manage_page.add_imei_in_sale_dev_page( '121201234567889,867597011453591') get_dev_in_list_number = self.dev_manage_page.get_dev_in_list_number() self.assertEqual(2, get_dev_in_list_number) # 搜索框输入多个设备IMEI,点击添加(设备之间不用enter键、逗号隔开,而用空格隔开) self.dev_manage_page.add_imei_in_sale_dev_page( '121201234567889867597011453591') add_dev_state = self.dev_manage_page.add_dev_after_fail_state() self.assertEqual(self.assert_text.dev_page_fail_text(), add_dev_state) add_dev_reason = self.dev_manage_page.add_dev_after_fail_reason() self.assertEqual(self.assert_text.dev_page_inexistence_text(), add_dev_reason) self.dev_manage_page.click_close_fails() # 不选择销售对象进行销售 self.dev_manage_page.click_sale_button() # text = self.dev_manage_page.get_error_text_after_ensure() # self.assertEqual(self.assert_text.glob_search_please_add_account_text(), text) # 点击重置的按钮 self.dev_manage_page.click_clear_button_in_dev_sale() get_dev_in_list_number = self.dev_manage_page.get_dev_in_list_number() self.assertEqual(0, get_dev_in_list_number)
class TestCase88DevManageSaleInList(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.connect_sql = ConnectSql() self.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_dev_manage_sale_in_list(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 点击进入设备管理 self.dev_manage_page.enter_dev_manage() imei_in_list = self.dev_manage_page.get_imei_in_list() dev_type_in_list = self.dev_manage_page.get_dev_type_in_list() # 点击批量 self.dev_manage_page.click_sale_in_list_button() self.dev_manage_page.click_close_sale_in_list_button() self.dev_manage_page.click_sale_in_list_button() # 点击销售 self.dev_manage_page.click_sale_button() # 获取打开销售之后的imei和设备类型 imei_in_sale = self.dev_manage_page.get_imei_in_sale() self.assertEqual(imei_in_list, imei_in_sale) dev_type_in_sale = self.dev_manage_page.get_dev_type_in_sale() self.assertEqual(dev_type_in_list, dev_type_in_sale) dev_account_name = self.dev_manage_page.get_dev_account_name() connect = self.connect_sql.connect_tuqiang_sql() cursor = connect.cursor() get_account_sql = "select o.account from equipment_mostly e inner join user_info o on e.userId = o.userId where e.imei = '%s';" % imei_in_list cursor.execute(get_account_sql) account_data = cursor.fetchall() account = account_data[0][0] cursor.close() connect.close() self.assertEqual(dev_account_name, account) # 搜索右侧客户树 # 循环点击5次 for n in range(5): self.driver.click_element( 'x,//*[@id="treeDemo_device_sale_id_%s_span"]' % str(n + 1)) sleep(2) # 判断数量 get_account_dev_number = self.driver.get_text( 'x,//*[@id="treeDemo_device_sale_id_%s_span"]' % str(n + 1)) name = self.dev_manage_page.get_select_account_name() self.assertEqual(get_account_dev_number, name) # 搜索无数据 self.dev_manage_page.search_customer_after_click_batch_sale_dev('无数据') get_text = self.dev_manage_page.get_search_customer_no_data_text_after_batch_sale_dev( ) self.assertIn(self.assert_text.account_center_page_no_data_text(), get_text) # 获取选中设备的数量 dev_number = self.dev_manage_page.get_select_dev_number() # 获取抬头设备统计的数量 dev_numbers_count = self.dev_manage_page.get_dev_numbers() self.assertEqual(str(dev_number), dev_numbers_count) # 删除设备后 点击销售 self.dev_manage_page.click_detele_dev() self.dev_manage_page.click_sale_button() ### 添加设备 # 成功添加的 self.dev_manage_page.add_dev_to_sale(imei_in_list) # 添加重复的 self.dev_manage_page.add_dev_to_sale(imei_in_list) # 获取失败后的imei imei_after_add_fail = self.dev_manage_page.get_imei_after_add_fail() self.assertEqual(imei_in_list, imei_after_add_fail) status = self.dev_manage_page.get_status_after_add_fail() self.assertEqual(self.assert_text.dev_page_fail_text(), status) fail_reason = self.dev_manage_page.get_fail_reason() self.assertEqual(self.assert_text.dev_page_repetition_text(), fail_reason) self.dev_manage_page.click_close_fails() # 添加不存在的imei self.dev_manage_page.add_dev_to_sale('我就是要添加不存在的') # 获取失败后的imei imei_after_add_fail = self.dev_manage_page.get_imei_after_add_fail() self.assertEqual('我就是要添加不存在的', imei_after_add_fail) status = self.dev_manage_page.get_status_after_add_fail() self.assertEqual(self.assert_text.dev_page_fail_text(), status) fail_reason = self.dev_manage_page.get_fail_reason() self.assertEqual(self.assert_text.dev_page_inexistence_text(), fail_reason) self.dev_manage_page.click_close_fails()
class TestCase82DevManageBatchSale(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.driver.wait(1) self.driver.clear_cookies() self.assert_text = AssertText() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_dev_manage_batch_sale(self): # 打开途强在线首页-登录页 self.base_page.open_page() self.log_in_base.log_in() # 点击进入设备管理 self.dev_manage_page.enter_dev_manage() # 选择一个设备点击批量销售 self.dev_manage_page.choose_one_dev_to_search() get_first_imei = self.dev_manage_page.get_first_imei_in_list() get_dev_type = self.dev_manage_page.get_dev_type_in_list() # 点击批量 self.dev_manage_page.click_batch_sale_button() self.dev_manage_page.click_close_batch_sale_button() self.dev_manage_page.click_batch_sale_button() '''# 搜索右侧客户树 # 循环点击5次 for n in range(5): self.driver.click_element('x,//*[@id="treeDemo_device_sale_id_%s_span"]' % str(n + 1)) sleep(2) # 判断数量 get_account_dev_number = self.driver.get_text('x,//*[@id="treeDemo_device_sale_id_%s_span"]' % str(n + 1)) name = self.dev_manage_page.get_select_account_name() self.assertEqual(get_account_dev_number, name) # 搜索无数据 self.dev_manage_page.search_customer_after_click_batch_sale_dev('无数据') get_text = self.dev_manage_page.get_search_customer_no_data_text_after_batch_sale_dev() self.assertIn(self.assert_text.account_center_page_no_data_text(), get_text) # 获取选中设备的数量 dev_number = self.dev_manage_page.get_select_dev_number() # 获取抬头设备统计的数量 dev_numbers_count = self.dev_manage_page.get_dev_numbers() self.assertEqual(str(dev_number), dev_numbers_count)''' # 验证界面 get_sale_title = self.dev_manage_page.get_sale_title_text_in_sale_dev() self.assertEqual(self.assert_text.batch_sale_text(), get_sale_title) get_imei_in_sale = self.dev_manage_page.get_batch_sale_imei_in_sale_dev() self.assertEqual(get_first_imei, get_imei_in_sale) get_dev_type_in_sale = self.dev_manage_page.get_dev_type_in_sale() self.assertEqual(get_dev_type, get_dev_type_in_sale) get_dev_number = self.dev_manage_page.get_dev_number_in_sale_dev() self.assertEqual('1', get_dev_number) get_dev_account = self.dev_manage_page.get_dev_account_name() connect_sql = ConnectSql() connect = connect_sql.connect_tuqiang_sql() cursor = connect.cursor() sql = "select m.account from equipment_mostly m where m.imei = '%s';" % get_first_imei cursor.execute(sql) data = cursor.fetchall() cursor.close() connect.close() sql_account = data[0][0] self.assertEqual(get_dev_account, sql_account) # 输入不存在的IMEI号进行添加 self.dev_manage_page.add_imei_in_sale_dev_page('bucunzai') add_dev_state = self.dev_manage_page.add_dev_after_fail_state() self.assertEqual(self.assert_text.dev_page_fail_text(), add_dev_state) add_dev_reason = self.dev_manage_page.add_dev_after_fail_reason() self.assertEqual(self.assert_text.dev_page_inexistence_text(), add_dev_reason) self.dev_manage_page.click_close_fails() # 添加不属于当前登陆账号设备总进货数中的设备 self.dev_manage_page.add_imei_in_sale_dev_page('863666010079196') add_dev_state = self.dev_manage_page.add_dev_after_fail_state() self.assertEqual(self.assert_text.dev_page_fail_text(), add_dev_state) add_dev_reason = self.dev_manage_page.add_dev_after_fail_reason() self.assertEqual(self.assert_text.dev_page_inexistence_text(), add_dev_reason) self.dev_manage_page.click_close_fails() # 添加与设备列表中重复的设备 self.dev_manage_page.add_imei_in_sale_dev_page(get_first_imei) add_dev_state = self.dev_manage_page.add_dev_after_fail_state() self.assertEqual(self.assert_text.dev_page_fail_text(), add_dev_state) add_dev_reason = self.dev_manage_page.add_dev_after_fail_reason() self.assertEqual(self.assert_text.dev_page_repetition_text(), add_dev_reason) self.dev_manage_page.click_close_fails() # 搜索右侧客户树 # 循环点击5次 for n in range(5): self.driver.click_element('x,//*[@id="treeDemo_device_sale_id_%s_span"]' % str(n + 1)) sleep(2) # 判断数量 get_account_dev_number = self.driver.get_text('x,//*[@id="treeDemo_device_sale_id_%s_span"]' % str(n + 1)) name = self.dev_manage_page.get_select_account_name() self.assertEqual(get_account_dev_number, name) # 搜索无数据 self.dev_manage_page.search_customer_after_click_batch_sale_dev('无数据') get_text = self.dev_manage_page.get_search_customer_no_data_text_after_batch_sale_dev() self.assertIn(self.assert_text.account_center_page_no_data_text(), get_text) # 获取选中设备的数量 dev_number = self.dev_manage_page.get_select_dev_number() # 获取抬头设备统计的数量 dev_numbers_count = self.dev_manage_page.get_dev_numbers() self.assertEqual(str(dev_number), dev_numbers_count)
class TestCase101DevManageBatchSetOverdueTime(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_dev_manage_search_dev_after_issued_work_type(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in_jimitest() # 点击进入设备管理 self.dev_manage_page.enter_dev_manage() imei_in_list = self.dev_manage_page.get_imei_in_list() # 点击批量设置用户到期时间 self.dev_manage_page.click_batch_set_user_overdue_time_button() # 点击关闭 self.dev_manage_page.click_close_set_user_overdue_time_button() # 点击批量设置用户到期时间 self.dev_manage_page.click_batch_set_user_overdue_time_button() # 点击关闭 self.dev_manage_page.click_clance_set_user_overdue_time_button() # 点击批量设置用户到期时间 self.dev_manage_page.click_batch_set_user_overdue_time_button() # 验证界面 text = self.dev_manage_page.get_text_after_click_set_user_overdue_time_button() self.assertEqual(self.assert_text.batch_set_user_overdue_time_text(), text) # 点击添加imei self.dev_manage_page.click_add_imei_to_set_user_overdue_time('不存在') # 获取失败的状态和原因 fail_status = self.dev_manage_page.get_fail_status_after_clcik_ensure() self.assertEqual(self.assert_text.dev_page_fail_text(), fail_status) fail_reason = self.dev_manage_page.get_fail_reason_after_click_ensure() self.assertEqual(self.assert_text.dev_page_inexistence_text(), fail_reason) # 点击关闭 self.dev_manage_page.click_close_fails() # 点击添加imei self.dev_manage_page.click_add_imei_to_set_user_overdue_time(imei_in_list) self.dev_manage_page.click_add_imei_to_set_user_overdue_time(imei_in_list) # 获取失败的状态和原因 fail_status = self.dev_manage_page.get_fail_status_after_clcik_ensure() self.assertEqual(self.assert_text.dev_page_fail_text(), fail_status) fail_reason = self.dev_manage_page.get_fail_reason_after_click_ensure() self.assertEqual(self.assert_text.dev_page_repetition_text(), fail_reason) # 点击关闭 self.dev_manage_page.click_close_fails()