def test_free_search(self): """免费商标查询测试""" dl = DengLuPage(self.driver) # 官方推荐有find_element(By.*(""))代替find_element_by_*("") # self.driver.find_element_by_id() # self.driver.find_element() dl.login() time.sleep(2) try: self.driver.find_elements_by_css_selector( ".modal-body > .close")[0].click() except Exception: pass ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > h3 > span" )).perform() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > h3 > a" )).perform() ActionChains(self.driver).release() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > div > dl:nth-child(2) > dd > a:nth-child(1)" ).click() time.sleep(3) # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) self.assertIn("注册商标查询_中国商标查询_权大师官网", self.driver.title) print(self.driver.title) get_screenshort(self.driver, "test_free_search.png")
def test_rjzr(self): """软件著作权转让测试""" dl = DengLuPage(self.driver) dl.login() time.sleep(2) try: self.driver.find_elements_by_css_selector(".modal-body > .close")[0].click() except Exception: pass ActionChains(self.driver).move_to_element(self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > h3 > span")).perform() time.sleep(2) ActionChains(self.driver).move_to_element(self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(3) > h3 > a")).perform() ActionChains(self.driver).release() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(3) > div > dl:nth-child(3) > dd > a:nth-child(3)").click() time.sleep(3) # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) self.assertIn("软件著作权转让-权大师", self.driver.title) print(self.driver.title) for a in self.driver.find_elements_by_css_selector("#total-price"): print("费用总计:" + a.text) aa = a.text self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-btnBuy > a.btn.btn-next.buynow").click() self.driver.find_element_by_name("ownerContactPerson").send_keys("{}".format(unicode())) self.driver.find_element_by_name("ownerContactPhone").send_keys("15624992498") self.driver.find_element_by_name("contactMail").send_keys("*****@*****.**") self.driver.find_element_by_css_selector("#remark").send_keys(time.strftime("%Y-%m-%d_%H-%M-%S") + "测试订单") get_screenshort(self.driver, "test_rjzr.png") for i in self.driver.find_elements_by_css_selector( "body > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(6) > div.last-pay.personal-last-pay > ul > li.row-sense > em > i"): print("总价:" + i.text) ii = i.text self.assertIn(aa, ii) print("价格一致") self.driver.find_element_by_css_selector( "body > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(6) > div.btns > a.btn-next.submitOrder").click() for o in self.driver.find_elements_by_class_name("payable"): print("订单提交成功,应付金额:" + o.text) oo = o.text self.assertIn(oo, ii) print("测试通过") self.driver.find_element_by_css_selector("#alisubmit").click()
def test_rjzz_j(self): """软件著作权登记""" # logging.basicConfig(filename='../LOG/' + __name__ + '.log', # format='[%(asctime)s-%(filename)s-%(levelname)s: %(message)s]', level=logging.DEBUG, # filemode='a', datefmt='%Y-%m-%d%I:%M:%S %p') dl = DengLuPage(self.driver) dl.login() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > h3 > span" )).perform() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(3) > h3 > a" )).perform() ActionChains(self.driver).release() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(3) > div > dl:nth-child(1) > dd > a:nth-child(1)" ).click() time.sleep(2) self.assertIn("软件著作权登记加急-权大师", self.driver.title) print(self.driver.title) self.driver.find_element_by_css_selector( "#serviceName > li:nth-child(2)").click() self.driver.find_element_by_xpath("//*[@id=\"urgent\"]/li[1]").click() # WebElement' object is not iterable # element + s (解决) for c in self.driver.find_elements_by_xpath( "//*[@id=\"total-price\"]"): print("费用总计:" + c.text) cc = c.text self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-btnBuy > a.btn.btn-next.buynow" ).click() self.driver.find_element_by_name("ownerContactPerson").send_keys( "{}".format(unicode())) self.driver.find_element_by_name("ownerContactPhone").send_keys( "15624992498") self.driver.find_element_by_name("contactMail").send_keys( "*****@*****.**") self.driver.find_element_by_css_selector("#remark").send_keys( time.strftime("%Y-%m-%d_%H-%M-%S") + "测试订单") get_screenshort(self.driver, "test_rjzz_j.png") for i in self.driver.find_elements_by_css_selector( "body > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(6) > div.last-pay.personal-last-pay > ul > li.row-sense > em > i" ): print("总价:" + i.text) ii = i.text self.assertIn(cc, ii) print("价格一致") self.driver.find_element_by_css_selector( "body > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(6) > div.btns > a.btn-next.submitOrder" ).click() for o in self.driver.find_elements_by_class_name("payable"): print("订单提交成功,应付金额:" + o.text) oo = o.text self.assertIn(oo, ii) print("测试通过") self.driver.find_element_by_css_selector("#alisubmit").click()
def _monitor_2(self): """初审公告监控测试""" dl = DengLuPage(self.driver) dl.login() time.sleep(1) self.driver.find_element_by_link_text("智能工具").click() time.sleep(2) self.driver.find_element_by_link_text("商标监控").click() windows = self.driver.window_handles self.driver.switch_to.window(windows[-1]) time.sleep(2) self.driver.set_window_size(1920, 1080) self.assertIn("商标监控首页_权大师", self.driver.title) print(self.driver.title) self.driver.find_element_by_css_selector( "body > div.brandMonitor-wrap > div > div.wrap > ul > li:nth-child(2) > a > i" ).click() self.driver.find_element_by_css_selector( "#city > select.myinput.select-sheng.prov").click() suiji = random.randint(1, 34) prov = self.driver.find_element_by_css_selector( "#city > select.myinput.select-sheng.prov > option:nth-child({})". format(suiji)).text self.driver.find_element_by_css_selector( "#city > select.myinput.select-sheng.prov > option:nth-child({})". format(suiji)).click() time.sleep(2) self.driver.find_element_by_css_selector( "#city > select.myinput.select-sheng.city").click() city = self.driver.find_element_by_css_selector( "#city > select.myinput.select-sheng.city > option:nth-child(1)" ).text self.driver.find_element_by_css_selector( "#city > select.myinput.select-sheng.city > option:nth-child(1)" ).click() print("地区选择:" + prov + "_" + str(city).replace("\n", " ")) brand = unicode() self.driver.find_element_by_css_selector( "body > div.brandMonitor-wrap > div > div > div.myPanel-bodyer > div.section1 > table > tbody > tr:nth-child(3) > td.td-content > input" ).send_keys(brand) print("商标名称:" + brand) jinsi = random.randint(2, 3) lx = self.driver.find_element_by_css_selector( "#jinsi > label:nth-child({})".format(jinsi)).text self.driver.find_element_by_css_selector( "#jinsi > label:nth-child({})".format(jinsi)).click() print(lx) self.driver.find_element_by_css_selector("#showleibie").click() suiji = random.randint(2, 46) add = self.driver.find_element_by_css_selector( "#leibie45 > label:nth-child({})".format(suiji)).text self.driver.find_element_by_css_selector( "#leibie45 > label:nth-child({})".format(suiji)).click() print(add) lb = self.driver.find_element_by_css_selector("#hot").text print(str(lb)) print("初审公告监控添加成功!") self.driver.find_element_by_css_selector( "body > div.brandMonitor-wrap > div > div > div.myPanel-bodyer > div.section2 > div > a" ).click() time.sleep(1) self.driver.find_element_by_css_selector( "#addSuccessModal > div > div > table > tbody > tr.tr-2 > td > div > a.mybtn.mybtn-inverse.btn-sure" ).click() time.sleep(1) info = self.driver.find_element_by_css_selector( "body > div.brandMonitor-wrap > div > div > div.myPanel-bodyer.brandMonitor-all > div > table > tbody > tr:nth-child(1)" ).text get_screenshort(self.driver, "test_monitor_2.png") print("监控信息" + str(info)) print("信息无误,测试通过!")
def test_fmzlbz_2(self): """标准型-多个申请人减缓""" # logging.basicConfig(filename='../LOG/' + __name__ + '.log', # format='[%(asctime)s-%(filename)s-%(levelname)s: %(message)s]', level=logging.DEBUG, # filemode='a', datefmt='%Y-%m-%d%I:%M:%S %p') dl = DengLuPage(self.driver) dl.login() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > h3 > span" )).perform() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(2) > h3 > a" )).perform() ActionChains(self.driver).release() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(2) > div > dl:nth-child(2) > dd > a:nth-child(1)" ).click() time.sleep(2) self.assertIn("发明专利标准申请|专利申请|专利查询|权大师", self.driver.title) print(self.driver.title) # self.driver.find_element_by_css_selector("#slowItems > label.label.active > input[type=\"checkbox\"]") #单个申请人减缓 self.driver.find_element_by_css_selector( "#slowItems > label:nth-child(2)").click() # 多个申请人减缓 # self.driver.find_element_by_css_selector("#slowItems > label:nth-child(3) > input[type=\"checkbox\"]") #不减缓 print("服务类别:" + self.driver.find_element_by_css_selector( "#serviceName > li.list.active").text + "_" + self.driver.find_element_by_css_selector( "#slowItems > label:nth-child(2)").text) self.driver.find_element_by_css_selector( "#serviceName > li.list.active").click() for a in self.driver.find_elements_by_css_selector("#total-price"): print("费用总计:" + a.text) aa = a.text self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-btnBuy > a.btn.btn-next.buynow" ).click() self.driver.find_element_by_name("ownerContactPerson").send_keys( "{}".format(unicode())) self.driver.find_element_by_name("ownerContactPhone").send_keys( "15624992498") self.driver.find_element_by_name("contactMail").send_keys( "*****@*****.**") self.driver.find_element_by_css_selector("#remark").send_keys( time.strftime("%Y-%m-%d_%H-%M-%S") + "测试订单") get_screenshort(self.driver, "test_fmzl_2.png") for i in self.driver.find_elements_by_css_selector( "body > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(6) > div.last-pay.personal-last-pay > ul > li.row-sense > em > i" ): print("总价:" + i.text) ii = i.text self.assertIn(aa, ii) print("价格一致") self.driver.find_element_by_css_selector( "body > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(6) > div.btns > a.btn-next.submitOrder" ).click() for o in self.driver.find_elements_by_class_name("payable"): print("订单提交成功,应付金额:" + o.text) oo = o.text self.assertIn(oo, ii) print("测试通过") self.driver.find_element_by_css_selector("#alisubmit").click()
def test_number3(self): """智能注册_全类商标跳转测试""" # logging.basicConfig(filename='../LOG/' + __name__ + '.log', # format='[%(asctime)s-%(filename)s-%(levelname)s:%(message)s]', level=logging.DEBUG, # filemode='a', datefmt='%Y-%m-%d%I:%M:%S %p') dl = DengLuPage(self.driver) # 官方推荐有find_element(By.*(""))代替find_element_by_*("") # self.driver.find_element_by_id() # self.driver.find_element() dl.login() time.sleep(2) ActionChains(self.driver).move_to_element(self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > h3 > span")).perform() time.sleep(2) ActionChains(self.driver).move_to_element(self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > h3 > a")).perform() ActionChains(self.driver).release() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > div > dl:nth-child(3) > dd > a:nth-child(3)").click() # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) time.sleep(2) self.driver.set_window_size(1920, 1080) self.assertIn("商标智能注册|商标注册查询|商标注册网-权大师", self.driver.title) print(self.driver.title) self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-serviceItems > table > tbody > tr > td.td-cont > ul > li:nth-child(3)").click() for a in self.driver.find_elements_by_css_selector("#total-price"): print("费用总计:" + a.text) # aa=a.text self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-btnBuy > a.btn.btn-next.buynow").click() time.sleep(2) self.driver.find_element_by_css_selector("body > div.recommend-help > i").click() # body > div.recommend-help > i # ss = credit_code("en.txt") ss = 'OLAY' self.driver.find_element_by_name("brandName").send_keys("{}".format(ss)) print("商标名称:{}".format(ss)) self.driver.find_element_by_css_selector("#create-tuyang > label.label.checked").click() self.driver.find_element_by_css_selector( "body > div.register-wrap.brandinfo-wrap > div.brand-info-wrap.show1.form-wrap > ul > li.brand-upload > div > div.brand-upload-wrap > div.zidongdong-create > ul > li > a").click() time.sleep(5) """全类保护""" self.driver.find_element_by_css_selector( "#selectCategoryType > label:nth-child(3)").click() time.sleep(20) print("选择类别:全类保护") xt = self.driver.find_element_by_css_selector( "#first01 > div.category-recommend-first > span.tips > a:nth-child(1)").text js = self.driver.find_element_by_css_selector( "#first01 > div.category-recommend-first > span.tips > a:nth-child(2)").text print(xt + js) number1 = re.sub(r"\D", "", xt) number2 = re.sub(r"\D", "", js) s2 = int(number1) + int(number2) print(s2) time.sleep(1) self.driver.find_element_by_css_selector( "#first01 > div.category-recommend-first > span.tips").click() time.sleep(2) windows = self.driver.window_handles self.driver.switch_to.window(windows[-1]) dl.refresh() time.sleep(3) # # self.driver.find_element_by_css_selector("body > div.page > div.search-help > div.tips.tips1 > a").click() # time.sleep(1) # self.driver.find_element_by_css_selector("body > div.page > div.search-help > div.tips.tips2 > a").click() # time.sleep(1) # self.driver.find_element_by_css_selector("body > div.page > div.search-help > div.tips.tips3 > a").click() # time.sleep(1) # self.driver.find_element_by_css_selector("body > div.page > div.search-help > div.tips.tips4 > a").click() time.sleep(1) number2 = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > div.search-top > i").text s3 = int(number2) + 0 print("权大师为您找到相关结果{}个".format(number2)) self.assertEqual(s2, s3,"相似商标数量不一致请及时查看!") print("检索相似商标数量一致,测试通过!")
def test_number1(self): """智能注册_自助商标跳转测试""" # logging.basicConfig(filename='../LOG/' + __name__ + '.log', # format='[%(asctime)s-%(filename)s-%(levelname)s:%(message)s]', level=logging.DEBUG, # filemode='a', datefmt='%Y-%m-%d%I:%M:%S %p') dl = DengLuPage(self.driver) # 官方推荐有find_element(By.*(""))代替find_element_by_*("") # self.driver.find_element_by_id() # self.driver.find_element() dl.login() time.sleep(2) ActionChains(self.driver).move_to_element(self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > h3 > span")).perform() time.sleep(2) ActionChains(self.driver).move_to_element(self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > h3 > a")).perform() ActionChains(self.driver).release() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > div > dl:nth-child(3) > dd > a:nth-child(3)").click() # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) time.sleep(2) self.driver.set_window_size(1920, 1080) self.assertIn("商标智能注册|商标注册查询|商标注册网-权大师", self.driver.title) print(self.driver.title) self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-serviceItems > table > tbody > tr > td.td-cont > ul > li:nth-child(3)").click() for a in self.driver.find_elements_by_css_selector("#total-price"): print("费用总计:" + a.text) # aa=a.text self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-btnBuy > a.btn.btn-next.buynow").click() time.sleep(2) self.driver.find_element_by_css_selector("body > div.recommend-help > i").click() # body > div.recommend-help > i ss = "小米" self.driver.find_element_by_name("brandName").send_keys("{}".format(ss)) print("商标名称:{}".format(ss)) self.driver.find_element_by_css_selector("#create-tuyang > label.label.checked").click() self.driver.find_element_by_css_selector( "body > div.register-wrap.brandinfo-wrap > div.brand-info-wrap.show1.form-wrap > ul > li.brand-upload > div > div.brand-upload-wrap > div.zidongdong-create > ul > li > a").click() time.sleep(5) self.driver.find_element_by_css_selector( "#selectCategoryType > label:nth-child(2)").click() self.driver.execute_script("window.scrollBy(0,1200)") # 滑动滚动条 suiji = random.randint(2, 45) time.sleep(2) self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li:nth-child({}) > span".format(suiji)).click() time.sleep(2) self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div:nth-child(2) > span").click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(1) > span").click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(2) > span").click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(3) > span").click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(4) > span").click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(5) > span").click() # self.driver.find_element_by_css_selector( # "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(6) > span").click() # self.driver.find_element_by_css_selector( # "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(7) > span").click() # self.driver.find_element_by_css_selector( # "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(8) > span").click() # self.driver.find_element_by_css_selector( # "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(9) > span").click() # self.driver.find_element_by_css_selector( # "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(10) > span").click() print("选择了第{}类商标分类!".format(suiji)) zf = self.driver.find_element_by_css_selector("#section-selfchoice > div > div.group-right > div > div > h4 > div.header-left > a > span").text print(zf) number1 = re.sub(r"\D", "", zf) print(number1) time.sleep(1) self.driver.find_element_by_css_selector("#section-selfchoice > div > div.group-right > div > div > h4 > div.header-left > a > span").click() time.sleep(2) windows = self.driver.window_handles self.driver.switch_to.window(windows[-1]) dl.refresh() time.sleep(1) # self.driver.find_element_by_css_selector("body > div.page > div.search-help > div.tips.tips1 > a").click() # time.sleep(1) # self.driver.find_element_by_css_selector("body > div.page > div.search-help > div.tips.tips2 > a").click() # time.sleep(1) # self.driver.find_element_by_css_selector("body > div.page > div.search-help > div.tips.tips3 > a").click() # time.sleep(1) # self.driver.find_element_by_css_selector("body > div.page > div.search-help > div.tips.tips4 > a").click() # time.sleep(1) number2 = self.driver.find_element_by_css_selector("#searchList > div.page-content.w-center > div.page-content-left > div.search-top > i").text print("权大师为您找到相关结果{}个".format(number2)) self.assertIn(number2,number1) print("检索相似商标数量一致,测试通过!")
def test_nfjn_3(self): """产品外观设计专利年费缴纳""" dl = DengLuPage(self.driver) dl.login() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > h3 > span" )).perform() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(2) > h3 > a" )).perform() ActionChains(self.driver).release() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(2) > div > dl:nth-child(6) > dd > a:nth-child(1)" ).click() time.sleep(3) # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) self.assertIn("发明专利年费缴纳-权大师", self.driver.title) print(self.driver.title) self.driver.find_element_by_css_selector( "#serviceName > li:nth-child(3)").click() time.sleep(2) for a in self.driver.find_elements_by_css_selector("#total-price"): print("费用总计:" + a.text) aa = a.text # aa = float(self.driver.find_element_by_css_selector("#total-price").text) # print("费用总计:" + str(aa)) self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-btnBuy > a.btn.btn-next.buynow" ).click() patent_no = patent_number() self.driver.find_element_by_name("patent_no").send_keys( "ZL{}".format(patent_no)) print("专利号:ZL{}".format(patent_no)) patent_name = unicode() self.driver.find_element_by_name("patent_name").send_keys( "{}".format(patent_name)) print("专利名称:{}".format(patent_name)) self.driver.find_element_by_name("ownerContactPerson").send_keys("全大师") self.driver.find_element_by_name("ownerContactPhone").send_keys( "15624992498") self.driver.find_element_by_name("contactMail").send_keys( "*****@*****.**") self.driver.find_element_by_css_selector("#remark").send_keys( time.strftime("%Y-%m-%d_%H-%M-%S") + "测试订单") get_screenshort(self.driver, "test_nfjn_3.png") for i in self.driver.find_elements_by_css_selector( "body > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(8) > div.last-pay.personal-last-pay > ul > li.row-sense > em > i" ): print("总价:" + i.text) ii = i.text # ii = float(self.driver.find_element_by_css_selector("body > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(6) > div.last-pay.personal-last-pay > ul > li.row-sense > em > i").text) # print("总价:" + str(ii)) self.assertIn(aa, ii) print("价格一致") self.driver.find_element_by_css_selector( "body > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(8) > div.btns > a.btn-next.submitOrder" ).click() for o in self.driver.find_elements_by_class_name("payable"): print("订单提交成功,应付金额:" + o.text) oo = o.text # oo = float(self.driver.find_element_by_css_selector("payable").text) self.assertIn(oo, ii) print("测试通过") self.driver.find_element_by_css_selector("#alisubmit").click()
def _hwgs_pic(self): """海外高速_图形""" # logging.basicConfig(filename='../LOG/' + __name__ + '.log', # format='[%(asctime)s-%(filename)s-%(levelname)s:%(message)s]', level=logging.DEBUG, # filemode='a', datefmt='%Y-%m-%d%I:%M:%S %p') dl = DengLuPage(self.driver) # 官方推荐有find_element(By.*(""))代替find_element_by_*("") # self.driver.find_element_by_id() # self.driver.find_element() dl.login() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > h3 > span" )).perform() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > h3 > a" )).perform() ActionChains(self.driver).release() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > div > dl:nth-child(3) > dd > a:nth-child(4)" ).click() # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) time.sleep(2) self.driver.set_window_size(1920, 1080) self.assertIn("海外商标注册|国际商标注册|商标注册流程|商标注册代理-权大师", self.driver.title) print(self.driver.title) self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-serviceItems > table > tbody > tr > td.td-cont > ul > li:nth-child(4)" ).click() for a in self.driver.find_elements_by_css_selector("#total-price"): print("费用总计:" + a.text) aa = a.text self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-btnBuy > a.btn.btn-next.buynow" ).click() time.sleep(2) self.driver.find_element_by_css_selector( "body > div.recommend-help > i").click() # body > div.recommend-help > i self.driver.find_element_by_css_selector( "#selectBrandType > label:nth-child(2)").click() self.driver.find_element_by_css_selector( "body > div.register-wrap.brandinfo-wrap > div.brand-info-wrap.form-wrap.show3 > ul > li.brand-upload > div > div.brand-upload-wrap > div.shoudong-create > ul > li > div > div > div.photo-box.btnuploadtuyang > div" ).click() """上传商标图片""" path = driver_path + "\\" + "Upload_files.exe" os.system(path) print("商标图形:小鸡图片") time.sleep(5) self.driver.find_element_by_css_selector( "#selectCategoryType > label:nth-child(2)").click() self.driver.execute_script("window.scrollBy(0,1200)") # 滑动滚动条 suiji = random.randint(2, 45) time.sleep(2) self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li:nth-child({}) > span" .format(suiji)).click() time.sleep(2) self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div:nth-child(2) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(1) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(2) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(3) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(4) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(5) > span" ).click() print("选择了第{}类商标分类!".format(suiji)) self.driver.find_element_by_css_selector( "body > div.register-wrap.brandinfo-wrap > div.register-pay > div > ul > li.row-step > a" ).click() try: self.driver.find_element(By.LINK_TEXT, "确认") a = True except: a = False if a is True: """不足10小项确认提交""" self.driver.find_element_by_link_text("确认").click() elif a is False: pass time.sleep(3) # 企业 国外 self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-base > div.overseas-form > table.table-1.table-overseas.table-type2.active > tbody.tbody-qiye > tr:nth-child(1) > td.td-content.contact-select-container > dl > dt > input" ).send_keys("{}".format(unicode())) self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-base > div.overseas-form > table.table-1.table-overseas.table-type2.active > tbody.tbody-qiye > tr:nth-child(2) > td.td-content > input" ).send_keys("tesr") self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-base > div.overseas-form > table.table-1.table-overseas.table-type2.active > tbody.tbody-qiye > tr:nth-child(3) > td.td-content.fcountry-container > input.myInput" ).click() self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-base > div.overseas-form > table.table-1.table-overseas.table-type2.active > tbody.tbody-qiye > tr:nth-child(3) > td.td-content.fcountry-container > div > div.country-list.country-list-ag.active > span:nth-child(1)" ).click() self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-base > div.overseas-form > table.table-1.table-overseas.table-type2.active > tbody.tbody-qiye > tr:nth-child(4) > td.td-title" ).click() self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-base > div.overseas-form > table.table-1.table-overseas.table-type2.active > tbody.tbody-qiye > tr:nth-child(4) > td.td-content > input" ).send_keys("test01") self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-base > div.overseas-form > table.table-1.table-overseas.table-type2.active > tbody.tbody-qiye > tr:nth-child(5) > td.td-content > input" ).send_keys("test01") self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-base > div.overseas-form > table.table-1.table-overseas.table-type2.active > tbody.tbody-qiye > tr:nth-child(6) > td.td-content > input" ).send_keys("test02") self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-base > div.overseas-form > table.table-1.table-overseas.table-type2.active > tbody.tbody-qiye > tr:nth-child(7) > td.td-content > input" ).send_keys("15624992422") self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-base > div.overseas-form > table.table-1.table-overseas.table-type2.active > tbody.tbody-qiye > tr:nth-child(8) > td.td-content > input" ).send_keys("*****@*****.**") self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap.overseas > div.section-btns.clearfix > a:nth-child(2)" ).click() """订单备注""" self.driver.find_element_by_css_selector( "html body div.register-wrap div.orderinfo-wrap div.order-content textarea" ).send_keys(time.strftime("%Y-%m-%d_%H-%M-%S") + "测试订单") get_screenshort(self.driver, "test_hwgs_1.png") for i in self.driver.find_elements_by_css_selector( "body > div.register-wrap > div.orderinfo-wrap > div.last-pay.personal-last-pay > ul > li.row-sense > em > i" ): print("总价:" + i.text) ii = i.text self.assertIn(aa, ii) print("价格一致") self.driver.find_element_by_css_selector( "body > div.register-wrap > div.orderinfo-wrap > div.last-pay.personal-last-pay > div > a" ).click() for o in self.driver.find_elements_by_class_name("payable"): print("订单提交成功,应付金额:" + o.text) oo = o.text self.assertIn(oo, ii) print("测试通过") self.driver.find_element_by_css_selector("#alisubmit").click()
def _hhr_order_pic(self): """合伙人商标注册_图形""" dl = DengLuPage(self.driver) dl.login() time.sleep(1) self.driver.find_element_by_css_selector( "#page-header > div.item-right > ul > li:nth-child(2) > a").click( ) time.sleep(1) # 新版提示 self.driver.find_element_by_xpath( "//*[@id=\"personalCenter2-rightContainer\"]/div[1]/div/a").click( ) self.driver.find_element_by_link_text("商标注册").click() """填写商标信息""" self.driver.find_element_by_css_selector( "#selectBrandType > label:nth-child(2)").click() self.driver.find_element_by_css_selector( "#personalCenter2-rightContainer > div > div.order-form-page > div > div.smartRegister-section > div.register-wrap.brandinfo-wrap > div.brand-info-wrap.form-wrap.show3 > ul > li.brand-upload > div > div.brand-upload-wrap > div.shoudong-create > ul > li > div > div > div.photo-box.btnuploadtuyang > div" ).click() time.sleep(2) """上传商标图片""" path = driver_path + "\\" + "Upload_files.exe" os.system(path) self.driver.find_element_by_css_selector( "#personalCenter2-rightContainer > div > div.order-form-page > div > div.smartRegister-section > div.register-wrap.brandinfo-wrap > div.brand-info-wrap.form-wrap.show3 > ul > li.brand-fcontent > div > textarea" ).send_keys("小鸡图片") print("商标图形:小鸡图片") time.sleep(5) self.driver.find_element_by_css_selector( "#selectCategoryType > label:nth-child(2)").click() self.driver.execute_script("window.scrollBy(0,500)") # 滑动滚动条 """商标类别""" suiji = random.randint(2, 45) time.sleep(2) self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li:nth-child({}) > span" .format(suiji)).click() time.sleep(2) self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div:nth-child(2) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(1) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(2) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(3) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(4) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(5) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(6) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(7) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(8) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(9) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(10) > span" ).click() print("选择了第{}类商标分类!".format(suiji)) time.sleep(3) for i in self.driver.find_elements_by_css_selector( "#personalCenter2-rightContainer > div > div.order-form-page > div > div.smartRegister-section > div.order-categories-calc > div.order-categories-total > span.span-total > strong > i" ): print("总价:" + i.text) ii = i.text self.driver.execute_script("window.scrollBy(0,1000)") # 滑动滚动条 """申请人信息""" self.driver.find_element_by_css_selector( "#selectOwnerType > label.label.fownertype.active").click() self.driver.find_element_by_css_selector( "#overseastype > label.label.checked").click() self.driver.find_element_by_css_selector( "#personalCenter2-rightContainer > div > div.order-form-page > div > div.order-detail-box.agentInfo-wrap > div > div > div > div > table.table-1.table-applicant.table-type1.active > tbody.tbody-qiye > tr:nth-child(1) > td.td-content.contact-select-container > dl > dt > input" ).send_keys("文思海辉技术有限公司{}".format(random.randint(1, 1000))) self.driver.find_element_by_xpath("//*[@id=\"ssq\"]").click() time.sleep(3) self.driver.find_element_by_xpath( "//*[@id=\"companylistrative\"]/div/div[2]/div[1]/dl[1]/dd/span[1]" ).click() time.sleep(3) self.driver.find_element_by_xpath( "//*[@id=\"companylistrative\"]/div/div[2]/div[2]/dl[2]/dd/span[1]" ).click() time.sleep(1) # 添加社会信用代码 self.driver.find_element_by_name("creditcode").send_keys( credit_code("credit_code.txt")) print("申请人信息填写成功!") """客户联系人信息""" self.driver.find_element_by_css_selector( "#personalCenter2-rightContainer > div > div.order-form-page > div > div.order-detail-box.contact-box > ul > li:nth-child(1) > input" ).send_keys("dalao") self.driver.find_element_by_css_selector( "#personalCenter2-rightContainer > div > div.order-form-page > div > div.order-detail-box.contact-box > ul > li:nth-child(2) > input" ).send_keys("15624992488") self.driver.find_element_by_css_selector( "#personalCenter2-rightContainer > div > div.order-form-page > div > div.order-detail-box.contact-box > ul > li:nth-child(3) > input" ).send_keys("*****@*****.**") print("联系人信息填写成功!") """订单改价""" self.driver.find_element_by_name("customPrice").clear() new_total = int(str(ii).replace(".00", "")) + 500 self.driver.find_element_by_name("customPrice").send_keys(new_total) print("改价:增加500服务费!") """订单备注""" self.driver.find_element_by_css_selector( "#personalCenter2-rightContainer > div > div.order-form-page > div > div.order-detail-box.message-box > ul > li > textarea" ).send_keys(time.strftime("%Y-%m-%d_%H-%M-%S") + "测试订单") # self.driver.find_element_by_css_selector("#personalCenter2-rightContainer > div > div.order-form-page > div > div:nth-child(7) > div > a.mybtn.mybtn-inverse.mybtn-lg.saveAll").click() self.driver.find_element_by_css_selector( "#personalCenter2-rightContainer > div > div.order-detail-fix > div > div.right.change-price > div.pay-btns > a:nth-child(2)" ).click() time.sleep(2) for o in self.driver.find_elements_by_class_name("payable"): print("订单提交成功,应付金额:" + o.text) oo = int(str(o.text).replace(".00", "")) get_screenshort(self.driver, "test.png") time.sleep(2) self.assertEqual(oo, new_total) self.driver.find_element_by_css_selector( "#payways > ul:nth-child(1) > li").click() self.driver.find_element_by_css_selector("#alisubmit").click() print("价格一致") print("合伙人订单下单成功!") get_screenshort(self.driver, "test_hhr_order_1.png") pay_url = self.driver.find_element_by_class_name( "pay_url").get_attribute("value") print("订单链接:" + pay_url) self.driver.find_element_by_link_text("复制").click() print("订单已发送客户付款!") # 订单url校验 self.driver.get(pay_url) print(self.driver.title) print(self.driver.current_url) time.sleep(2) order_number = self.driver.find_element_by_css_selector( "#table-contract > table:nth-child(1) > tbody > tr:nth-child(2) > td:nth-child(2)" ).text order_time = self.driver.find_element_by_css_selector( "#table-contract > table:nth-child(1) > tbody > tr:nth-child(2) > td:nth-child(4)" ).text if order_time == '': self.assertEqual(1, 2, "付款链接异常请及时查看!") else: print("订单编号:" + order_number)
def _znzz_pic(self): """智能注册_图形""" # logging.basicConfig(filename='../LOG/' + __name__ + '.log', # format='[%(asctime)s-%(filename)s-%(levelname)s:%(message)s]', level=logging.DEBUG, # filemode='a', datefmt='%Y-%m-%d%I:%M:%S %p') dl = DengLuPage(self.driver) # 官方推荐有find_element(By.*(""))代替find_element_by_*("") # self.driver.find_element_by_id() # self.driver.find_element() dl.login() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > h3 > span" )).perform() time.sleep(2) ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > h3 > a" )).perform() ActionChains(self.driver).release() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > div > dl:nth-child(3) > dd > a:nth-child(3)" ).click() # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) time.sleep(2) self.driver.set_window_size(1920, 1080) self.assertIn("商标智能注册|商标注册查询|商标注册网-权大师", self.driver.title) print(self.driver.title) self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-serviceItems > table > tbody > tr > td.td-cont > ul > li:nth-child(3)" ).click() for a in self.driver.find_elements_by_css_selector("#total-price"): print("费用总计:" + a.text) # aa=a.text self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-btnBuy > a.btn.btn-next.buynow" ).click() time.sleep(2) self.driver.find_element_by_css_selector( "body > div.recommend-help > i").click() # body > div.recommend-help > i self.driver.find_element_by_css_selector( "#selectBrandType > label:nth-child(2)").click() self.driver.find_element_by_css_selector( "body > div.register-wrap.brandinfo-wrap > div.brand-info-wrap.form-wrap.show3 > ul > li.brand-upload > div > div.brand-upload-wrap > div.shoudong-create > ul > li > div > div > div.photo-box.btnuploadtuyang > div" ).click() """上传商标图片""" path = driver_path + "\\" + "Upload_files.exe" os.system(path) print("商标图形:小鸡图片") time.sleep(5) self.driver.find_element_by_css_selector( "#selectCategoryType > label:nth-child(2)").click() self.driver.execute_script("window.scrollBy(0,1200)") # 滑动滚动条 suiji = random.randint(2, 45) time.sleep(2) self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li:nth-child({}) > span" .format(suiji)).click() time.sleep(2) self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div:nth-child(2) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(1) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(2) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(3) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(4) > span" ).click() self.driver.find_element_by_css_selector( "#section-selfchoice > div > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(5) > span" ).click() print("选择了第{}类商标分类!".format(suiji)) print(1) self.driver.find_element_by_css_selector( "body > div.register-wrap.brandinfo-wrap > div.register-pay > div > ul > li.row-step > a" ).click() print(2) try: self.driver.find_element(By.LINK_TEXT, "确认") a = True except: a = False if a is True: """不足10小项确认提交""" self.driver.find_element_by_link_text("确认").click() elif a is False: pass time.sleep(3) # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) time.sleep(2) # self.driver.execute_script("document.getElementByName('fname').length = 0;") # self.driver.find_element_by_css_selector( # "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap > div.section-base > div.applicant-form > table.table-1.table-applicant.table-type1.active > tbody.tbody-qiye > tr:nth-child(1) > td.td-content.contact-select-container > dl > dt > input").clear() self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap > div.section-base > div.applicant-form > table.table-1.table-applicant.table-type1.active > tbody.tbody-qiye > tr:nth-child(1) > td.td-content.contact-select-container > dl > dt > input" ).send_keys("{}".format(unicode())) self.driver.find_element_by_css_selector("#ssq").click() self.driver.find_element_by_css_selector( "#companylistrative > div > div.d-dropdown > div.tab-content.active.tab-province > dl.item.item-a-g.clearfix > dd > span:nth-child(1)" ).click() time.sleep(2) self.driver.find_element_by_css_selector( "#companylistrative > div > div.d-dropdown > div.tab-content.tab-city.active > dl.item.item-a-g.clearfix > dd > span:nth-child({})" .format(random.randint(1, 5))).click() time.sleep(2) # 添加社会信用代码 self.driver.find_element_by_name("creditcode").send_keys( credit_code("credit_code.txt")) # 解决弹框 # self.driver.find_element_by_css_selector("body > div.register-wrap > div.agentInfo-wrap.applicant-wrap > div.section-base > div.applicant-form > table.table-1.table-applicant.table-type1.active > tbody.tbody-qiye > tr:nth-child(4) > td.td-title").click() # time.sleep(1) self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap > div.section-base > div.applicant-form > table:nth-child(13) > tbody.tbody-qiye > tr:nth-child(1) > td.td-content > input" ).send_keys("{}".format(unicode())) self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap > div.section-base > div.applicant-form > table:nth-child(13) > tbody.tbody-qiye > tr:nth-child(2) > td.td-content > input" ).send_keys("15624992489") self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap > div.section-base > div.applicant-form > table:nth-child(13) > tbody.tbody-qiye > tr:nth-child(3) > td.td-content > input" ).send_keys("*****@*****.**") self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap > div.section-base > div.applicant-form > table:nth-child(13) > tbody.tbody-qiye > tr:nth-child(4) > td.td-content > input" ).send_keys("03515978787") time.sleep(2) # 解决常用申请人弹框,点击空白处 self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap > div.section-base > div.applicant-form > h2" ).click() self.driver.find_element_by_css_selector( "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap > div.section-base > div.section-btns.clearfix > a:nth-child(2)" ).click() time.sleep(1) # self.driver.find_element_by_css_selector( # "body > div.register-wrap > div.agentInfo-wrap.applicant-wrap > div.section-base > div.section-btns.clearfix > a:nth-child(2)").click() # time.sleep(1) """订单备注""" self.driver.find_element_by_css_selector( "html body div.register-wrap div.orderinfo-wrap div.order-content textarea" ).send_keys(time.strftime("%Y-%m-%d_%H-%M-%S") + "测试订单") get_screenshort(self.driver, "test_znzz_1.png") for i in self.driver.find_elements_by_css_selector( "body > div.register-wrap > div.orderinfo-wrap > div.last-pay.personal-last-pay > ul > li.row-sense > em > i" ): print("总价:" + i.text) ii = i.text # self.assertIn(aa,ii) # print("测试通过") # self.driver.find_element_by_xpath("/html/body/div[6]/div[3]/div[5]/div/a").click() self.driver.find_element_by_css_selector( "body > div.register-wrap > div.orderinfo-wrap > div.last-pay.personal-last-pay > div > a" ).click() for o in self.driver.find_elements_by_class_name("payable"): print("订单提交成功,应付金额:" + o.text) oo = o.text self.assertIn(oo, ii) print("测试通过!") self.driver.find_element_by_css_selector("#alisubmit").click()
def test_trade_12(self): """求购需求测试""" dl = DengLuPage(self.driver) dl.login() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > ul > li:nth-child(5) > a" ).click() windows = self.driver.window_handles self.driver.switch_to.window(windows[-1]) time.sleep(2) dl.refresh() self.driver.set_window_size(1920, 1080) self.assertIn("商标交易_商标转让_商标买卖_商标交易网-权大师", self.driver.title) print(self.driver.title) self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.brandSearchBox > p.postWant" ).click() fl = random.randint(1, 45) self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > div > ul > li:nth-child({})" .format(fl)).click() print("选择" + str(fl) + "商标类别") jg = 4 if jg == 4: self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > ul.structureBox.commonBox > li.structureAct" ).click() structure = self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > ul.structureBox.commonBox > li.structureAct" ).text print("商标结构:" + str(structure)) else: self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > ul.structureBox.commonBox > li:nth-child({})" .format(jg)).click() structure = self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > ul.structureBox.commonBox > li:nth-child({})" .format(jg)).text print("商标结构:" + str(structure)) zs = random.randint(2, 6) self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > ul.wordNumBox.commonBox > li:nth-child({})" .format(zs)).click() words = self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > ul.wordNumBox.commonBox > li:nth-child({})" .format(zs)).text print("商标字数:" + str(words)) ys = random.randint(2, 7) self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > ul.priceBox.commonBox > li:nth-child({})" .format(ys)).click() budget = self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > ul.priceBox.commonBox > li:nth-child({})" .format(ys)).text print("商标预算:" + str(budget)) self.driver.execute_script("window.scrollBy(0,3500)") # 滑动滚动条 self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > p:nth-child(10) > input[type=\"text\"]" ).send_keys(patent_name()) self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > p:nth-child(12) > input[type=\"text\"]" ).send_keys("15624992498") need = "有带“{}”或“{}”的商标,欢迎推荐!".format(unicode(), patent_name()) self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > p:nth-child(14) > textarea" ).send_keys(need) get_screenshort(self.driver, "test_trade_1.png") self.driver.find_element_by_css_selector( "#app > div > div.postNeedsBox > div > a").click() print("需求已发布!")
def test_trade_10(self): """筛选商标测试""" dl = DengLuPage(self.driver) dl.login() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > ul > li:nth-child(5) > a" ).click() windows = self.driver.window_handles self.driver.switch_to.window(windows[-1]) time.sleep(2) dl.refresh() self.driver.set_window_size(1920, 1080) self.assertIn("商标交易_商标转让_商标买卖_商标交易网-权大师", self.driver.title) print(self.driver.title) self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.brandType.chooseType > dd.openBrandType.openBrandTypeOpen" ).click() lb1 = random.randint(1, 45) brand = self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.brandType.chooseType > dd:nth-child(2) > p > a:nth-child({})" .format(lb1)).text self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.brandType.chooseType > dd:nth-child(2) > p > a:nth-child({})" .format(lb1)).click() print("商标类别:" + brand) lb2 = random.randint(2, 7) price = self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.brandPrice.chooseType > dd:nth-child(2) > a:nth-child({})" .format(lb2)).text self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.brandPrice.chooseType > dd:nth-child(2) > a:nth-child({})" .format(lb2)).click() print("商标价格:" + price) jg = [2, 3, 5, 6, 7, 8, 9] lb3 = random.choice(jg) structure = self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.brandStructure.chooseType > dd > a:nth-child({})" .format(lb3)).text self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.brandStructure.chooseType > dd > a:nth-child({})" .format(lb3)).click() print("商标结构:" + structure) lb4 = random.randint(2, 6) num = self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.brandWordNum.chooseType > dd > a:nth-child({})" .format(lb4)).text self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.brandWordNum.chooseType > dd > a:nth-child({})" .format(lb4)).click() print("商标字数:" + num) get_screenshort(self.driver, "test_trade_10.png") result = self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.CompreRanking > dd:nth-child(3)" ).text print(result) number = self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.CompreRanking > dd:nth-child(3) > span" ).text number1 = int(number) print(number1) if number1 == 0: print("没有相关可出售商标,您可以发布求购需求!") else: print( self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > ul > li:nth-child(1) > div" ).text) selected = self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > div.searchCriteriaBox > dl.SelectedConditions > dd" ).text print("已选条件:" + str(selected).replace("\n", " ")) print("筛选商标测试通过!")
def test_trade_2(self): """购买商标测试""" dl = DengLuPage(self.driver) dl.login() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > ul > li:nth-child(5) > a" ).click() windows = self.driver.window_handles self.driver.switch_to.window(windows[-1]) time.sleep(2) dl.refresh() self.driver.set_window_size(1920, 1080) self.assertIn("商标交易_商标转让_商标买卖_商标交易网-权大师", self.driver.title) print(self.driver.title) brand = random.randint(1, 36) name = self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > ul > li:nth-child({}) > div > b" .format(brand)).text price = self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > ul > li:nth-child({}) > div > i" .format(brand)).text lb = self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > ul > li:nth-child({}) > div > span" .format(brand)).text print("商标信息:" + str(name) + "_" + str(price) + "_" + str(lb)) self.driver.find_element_by_css_selector( "#app > div > div.brandMarketBox > ul > li:nth-child({})".format( brand)).click() print("选择购买第" + str(brand) + "个商标.") # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) time.sleep(2) self.driver.set_window_size(1920, 1080) time.sleep(2) name_1 = self.driver.find_element_by_css_selector( "#app > div > div.brandDetailMsgBox > div.brandMsgBox > div.brandMsg > dl > dt" ).text print(name_1) self.assertIn(str(name_1), str(name)) self.driver.find_element_by_css_selector( "#app > div > div.brandDetailMsgBox > div.brandMsgBox > div.brandMsg > dl > dd:nth-child(9) > a:nth-child(2)" ).click() time.sleep(2) """刷新页面显示商品""" self.driver.refresh() time.sleep(2) price_1 = self.driver.find_element_by_css_selector( "#app > div > div.shoppingCarBox > div.totalMoney > div > p > span" ).text print(price_1) # self.assertIn(price_1,price) info_1 = self.driver.find_element_by_css_selector( "#app > div > div.shoppingCarBox > div.totalMoney > div > p").text print(str(info_1)) """判断是否选中购物车的第一个商标""" price_2 = self.driver.find_element_by_css_selector( "#app > div > div.shoppingCarBox > div.totalMoney > div > p > b" ).text print(price_2) if price_2 == "¥0.00": self.driver.find_element_by_css_selector( "#app > div > div.shoppingCarBox > table > tr:nth-child(2) > td:nth-child(1) > img" ).click() else: pass # # try: # self.driver.find_element(By.CSS_SELECTOR, "#app > div > div.shoppingCarBox > table > tr:nth-child(2) > td:nth-child(1) > img") # a = True # except: # a = False # if a is True: # """自动选中购物车的第一个商标""" # self.driver.find_element_by_css_selector("#app > div > div.shoppingCarBox > table > tr:nth-child(2) > td:nth-child(1) > img").click() # elif a is False: # pass self.driver.find_element_by_css_selector( "#app > div > div.shoppingCarBox > div.userMsg > div > dl:nth-child(1) > dd > input[type=\"text\"]" ).send_keys(patent_name()) self.driver.find_element_by_css_selector( "#app > div > div.shoppingCarBox > div.userMsg > div > dl:nth-child(2) > dd > input[type=\"text\"]" ).send_keys("15624992498") self.driver.find_element_by_css_selector( "#app > div > div.shoppingCarBox > div.userMsg > div > dl:nth-child(3) > dd > input[type=\"text\"]" ).clear() self.driver.find_element_by_css_selector( "#app > div > div.shoppingCarBox > div.userMsg > div > dl:nth-child(3) > dd > input[type=\"text\"]" ).send_keys("*****@*****.**") get_screenshort(self.driver, "test_trade_2.png") self.driver.find_element_by_css_selector( "#app > div > div.shoppingCarBox > div.totalMoney > div > a" ).click() time.sleep(4) # 二次切换窗口 current_window = self.driver.current_window_handle all_handles = self.driver.window_handles for handle in all_handles: if handle != current_window: self.driver.switch_to.window(handle) time.sleep(2) self.driver.set_window_size(1920, 1080) print(self.driver.current_url) info_2 = self.driver.find_element_by_css_selector( "#app > div > div.paymentBox > div.orderMsgBox > dl > dt > b").text print("订单提交成功,应付金额:" + str(info_2)) info_3 = self.driver.find_element_by_css_selector( "#app > div > div.paymentBox > div.orderMsgBox > dl > dd").text print(info_3) self.driver.find_element_by_css_selector( "#app > div > div.paymentBox > div.payMethod > a").click()
def test_bmks(self): """保姆快速注册""" # logging.basicConfig(filename='../LOG/' + __name__ + '.log', # format='[%(asctime)s-%(filename)s-%(levelname)s: %(message)s]', level=logging.ERROR, # filemode='a', datefmt='%Y-%m-%d%I:%M:%S %p') dl = DengLuPage(self.driver) # 官方推荐有find_element(By.*(""))代替find_element_by_*("") # self.driver.find_element_by_id() # self.driver.find_element() dl.login() time.sleep(2) # self.driver.find_element_by_css_selector("#com-navbar > div > ul > li:nth-child(1) > a").click() """新版首页""" # self.driver.find_element_by_css_selector("body > div.section-banner > div.public-navbar > div > ul > li:nth-child(1) > a").click() ActionChains(self.driver).move_to_element(self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > h3 > span")).perform() time.sleep(2) ActionChains(self.driver).move_to_element(self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > h3 " "> a")).perform() ActionChains(self.driver).release() self.driver.find_element_by_css_selector( "body > div.section-banner > div.public-navbar > div > div > div > ul:nth-child(1) > li:nth-child(1) > div" " > dl:nth-child(3) > dd > a:nth-child(1)").click() time.sleep(3) # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) time.sleep(2) self.driver.set_window_size(1920, 1080) self.assertIn("商标申请|商标注册查询|商标注册流程及费用-权大师",self.driver.title) print(self.driver.title) # 保姆快速注册 self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-serviceItems > table > tbody > tr > td.td-cont >" " ul > li.list.active").click() # #total-price for a in self.driver.find_elements_by_css_selector("#total-price"): print("费用总计:" + a.text) aa = a.text self.driver.find_element_by_css_selector( "body > div.section-product.width1200 > dl > dd > div.cont-btnBuy > a.btn.btn-next.buynow").click() self.driver.find_element_by_name("ownerContactPerson").send_keys("{}".format(unicode())) self.driver.find_element_by_name("ownerContactPhone").send_keys("15624992498") self.driver.find_element_by_name("contactMail").send_keys("*****@*****.**") self.driver.find_element_by_css_selector("#remark").send_keys(time.strftime("%Y-%m-%d_%H-%M-%S") + "测试订单") get_screenshort(self.driver, "test_bmks.png") for i in self.driver.find_elements_by_css_selector("body > div.myOrder-wrap > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(6) > div.last-pay.personal-last-pay > ul > li.row-sense > em > i"): print("总价:"+i.text) ii = i.text self.assertIn(aa, ii) print("价格一致") self.driver.find_element_by_css_selector( "body > div.myOrder-wrap > div.section-myorder.orderinfo-wrap.width1200 > div:nth-child(6) > div.btns > a.btn-next.submitOrder").click() for o in self.driver.find_elements_by_class_name("payable"): print("订单提交成功,应付金额:"+o.text) oo = o.text self.assertIn(oo, ii) print("测试通过") self.driver.find_element_by_css_selector("#alisubmit").click()