def test_TrademarkMonitor(self): """商标详情监控按钮测试""" dl = DengLuPage(self.driver) self.driver.get("https://so.quandashi.com/") dl.refresh() self.driver.find_element_by_name("key").send_keys( xz("著名商标.txt").replace(".0", "")) time.sleep(2) self.driver.find_element_by_css_selector("#btnSearchkey").click() time.sleep(5) result = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > div.search-top" ).text print(str(result)) number = 1 info = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > ul > li:nth-child({}) > div.result-href" .format(number)).text print(str(info).replace("\n", " ")) self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > ul > li:nth-child({}) > div.result-href" .format(number)).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) result2 = self.driver.find_element_by_css_selector( "#searchDetail > div.page-brand > div > div.brand-left > div.brand-info > h2" ).text result3 = self.driver.find_element_by_css_selector( "#searchDetail > div.page-brand > div > div.brand-left > div.brand-info > div > span:nth-child(3)" ).text print(result3) result4 = re.sub(r"\D", "", result3) result8 = int(result4) + 0 print(str(result2)) self.driver.execute_script("window.scrollBy(0,2000)") # 滑动滚动条 self.driver.find_element_by_link_text("监控该商标").click() time.sleep(2) self.driver.find_element_by_link_text("确定").click() print("监控跳转正常!")
def test_famous(self): """驰著名商标测试""" dl = DengLuPage(self.driver) self.driver.get("https://so.quandashi.com/") dl.refresh() self.driver.find_element_by_name("key").send_keys( xz("驰著名商标.txt").replace(".0", "")) time.sleep(2) self.driver.find_element_by_css_selector( "body > div.page > div.page-index > div.page-index-form.search > ul.page-index-icon > li:nth-child(3) > a > img" ).click() time.sleep(5) selected = self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > div.selected-category" ).text print((str(selected).replace("\n", " ")).replace("×", " ")) selected_1 = self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > div.selected-category > div.selected-category-box > a:nth-child(1) > span" ).text if selected_1 == "驰名商标": pass else: self.assertEqual(1, 2, "已选条件异常请及时查看") result = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > div.search-top" ).text print(str(result)) number = 1 info = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > ul > li:nth-child({}) > div.result-href" .format(number)).text print(str(info).replace("\n", " ")) self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > ul > li:nth-child({}) > div.result-href" .format(number)).click() windows = self.driver.window_handles self.driver.switch_to.window(windows[-1]) time.sleep(2) print(self.driver.current_url) get_screenshort(self.driver, "test_famous.png") result2 = self.driver.find_element_by_css_selector( "#searchDetail > div.page-brand > div > div.brand-left > div.brand-info > h2" ).text print(str(result2))
def test_special_trademark(self): """特殊商标测试""" dl = DengLuPage(self.driver) self.driver.get("https://so.quandashi.com/") dl.refresh() time.sleep(2) trademark = ("地理标志商标.txt", "著名商标.txt", "驰名商标.txt") filename = random.choice(trademark) print(filename) application_number = xz(filename) print("申请号:" + str(application_number).replace(".0", "")) self.driver.find_element_by_css_selector( "body > div.page > div.page-index > div.page-index-form.search > div > input.input.search-text" ).send_keys(str(application_number).replace(".0", "")) self.driver.find_element_by_css_selector("#btnSearchkey").click() time.sleep(5) result = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > div.search-top" ).text print(str(result)) info = 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" ).text print(str(info).replace("\n", " ")) number = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > ul > li > div.result-href > div.brand-info > div > ul > li:nth-child(2) > span:nth-child(4)" ).text print(str(number)) self.assertIn(str(application_number).replace(".0", ""), str(number)) 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" ).click() windows = self.driver.window_handles self.driver.switch_to.window(windows[-1]) time.sleep(2) print(self.driver.current_url) result2 = self.driver.find_element_by_css_selector( "#searchDetail > div.page-brand > div > div.brand-left > div.brand-info > h2" ).text get_screenshort(self.driver, "test_special_trademark.png") print(str(result2))
def test_special_search(self): """特殊搜索测试""" dl = DengLuPage(self.driver) self.driver.get("https://so.quandashi.com/") dl.refresh() time.sleep(2) self.driver.find_element_by_css_selector( "body > div.page > div.page-index > div.page-index-form.search > div > input.input.search-text" ).send_keys(xz("驰著名地理商标.txt").replace(".0", "")) self.driver.find_element_by_css_selector("#btnSearchkey").click() time.sleep(5) # """删除搜索商标""" # self.driver.find_element_by_css_selector("#searchList > div.page-search.w-center > div.search-input > input").send_keys(Keys.BACK_SPACE) # time.sleep(2) """点击驰名商标""" self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > ul > li:nth-child(4) > div.category-show-box > a:nth-child(2)" ).click() time.sleep(5) result = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > div.search-top" ).text print(str(result)) info = 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" ).text print(str(info).replace("\n", " ")) for link in self.driver.find_elements_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > ul > li:nth-child(1) > div.result-href > div.brand-info > a" ): print(link.get_attribute("href")) selected = self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > div.selected-category" ).text print((str(selected).replace("\n", " ")).replace("×", " ")) """点击著名商标""" self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > ul > li:nth-child(4) > div.category-show-box > a:nth-child(3)" ).click() time.sleep(5) result = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > div.search-top" ).text print(str(result)) info = 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" ).text print(str(info).replace("\n", " ")) for link in self.driver.find_elements_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > ul > li:nth-child(1) > div.result-href > div.brand-info > a" ): print(link.get_attribute("href")) selected = self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > div.selected-category" ).text print((str(selected).replace("\n", " ")).replace("×", " ")) """点击地理标志商标""" self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > ul > li:nth-child(4) > div.category-show-box > a:nth-child(4)" ).click() time.sleep(5) result = self.driver.find_element_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > div.search-top" ).text print(str(result)) info = 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" ).text print(str(info).replace("\n", " ")) for link in self.driver.find_elements_by_css_selector( "#searchList > div.page-content.w-center > div.page-content-left > ul > li:nth-child(1) > div.result-href > div.brand-info > a" ): print(link.get_attribute("href")) selected = self.driver.find_element_by_css_selector( "#searchList > div.page-form.w-center > div.selected-category" ).text print((str(selected).replace("\n", " ")).replace("×", " "))