def test_address(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(1) > a").click( ) time.sleep(1) try: self.driver.find_elements_by_css_selector( ".modal-body > .close")[0].click() except Exception: pass """添加邮寄地址""" self.driver.find_element_by_link_text("邮寄地址管理").click() self.assertIn("权大师_邮寄地址管理", self.driver.title) print(self.driver.title) time.sleep(1) # self.driver.find_element_by_css_selector("#personalCenter2-leftNav > ul > li:nth-child(3) > ul > li.selected > a").click() self.driver.find_element_by_css_selector("#addAddress").click() ss = unicode() self.driver.find_element_by_css_selector( "#add_Address > table > tbody > tr:nth-child(1) > td:nth-child(2) > input" ).send_keys("{}".format(ss)) print("收件人名称:{}".format(ss)) self.driver.find_element_by_css_selector( "#add_Address > table > tbody > tr:nth-child(2) > td:nth-child(2) > input" ).send_keys("15624992422") self.driver.find_element_by_css_selector("#address_info").click() self.driver.find_element_by_css_selector( "#administrative > div > div.d-dropdown > div.tab-content.active.tab-province > dl.item.item-a-g.clearfix > dd > span:nth-child(1)" ).click() self.driver.find_element_by_css_selector( "#administrative > div > div.d-dropdown > div.tab-content.tab-city.active > dl.item.item-a-g.clearfix > dd > span:nth-child(1)" ).click() qq = unicode() self.driver.find_element_by_css_selector( "#add_Address > table > tbody > tr:nth-child(4) > td:nth-child(2) > textarea" ).send_keys("{}".format(qq)) print("收件人地址:北京市昌平区{}街道".format(qq)) self.driver.find_element_by_css_selector( "#add_Address > table > tbody > tr:nth-child(3) > td.td-title" ).click() self.driver.find_element_by_css_selector("#submit-editAddress").click() print("添加邮寄地址成功!") get_screenshort(self.driver, "test_address.png") print("测试通过!")
def test_classify_1(self): """商品分类搜索测试""" dl = DengLuPage(self.driver) dl.login() time.sleep(1) self.driver.execute_script("window.scrollBy(0,1200)") # 滑动滚动条 ActionChains(self.driver).move_to_element( self.driver.find_element_by_css_selector("#section-tools > div > ul > li:nth-child(3)")).perform() time.sleep(2) ActionChains(self.driver).release() self.driver.find_element_by_link_text("立即使用").click() time.sleep(2) self.assertIn("商品分类_商标类似商品和服务区分表基于尼斯分类第十版2016", self.driver.title) print(self.driver.title) dl.refresh() brand = unicode() self.driver.find_element_by_css_selector("#niceList > div.page-search.w-center > div > input").send_keys(brand) print("商品关键词:" + brand) time.sleep(2) self.driver.find_element_by_css_selector("#search").click() get_screenshort(self.driver,"test_classify_1.png")
def test_clue1(self): """开放平台线索测试""" dl = DengLuPage(self.driver) dl.login() time.sleep(1) """新版首页""" # self.driver.find_element_by_css_selector("body > div.festival-modal-bg > a.close").click() self.driver.execute_script("window.scrollBy(0,1000)") # 滑动滚动条 ActionChains(self.driver).move_to_element(self.driver.find_element_by_css_selector("#section-tools > div > ul > li:nth-child(2)")).perform() time.sleep(2) ActionChains(self.driver).release() self.driver.find_element_by_link_text("立即咨询").click() print("开放平台咨询_弹框") self.driver.find_element_by_id("userName").send_keys(unicode()) self.driver.find_element_by_id("userTel").send_keys("15624992498") self.driver.find_element_by_id("userQue").send_keys(time.strftime("%Y-%m-%d_%H-%M-%S") + "测试线索") name = self.driver.find_element_by_id("userName").get_attribute("value") tel = self.driver.find_element_by_id("userTel").get_attribute("value") que = self.driver.find_element_by_id("userQue").get_attribute("value") print("姓名:" + name) print("电话:" + tel) print("问题:" + que) self.driver.find_element_by_css_selector("#contactModal > form > span").click() print("线索录入成功!")
def test_Korea(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(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(8) > dd > a:nth-child(10)").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) 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_Korea.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 _monitor_1(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() get_screenshort(self.driver, "test.png") 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) get_screenshort(self.driver, "test.png") self.driver.find_element_by_css_selector( "body > div.brandMonitor-wrap > div > div.wrap > ul > li:nth-child(1) > a > i" ).click() brand = unicode() self.driver.find_element_by_css_selector( "body > div.brandMonitor-wrap > div > div > div.myPanel-bodyer > div.section1 > table > tbody > tr.row-brandname > 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_1.png") print("监控信息" + str(info)) print("信息无误,测试通过!")
def test_clue2(self): """专利二级页线索测试""" dl = DengLuPage(self.driver) dl.login() time.sleep(1) """新版首页""" 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()).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) > h3 > a" ).click() # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) time.sleep(2) self.driver.set_window_size(1920, 1080) self.driver.find_element_by_css_selector("#anchor03 > div > a").click() print("专利咨询_弹框") self.driver.find_element_by_id("userName").send_keys(unicode()) self.driver.find_element_by_id("userTel").send_keys("15624992498") self.driver.find_element_by_id("userQue").send_keys( time.strftime("%Y-%m-%d_%H-%M-%S") + "测试线索") name = self.driver.find_element_by_id("userName").get_attribute( "value") tel = self.driver.find_element_by_id("userTel").get_attribute("value") que = self.driver.find_element_by_id("userQue").get_attribute("value") print("姓名:" + name) print("电话:" + tel) print("问题:" + que) self.driver.find_element_by_css_selector("#sub-qus").click() print("线索录入成功!")
def test_trade_3(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({}) > div > p > a:nth-child(1)" .format(brand)).click() self.driver.find_element_by_css_selector( "#app > div > div:nth-child(6) > div > div > p:nth-child(1) > input[type=\"text\"]" ).send_keys(unicode()) self.driver.find_element_by_css_selector( "#app > div > div:nth-child(6) > div > div > p:nth-child(2) > input[type=\"text\"]" ).send_keys("15624992422") price = random.randint(1, 20000000) self.driver.find_element_by_css_selector( "#app > div > div:nth-child(6) > div > div > p:nth-child(3) > input[type=\"text\"]" ).send_keys(price) print("报价:" + str(price) + "元!") # self.driver.find_element_by_css_selector("#app > div > div:nth-child(6) > div > p.subBtn > a").click() get_screenshort(self.driver, "test_trade_3.png") print("提交报价成功!")
def test_try(self): """尝试注册测试""" dl = DengLuPage(self.driver) self.driver.get("https://so.quandashi.com/") dl.refresh() time.sleep(2) brand = unicode() self.driver.find_element_by_name("key").send_keys(brand) self.driver.find_element_by_id("btnSearchkey").click() time.sleep(3) result = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > div.search-top > i" ).text print(result) time.sleep(2) if int(result) == 0: print("亲,未检测到您关注的商标,请换个词试试~ 不过您可以就~{}~提起商标申请哦".format(brand)) wsq = self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > div.no-result-category > div.no-result-category-box > a:nth-child(1)" ).text print(str(wsq)) self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > div.no-result-category > div.no-result-category-box > a:nth-child(1)" ).click() windows = self.driver.window_handles self.driver.switch_to.window(windows[-1]) time.sleep(2) self.driver.set_window_size(1920, 1080) print(self.driver.current_url) get_screenshort(self.driver, "test_try.png") else: # 搜索结果 jg = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > div.search-top" ).text print(jg) # 第一个商标信息 jg1 = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > ul > li:nth-child(1) > div.result-href > div.brand-info > div > ul" ).text print(str(jg1).replace("\n", " "))
def test_enterprise_search(self): """企业搜索测试""" dl = DengLuPage(self.driver) dl.login() time.sleep(2) self.driver.find_element_by_css_selector("#qds-search-common > li:nth-child(3)").click() company = unicode() self.driver.find_element_by_css_selector("#qds-searchkey").send_keys(company) print(str(company)) self.driver.find_element_by_css_selector("#serch-word").click() # 获取打开的多个窗口句柄 windows = self.driver.window_handles # 切换到当前最新打开的窗口 self.driver.switch_to.window(windows[-1]) time.sleep(2) # self.assertIn("注册专利查询_中国专利查询系统_让知识产生财富_权大师", self.driver.title) print(self.driver.title) print(self.driver.current_url)
def test_clue4(self): """IP圈子咨询测试""" dl = DengLuPage(self.driver) dl.login() time.sleep(1) try: self.driver.find_elements_by_css_selector( ".modal-body > .close")[0].click() except Exception: pass """新版首页""" 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) self.driver.set_window_size(1920, 1080) self.driver.execute_script("window.scrollBy(0,2000)") # 滑动滚动条 time.sleep(2) self.driver.find_element_by_link_text("立即咨询IP圈子").click() print("IP圈子咨询_弹框") name = unicode() tel = "15624992498" que = time.strftime("%Y-%m-%d_%H-%M-%S") + "测试线索" self.driver.find_element_by_name("user_name").send_keys(name) self.driver.find_element_by_name("user_phone").send_keys(tel) self.driver.find_element_by_name("user_problem").send_keys(que) print("姓名:" + name) print("电话:" + tel) print("问题:" + que) self.driver.find_element_by_css_selector( "body > div.dispark-plat > div.pt_wind > div > a").click() print("线索录入成功!")
def test_overseas(self): """海外智能推荐测试""" self.driver.find_element_by_xpath( "//android.widget.TextView[@text=\"智能自助注册\"]").click() service_price = self.driver.find_element_by_id( "com.dream.ipm:id/tv_product_service_price").text print("服务费:" + service_price) official_price = self.driver.find_element_by_id( "com.dream.ipm:id/tv_product_official_price").text print("服务费:" + official_price) """"海外智能注册""" self.driver.find_element_by_xpath( "//android.widget.TextView[@resource-id=\"com.dream.ipm:id/cb_product_detail_option\" and @text=\"智能自助注册\"]" ).click() self.driver.find_element_by_id( "com.dream.ipm:id/tv_product_detail_order").click() self.driver.find_element_by_xpath( "//android.widget.RadioButton[@resource-id=\"com.dream.ipm:id/rb_tm_apply_foreign_type\"]" ).click() """填写信息""" brand = unicode() self.driver.find_element_by_xpath( "//android.widget.EditText[@resource-id=\"com.dream.ipm:id/et_tm_apply_name\"]" ).send_keys(brand) print("商标名称:" + brand) self.driver.find_element_by_xpath( "//android.widget.TextView[@resource-id=\"com.dream.ipm:id/tv_tm_apply_images\"]" ).click() time.sleep(2) self.driver.find_element_by_xpath( "//android.widget.TextView[@resource-id=\"com.dream.ipm:id/text\" and @text=\"自动生成\"]" ).click() time.sleep(5) """选择智能推荐尼斯分类""" self.driver.find_element_by_xpath( "//android.widget.RadioButton[@resource-id=\"com.dream.ipm:id/rb_tm_apply_smart\"]" ).click() self.driver.find_element_by_xpath( "//android.widget.TextView[@resource-id=\"com.dream.ipm:id/tv_smart_apply_lingyu\"]" ).click() lingyu = random.randint(1, 11) selected = self.driver.find_element_by_xpath( "//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.ListView[1]/android.widget.LinearLayout[{}]/android.widget.TextView[1]" .format(lingyu)).text self.driver.find_element_by_xpath( "//android.widget.ListView[@resource-id=\"com.dream.ipm:id/lv_smart_apply_lingyu\"]/android.widget.LinearLayout[{}]" .format(lingyu)).click() print("选择领域:" + selected) time.sleep(3) self.driver.find_element_by_xpath( "//android.widget.TextView[@resource-id=\"com.dream.ipm:id/tv_smart_apply_hangye\"]" ).click() hangye = self.driver.find_element_by_xpath( "//android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.ListView[1]/android.widget.LinearLayout[1]/android.widget.TextView[1]" ).text self.driver.find_element_by_xpath( "//android.widget.ListView[@resource-id=\"com.dream.ipm:id/lv_smart_apply_hangye\"]/android.widget.LinearLayout[1]" ).click() print("选择行业:" + hangye) time.sleep(2) self.driver.find_element_by_xpath( "//android.widget.Button[@resource-id=\"com.dream.ipm:id/bt_smart_apply_get_goods\"]" ).click() zongji = self.driver.find_element_by_xpath( "//android.widget.TextView[@resource-id=\"com.dream.ipm:id/tv_agent_apply_total_nice_price\"]" ).text print("合计:" + zongji) num = self.driver.find_element_by_xpath( "//android.widget.TextView[@resource-id=\"com.dream.ipm:id/tv_agent_apply_total_nice_num\"]" ).text print("已选择{}个商品小项".format(num)) self.driver.find_element_by_xpath( "//android.widget.Button[@resource-id=\"com.dream.ipm:id/bt_agent_apply_nice_next_step\"]" ).click() """确认订单""" # self.driver.find_element_by_xpath("//android.widget.TextView[@text=\"常用申请人\"]").click() # time.sleep(10) get_screenshort(self.driver, "test_overseas.png") """向下滑动屏幕""" # print(self.driver.get_window_size()) # 滑动方向是相反的 width = self.driver.get_window_size()['width'] height = self.driver.get_window_size()['height'] self.driver.swipe(width / 2, height * 6 / 8, width / 2, height * 1 / 8, 1000) self.driver.find_element_by_xpath( "//android.widget.EditText[@resource-id=\"com.dream.ipm:id/et_confirm_tm_order_notes\"]" ).send_keys(time.strftime("%Y-%m-%d_%H-%M-%S") + "测试订单") self.driver.find_element_by_xpath( "//android.widget.CheckBox[@resource-id=\"com.dream.ipm:id/cb_tm_apply_document\"]" ).click() price = self.driver.find_element_by_xpath( "//android.widget.TextView[@resource-id=\"com.dream.ipm:id/tv_confirm_tm_order_total_price\"]" ).text print(price) self.driver.find_element_by_xpath( "//android.widget.Button[@resource-id=\"com.dream.ipm:id/bt_confirm_tm_order_submit\"]" ).click() 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 _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_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()
def test_PreliminaryPublicationQuery(self): """初审公告查询测试""" dl = DengLuPage(self.driver) time.sleep(2) self.driver.get("https://so.quandashi.com/search/notice/index") dl.refresh() time.sleep(2) self.driver.set_window_size(1920, 1080) self.assertIn("初审公告搜索", self.driver.title) print(self.driver.title) dl.refresh() brand1 = unicode() self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > ul:nth-child(1) > li:nth-child(1) > input[type=\"text\"]" ).send_keys(brand1) print("商标名称:" + brand1) self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > ul:nth-child(1) > li:nth-child(2) > label:nth-child(1) > span" ).click() lx1 = self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > ul:nth-child(1) > li:nth-child(2) > label:nth-child(1) > span" ).text print("搜索类型:" + str(lx1)) time.sleep(2) get_screenshort(self.driver, "test.png") self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > div > a").click() time.sleep(5) js = "return document.getElementsByClassName(\"search-num\")[0].innerText;" ss = self.driver.execute_script(js) print(str(ss)) time.sleep(2) get_screenshort(self.driver, "test_PreliminaryPublicationQuery_1.png") self.driver.refresh() brand2 = unicode() self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > ul:nth-child(1) > li:nth-child(1) > input[type=\"text\"]" ).send_keys(brand2) print("商标名称:" + brand2) self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > ul:nth-child(1) > li:nth-child(2) > label:nth-child(2)" ).click() lx2 = self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > ul:nth-child(1) > li:nth-child(2) > label:nth-child(2)" ).text print("搜索类型:" + lx2) time.sleep(2) self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > div > a").click() time.sleep(5) js = "return document.getElementsByClassName(\"search-num\")[0].innerText;" ss = self.driver.execute_script(js) print(str(ss)) time.sleep(2) get_screenshort(self.driver, "test_PreliminaryPublicationQuery_2.png") self.driver.refresh() brand3 = unicode() self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > ul:nth-child(1) > li:nth-child(1) > input[type=\"text\"]" ).send_keys(brand3) print("商标名称:" + brand3) self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > ul:nth-child(1) > li:nth-child(2) > label:nth-child(3) > span" ).click() lx3 = self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > ul:nth-child(1) > li:nth-child(2) > label:nth-child(3) > span" ).text print("搜索类型:" + lx3) time.sleep(2) self.driver.find_element_by_css_selector( "#noticeList > div > div.page-form > div > a").click() time.sleep(5) js = "return document.getElementsByClassName(\"search-num\")[0].innerText;" ss = self.driver.execute_script(js) print(str(ss)) time.sleep(2) get_screenshort(self.driver, "test_PreliminaryPublicationQuery_3.png")
def test_cross(self): """交叉检索测试""" dl = DengLuPage(self.driver) self.driver.get("https://so.quandashi.com/") dl.refresh() time.sleep(2) mark = ("小米", unicode()) brand = random.choice(mark) self.driver.find_element_by_name("key").send_keys(brand) print("搜索商标:" + brand) self.driver.find_element_by_id("btnSearchkey").click() time.sleep(3) # html = self.driver.execute_script("return document.documentElement.outerHTML") # print(str(html)) """交叉检索""" self.driver.find_element_by_class_name("cross-search").click() classify = random.randint(1, 45) time.sleep(2) dl = self.driver.find_element_by_css_selector( "#section-selfchoice > div.group-left > ul > li:nth-child({})". format(classify)).text print(str(dl)) self.driver.find_element_by_css_selector( "#section-selfchoice > div.group-left > ul > li:nth-child({})". format(classify)).click() time.sleep(2) zl = self.driver.find_element_by_css_selector( "#section-selfchoice > div.group-left > ul > li.list.open > div:nth-child(2) > span" ).text print(str(zl)) self.driver.find_element_by_css_selector( "#section-selfchoice > div.group-left > ul > li.list.open > div:nth-child(2) > span" ).click() time.sleep(2) xl = self.driver.find_element_by_css_selector( "#section-selfchoice > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(1) > span" ).text print(str(xl)) self.driver.find_element_by_css_selector( "#section-selfchoice > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(1) > span" ).click() time.sleep(2) # ol = self.driver.find_element_by_css_selector("#section-selfchoice > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(1) > span").text # print(str(ol)) # self.driver.find_element_by_css_selector("#section-selfchoice > div.group-left > ul > li.list.open > div.title-second.open > dl > dt:nth-child(1) > span").click() info = self.driver.find_element_by_class_name("cross-range-list").text print(str(info).replace("\n", " ")) self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > div.w_category_modal > div > div.btns > a" ).click() time.sleep(2) """已选条件""" select = self.driver.find_element_by_class_name( "selected-category").text print((str(select).replace("\n", " ")).replace("×", " ")) result = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > div.search-top > i" ).text print("权大师为您找到相关结果{}个".format(result)) time.sleep(2) if int(result) == 0: print("亲,未检测到您关注的商标,请换个词试试~ 不过您可以就~{}~提起商标申请哦".format(brand)) else: # 第一个商标信息 jg1 = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > ul > li:nth-child(1) > div.result-href > div.brand-info > div > ul" ).text print(str(jg1).replace("\n", " ")) get_screenshort(self.driver, "test_cross.png")
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 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 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()