def test_importName(self): Lgin.test_login(self) # 调用登录模块 time.sleep(1) driver = self.driver element = driver.find_element_by_xpath #点击名单导入按钮 ipmort_file = element("/html/body/div/div/div[1]/ul/li[1]") ipmort_file.click() #点击导入按钮 import_button = element( "/html/body/div/div/div[2]/div[2]/div/div/div[1]/div/div/button") import_button.click() #点击导入模板下载 import_demo = element( "/html/body/div/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/p[3]" ) import_demo.click() time.sleep(2) #点击导入模块的X import_close = element( "/html/body/div/div/div[2]/div[2]/div/div/div[4]/div/div/div[1]/button" ) import_close.click() #点击导出按钮 export_button = element( "/html/body/div/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[6]" ) export_button.click() time.sleep(2) #从排序位置开始 source = element( "/html/body/div/div/div[2]/div[2]/div/div/div[2]/table/tr[1]/th[1]" ) # 结束位置:定位到元素要移动到的目标位置 target = element( "/html/body/div/div/div[2]/div[2]/div/div/div[3]/div/div/span[1]") # 执行元素的拖放操作 ActionChains(self.driver).drag_and_drop(source, target).perform() time.sleep(1) #进行翻页 page2 = element( "/html/body/div/div/div[2]/div[2]/div/div/div[3]/div/div/ul/li[2]") page2.click() time.sleep(3) print('名单导入成功') #关闭浏览器 self.driver.quit()
def test_caseQuery(self): Lgin.test_login(self) # 调用登录模块 time.sleep(1) driver = self.driver element = driver.find_element_by_xpath #案件查询页面 case_query = element("/html/body/div/div/div[1]/ul/li[2]") case_query.click() #点击基础案件查询 basic_case = element( "/html/body/div/div/div[2]/div[1]/div/div/ul/li[1]/span") basic_case.click() #点击关键字搜索,输入姓名 keyword_query1 = element( "/html/body/div/div/div[2]/div[2]/div/div/div[1]/div/div/div/input" ) keyword_query1.send_keys("候云飞") #点击搜索按钮 search_button1 = element( "/html/body/div/div/div[2]/div[2]/div/div/div[1]/div/div/div/button" ) search_button1.click() time.sleep(2) #点击查看按钮 view_button = element( "/html/body/div/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[4]/span" ) view_button.click() time.sleep(2) #点击高级案件查询 advance_case = element( "/html/body/div/div/div[2]/div[1]/div/div/ul/li[2]") advance_case.click() #点击关键字搜索,输入姓名 keyword_query2 = element( "/html/body/div/div/div[2]/div[2]/div/div/div[1]/div/div/div/input" ) keyword_query2.send_keys("张三") #点击搜索按钮 search_button2 = element( "/html/body/div/div/div[2]/div[2]/div/div/div[1]/div/div/div/button" ) search_button2.click() time.sleep(2) self.driver.quit()
def test_cpa(self): Lgin.test_login(self) # 调用登录模块 time.sleep(1) driver = self.driver element = driver.find_element_by_xpath # -*-点击机构管理 org_manage = element("/html/body/div/div/div[1]/ul/li[5]") org_manage.click() # -*-CPA新增/编辑流量用户 cpa_org = element('//*[@id="app"]/div/div[2]/div[1]/div/div/ul/li[1]') cpa_org.click() time.sleep(2) # 点击添加流量机构 add_org = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div/button') add_org.click() time.sleep(1) # 输入机构名称 org_name = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[5]/div/div/div[2]/input' ) org_name.send_keys('屈层氏') time.sleep(1) # 选择机构属性 org_att = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[5]/div/div/div[3]/select' ) Select(org_att).select_by_visible_text('流量用户') element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[5]/div/div/div[4]/button' ).click() time.sleep(1) # 获取alert对话框 dig_alert = self.driver.switch_to.alert time.sleep(1) dig_alert.accept() time.sleep(2) # 筛选机构属性 org_select = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div[1]/select') Select(org_select).select_by_visible_text('流量用户') time.sleep(1) element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div[2]/button[1]' ).click() time.sleep(2) # 点击编辑按钮 edit_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[3]/table/tr[2]/td[6]/span[2]' ) edit_btn.click() time.sleep(1) # 点击增减平台按钮 add_plat = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div/button') add_plat.click() time.sleep(1) # 选择新建的平台 element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/div/div[1]/div/ul/li' ).click() rig_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/div/div[2]/button[1]' ) rig_btn.click() save_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[3]/button' ) save_btn.click() time.sleep(1) dig_alert.accept() time.sleep(1) # 编辑流量用户的系数 editp_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[8]/span[2]' ) editp_btn.click() # 注册系数 log_rate = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/p[4]/input' ) log_rate.clear() log_rate.send_keys('0.45') # 放款系数 loan_rate = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/p[5]/input' ) loan_rate.clear() loan_rate.send_keys('0.45') # 单价 price = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/p[6]/input' ) price.clear() price.send_keys('10') time.sleep(1) # 生效时间 effect_time = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/p[7]/select' ) Select(effect_time).select_by_visible_text('立即生效') time.sleep(2) element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[3]/button[1]' ).click() time.sleep(1) dig_alert.accept() time.sleep(3) # -*-CPA新增/编辑贷超用户 cpa_org = element('//*[@id="app"]/div/div[2]/div[1]/div/div/ul/li[1]') cpa_org.click() time.sleep(2) # 点击添加贷超机构 add_org = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div/button') add_org.click() time.sleep(1) # 输入机构名称 org_name = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[5]/div/div/div[2]/input' ) org_name.send_keys('伊朗') time.sleep(1) # 选择机构属性 org_att = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[5]/div/div/div[3]/select' ) Select(org_att).select_by_visible_text('贷超用户') element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[5]/div/div/div[4]/button' ).click() time.sleep(1) # 获取alert对话框 dig_alert = self.driver.switch_to.alert time.sleep(1) dig_alert.accept() time.sleep(2) # 筛选机构属性 org_select = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div[1]/select') Select(org_select).select_by_visible_text('贷超用户') time.sleep(1) element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div[2]/button[1]' ).click() time.sleep(2) # 点击编辑按钮 edit_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[3]/table/tr[2]/td[6]/span[2]' ) edit_btn.click() # 点击增减平台按钮 add_plat = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div/button') add_plat.click() time.sleep(1) # 选择新建的平台 element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/div/div[1]/div/ul/li[1]' ).click() rig_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/div/div[2]/button[1]' ) rig_btn.click() save_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[3]/button' ) save_btn.click() time.sleep(1) dig_alert.accept() time.sleep(1) # 编辑贷超用户的系数 editp_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[8]/span[2]' ) editp_btn.click() # 注册系数 log_rate = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/p[4]/input' ) log_rate.clear() log_rate.send_keys('0.45') # 点击系数 click_rate = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/p[5]/input' ) click_rate.clear() click_rate.send_keys('0.45') # 单价 price = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/p[6]/input' ) price.clear() price.send_keys('10') time.sleep(1) # 生效时间 effect_time = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]/p[7]/select' ) Select(effect_time).select_by_visible_text('立即生效') time.sleep(2) element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[3]/button[1]' ).click() time.sleep(1) dig_alert.accept() time.sleep(1) # -*-CPA新增/编辑贷超及流量用户完成 cpa_org = element('//*[@id="app"]/div/div[2]/div[1]/div/div/ul/li[1]') cpa_org.click() time.sleep(2) print('CPA新增/编辑贷超及流量用户完成')
def test_DaiChao(self): Lgin.test_login(self) # 调用登录模块 time.sleep(1) driver = self.driver element = driver.find_element_by_xpath #点击用户管理 userManage = element('//*[@id="app"]/div/div[1]/ul/li[6]') userManage.click() time.sleep(2) #点击贷超用户 daichaoU = element('//*[@id="app"]/div/div[2]/div[1]/div/div/ul/li[1]') daichaoU.click() time.sleep(1) # 创建流量用户-》修改账号及平台名称 creatLL = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div[5]/div/button' ) creatLL.click() time.sleep(2) # 选择落地页 element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[1]/div/div/div[1]/input' ).click() time.sleep(1) element('/html/body/div[2]/div[1]/div[1]/ul/li[3]').click() time.sleep(1) account = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[2]/div/div/input' ) account.send_keys('mali') platform = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[3]/div/div/input' ) platform.send_keys('玛丽') origin_amount = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[4]/div/div[1]/input' ) origin_amount.send_keys('100') tel = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[5]/div/div[1]/input' ) tel.send_keys('13313331333') origin_pwd = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[6]/div/div[1]/input' ) origin_pwd.send_keys('a111111') confirm_pwd = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[7]/div/div[1]/input' ) confirm_pwd.send_keys('a111111') creat_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[8]/div/button[1]' ) creat_btn.click() time.sleep(1) # 切换至alert并打印、接受alert dig_alert = driver.switch_to_alert() print(dig_alert.text) dig_alert.accept() time.sleep(3) print('新建流量用户成功!') # 创建贷超用户——>修改账号及平台名称 creatDC = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div[6]/div/button' ) creatDC.click() time.sleep(1) # 选择平台类型 plat = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[1]/div/div/div[1]/input' ) plat.click() time.sleep(1) element('/html/body/div[2]/div[1]/div[1]/ul/li[1]').click() time.sleep(1) account = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[2]/div/div/input' ) account.send_keys('dog') platform = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[3]/div/div/input' ) platform.send_keys('小黑') tel = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[4]/div/div[1]/input' ) tel.send_keys('13313331333') opwd = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[5]/div/div[1]/input' ) opwd.send_keys('a111111') cpwd = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[6]/div/div[1]/input' ) cpwd.send_keys('a111111') creat_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[7]/div/button[1]' ) # 模拟鼠标滑动至创建按钮处 ActionChains(driver).move_to_element(creat_btn).perform() time.sleep(1) creat_btn.click() time.sleep(2) dig_alert.accept() time.sleep(5) print('新建贷超用户成功!') # 搜索当前状态+角色名称+关键字搜索改为新建的流量用户 status = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div[1]/select' ) Select(status).select_by_visible_text('未冻结') uname = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div[2]/select' ) Select(uname).select_by_visible_text('流量用户') kwd = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div[3]/div/input' ) kwd.send_keys('玛丽') search_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div[4]/button[1]' ) search_btn.click() time.sleep(2) clear_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div[4]/button[2]' ) clear_btn.click() uname = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div[2]/select' ) Select(uname).select_by_visible_text('贷超用户') search_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div[4]/button[1]' ) search_btn.click() time.sleep(2) clear_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div[4]/button[2]' ) clear_btn.click() print('搜索成功!') # 编辑用户信息 edit = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[9]/span[2]/span' ) edit.click() time.sleep(1) edit_opd = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[4]/div/div/input' ) edit_opd.send_keys('a111111') edit_npd = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[5]/div/div/input' ) edit_npd.send_keys('a111111') edit_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div/form/div[6]/div/button[1]' ) edit_btn.click() time.sleep(1) dig_alert.accept() time.sleep(3) print('编辑用户成功') # 冻结用户 # 1、点击冻结按钮,选择立即冻结,接受弹框 freeze = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[9]/span[1]' ) freeze.click() time.sleep(1) now_freeze = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[1]' ) now_freeze.click() element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[3]/button' ).click() time.sleep(1) dig_alert.accept() time.sleep(3) # 2、点击解除按钮,选择立即冻结,接受弹框 unfreeze = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[9]/span[1]' ) unfreeze.click() time.sleep(1) dig_alert.accept() time.sleep(3) # 3、点击冻结按钮,选择7天后冻结,接受弹框 freeze = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[9]/span[1]' ) freeze.click() time.sleep(1) seven_freeze = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div[2]' ) seven_freeze.click() element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[3]/button' ).click() time.sleep(1) dig_alert.accept() time.sleep(3) print('冻结及解冻用户成功') #关闭浏览器 driver.quit()
def test_luopage(self): Lgin.test_login(self) # 调用登录模块 time.sleep(1) driver = self.driver element = driver.find_element_by_xpath # 点击用户管理 userManage = element('//*[@id="app"]/div/div[1]/ul/li[6]') userManage.click() time.sleep(2) # 点击落地页 page = element('//*[@id="app"]/div/div[2]/div[1]/div/div/ul/li[3]') page.click() time.sleep(1) # 点击新建按钮 new_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div/div/div/button' ) new_btn.click() time.sleep(1) # 1、输入落地页名称,2、选择产品名称,3、选择额度,4、产品名称关联落地页链接,5、保存 ldy_name = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div/div/form/div[1]/div/div/input' ) ldy_name.send_keys('我享花随便花') pro_name = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div/div/form/div[2]/div/div/div[1]/input' ) pro_name.click() time.sleep(1) element('/html/body/div[2]/div[1]/div[1]/ul/li[4]').click() time.sleep(1) amount = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div/div/form/div[3]/div/div/div[1]/input' ) amount.click() time.sleep(1) element('/html/body/div[3]/div[1]/div[1]/ul/li[6]').click() time.sleep(1) save_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div/div/form/div[5]/div/button[1]' ) save_btn.click() time.sleep(1) dig_alert = self.driver.switch_to_alert() dig_alert.accept() time.sleep(1) dig_alert.accept() time.sleep(2) # 编辑:1、编辑产品名称,2、编辑额度,3、保存 edit_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[3]/table/tr[2]/td[6]/button[2]/span' ) edit_btn.click() edit_pro = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div/div/form/div[2]/div/div/div[1]/input' ) edit_pro.click() time.sleep(1) element('/html/body/div[2]/div[1]/div[1]/ul/li[2]').click() time.sleep(1) element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div/div/form/div[3]/div/div/div[1]/input' ).click() time.sleep(1) element('/html/body/div[3]/div[1]/div[1]/ul/li[3]').click() time.sleep(1) save_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div/div/form/div[5]/div/button[1]' ) save_btn.click() dig_alert = self.driver.switch_to_alert() dig_alert.accept() time.sleep(1) dig_alert.accept() time.sleep(2) # 冻结+解冻 freeze_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[3]/table/tr[2]/td[6]/button[1]/span' ) freeze_btn.click() time.sleep(1) dig_alert.accept() time.sleep(1) unfreeze = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[3]/table/tr[2]/td[6]/button[1]/span' ) unfreeze.click() time.sleep(1) dig_alert.accept() time.sleep(1) # 产品名称+关键字筛选 pro_name = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div[1]/select') Select(pro_name).select_by_visible_text('我要花') kwd = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div[2]/div/input') kwd.send_keys('哈哈哈') search_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div[3]/button[1]') search_btn.click() time.sleep(1) clear_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/div[3]/button[2]') clear_btn.click() time.sleep(1) print("落地页:新建、编辑、冻结及筛选完成") # 关闭浏览器 driver.quit()
def test_up_manage(self): Lgin.test_login(self) # 调用登录模块 time.sleep(2) driver = self.driver element = driver.find_element_by_xpath # 点击贷超管理 dc_mana = element('//*[@id="app"]/div/div[1]/ul/li[4]') dc_mana.click() time.sleep(2) # 点击产品上架管理 putaway = element('//*[@id="app"]/div/div[2]/div[1]/div/div/ul/li[1]') putaway.click() time.sleep(2) # 点击添加海报 add_banner = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div[1]/div[2]/div/button' ) add_banner.click() time.sleep(1) element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div/ul/li[3]/div/div' ).click() time.sleep(1) # 调用上传banner.exe上传程序 os.system("C:\\Users\\22648\\Desktop\\test\\自动化上传文件\\数据平台添加产品海报.exe") time.sleep(1) link = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/div/ul/li[3]/input' ) link.clear() time.sleep(1) link.send_keys('http://h5.super.com/') time.sleep(1) element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[3]/div/button[1]' ).click() time.sleep(1) dig_alert = self.driver.switch_to_alert() dig_alert.accept() time.sleep(1) dig_alert.accept() add_banner = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div[1]/div[2]/div/button' ) add_banner.click() element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[1]/button/span' ).click() time.sleep(1) # 添加产品:修改产品名称+产品链接 add_pro = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div[1]/div[1]/div/button' ) add_pro.click() time.sleep(1) pro_name = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[1]/div/div/input' ) pro_name.send_keys('京东') pro_rate = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[2]/div/div[1]/input' ) pro_rate.send_keys('1%') pro_date = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[3]/div/div[1]/input' ) pro_date.send_keys('7') pro_amount = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[4]/div/div[1]/input' ) pro_amount.send_keys('1000') pro_targe1 = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[5]/div/div[1]/label[1]/span[1]/span' ) pro_targe1.click() pro_targe2 = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[5]/div/div[1]/label[2]/span[1]/span' ) pro_targe2.click() pro_type1 = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[6]/div/div[1]/label[1]/span[1]/span' ) pro_type1.click() pro_type2 = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[6]/div/div[1]/label[6]/span[1]/span' ) pro_type2.click() pro_introduce = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[7]/div/div[1]/textarea' ) pro_introduce.send_keys('自动添加产品的测试简介') loan_time = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[8]/div/div[1]/textarea' ) loan_time.send_keys('自动测试') element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[9]/div/div[1]/div/div/i' ).click() time.sleep(1) # 调用上传banner.exe上传程序 os.system("C:\\Users\\22648\\Desktop\\test\\自动化上传文件\\数据平台添加产品海报.exe") time.sleep(5) apply_status = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[10]/div/div[1]/textarea' ) apply_status.send_keys('自动测试') save_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[3]/button' ) ActionChains(self.driver).move_to_element(save_btn).perform() time.sleep(1) apply_condition = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[11]/div/div/textarea' ) apply_condition.send_keys('你好,自动化测试') need_info = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[12]/div/div/textarea' ) need_info.send_keys('你好,自动化测试') back_link = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[13]/div/div/input' ) back_link.send_keys('https://fanyi.baidu.com/translate?') back_account = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[14]/div/div/input' ) back_account.send_keys('test') back_pwd = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[15]/div/div/input' ) back_pwd.send_keys('abc123') pro_link = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[16]/div/div/input' ) pro_link.send_keys('https://miaosha.jd.com/pinpailist.html') save_btn.click() time.sleep(1) dig_alert.accept() time.sleep(5) # 点击上架按钮 upload = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[9]/button[1]/span' ) upload.click() time.sleep(2) comfirm = element('/html/body/div[2]/div/div[3]/button[2]') comfirm.click() time.sleep(5) # 点击产品短链 short_link = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[8]/a' ) short_link.click() time.sleep(1) # 切换窗口至新开的页面 driver.switch_to.window(driver.window_handles[-1]) time.sleep(5) # 切换窗口回原来的页面,根据索引进行切换 self.driver.switch_to_window(driver.window_handles[0]) time.sleep(5) # 编辑——编辑短链 edit_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/table/tr[2]/td[9]/button[2]/span' ) edit_btn.click() time.sleep(1) save_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[3]/button' ) ActionChains(self.driver).move_to_element(save_btn).perform() time.sleep(1) pro_link = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[4]/div/div/div[2]/form/div[16]/div/div/input' ) pro_link.clear() time.sleep(1) pro_link.send_keys('https://miaosha.jd.com/') save_btn.click() time.sleep(1) dig_alert.accept() time.sleep(5) # 移除 remove = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[2]/table/tr[5]/td[9]/button[3]/span' ) remove.click() time.sleep(1) comfirm = element('/html/body/div[2]/div/div[3]/button[2]') comfirm.click() time.sleep(5) # 筛选状态+产品名称 present_status = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div[2]/div[1]/select' ) Select(present_status).select_by_visible_text('已上架') kwd = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div[2]/div[2]/div/input' ) kwd.send_keys('京东') search_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div[2]/div[3]/button[1]' ) search_btn.click() time.sleep(1) clear_btn = element( '//*[@id="app"]/div/div[2]/div[2]/div/div/div[1]/div[2]/div[3]/button[2]' ) clear_btn.click() time.sleep(5) print('产品上架管理:添加产品海报、添加产品、编辑、移除、上架、状态+名称搜索成功!') # 关闭浏览器 self.driver.quit()