How to use click_search_result method in SeleniumBase

Best Python code snippet using SeleniumBase

district_case.py

Source: district_case.py Github

copy

Full Screen

...43 def test_002(self):44 name = DistrictCommon(self.driver).DistrictRequiredCommon()45 # print(name)46 DistrictPage(self.driver).search(name)47 DistrictPage(self.driver).click_search_result()48 DistrictPage(self.driver).addsubmit()49 DistrictPage(self.driver).search(name)50 Districname = DistrictPage(self.driver).gettable_body()[0].text51 Districcommon = DistrictPage(self.driver).gettable_body()[1].text52 self.assertEqual(Districname, name, msg='错误,必填添加区域列表中名称显示错误')53 self.assertEqual(Districcommon, '', msg='错误,必填添加区域列表中备注显示错误')54 DistrictPage(self.driver).click_search_result()55 Districtinfo= DistrictCommon(self.driver).GetDistrictInfo()56 districtlist = [name, None, '有效', None]57 Districtinfo2 = []58 for i in range(0, len(Districtinfo)):59 Districtinfo2.append(Districtinfo[i])60 if Districtinfo2[i] == '':61 Districtinfo2[i] = None62 self.assertEqual(Districtinfo2, districtlist, msg='必填添加区域二次编辑进入,数据显示错误')63 # 检查必填项,必填项空格输入64 def test_003(self):65 strnumber = time.strftime('%y%m%d%M%S', time.localtime())66 name = "区域必填" + strnumber67 EntranceAgentPage(self.driver).enter_district()68 time.sleep(5)69 DistrictPage(self.driver).click_add()70 submitinfo = DistrictPage(self.driver).check_submit_clickable()71 self.assertEqual(submitinfo, False, msg='错误:名称未输入,提交按钮可触发')72 DistrictPage(self.driver).input_name(' ')73 time.sleep(2)74 submitinfo = DistrictPage(self.driver).check_submit_clickable()75 self.assertEqual(submitinfo, False, msg='错误:必填项输入空格,提交按钮可触发')76 DistrictPage(self.driver).input_name(name)77 time.sleep(2)78 submitinfo = DistrictPage(self.driver).check_submit_clickable()79 self.assertEqual(submitinfo, True, msg='错误:必填项已填写,提交按钮不可触发')80 DistrictPage(self.driver).delete_valid()81 time.sleep(2)82 submitinfo = DistrictPage(self.driver).check_submit_clickable()83 self.assertEqual(submitinfo, False, msg='错误:有效性为空,提交按钮可触发')84 # 检查返回列表按钮 返回页面添加按钮可点击85 DistrictPage(self.driver).backlist()86 submitinfo = DistrictPage(self.driver).check_add_clickable()87 self.assertEqual(submitinfo, True, msg='错误:点击返回列表按钮,返回列表失败')88 # 名称重名检验89 def test_004(self):90 strnumber = time.strftime('%y%m%d%M%S', time.localtime())91 name2 = name = "区域 必填" + strnumber92 name1 = DistrictCommon(self.driver).DistrictRequiredCommon()93 DistrictPage(self.driver).click_add()94 time.sleep(3)95 DistrictPage(self.driver).input_name(name2)96 DistrictPage(self.driver).choose_valid()97 DistrictPage(self.driver).addsubmit()98 DistrictPage(self.driver).click_add()99 time.sleep(3)100 DistrictPage(self.driver).input_name(name1)101 name_tip = DistrictPage(self.driver).get_name_tip()102 submitinfo = DistrictPage(self.driver).check_submit_clickable()103 self.assertEqual(name_tip,'该名称已存在,请更换其他名称!', msg='名称重复未提示')104 self.assertEqual(submitinfo, False, msg='错误:名称重复,提交按钮可触发')105 # 检查带有空格的名称重名检验106 DistrictPage(self.driver).input_name(name2)107 name_tip = DistrictPage(self.driver).get_name_tip()108 submitinfo = DistrictPage(self.driver).check_submit_clickable()109 self.assertEqual(name_tip, '该名称已存在,请更换其他名称!', msg='检查带有空格的名称重复未提示')110 self.assertEqual(submitinfo, False, msg='错误:检查带有空格的名称重复,提交按钮可触发')111 # 添加一个无效区域112 @Base.screenshot_about_case113 def test_005(self):114 name = DistrictCommon(self.driver).DistrictinvalidCommon()115 # 切换到无效tab click_invalid_tab116 DistrictPage(self.driver).click_invalid_tab()117 DistrictPage(self.driver).search(name)118 DistrictPage(self.driver).click_search_result()119 DistrictPage(self.driver).addsubmit()120 DistrictPage(self.driver).click_invalid_tab()121 DistrictPage(self.driver).search(name)122 Districname = DistrictPage(self.driver).gettable_body()[0].text123 Districcommon = DistrictPage(self.driver).gettable_body()[1].text124 self.assertEqual(Districname, name, msg='错误,必填添加区域列表中名称显示错误')125 self.assertEqual(Districcommon, '', msg='错误,必填添加区域列表中备注显示错误')126 DistrictPage(self.driver).click_search_result()127 Districtinfo= DistrictCommon(self.driver).GetDistrictInfo()128 districtlist = [name, None, '无效', None]129 Districtinfo2 = []130 for i in range(0, len(Districtinfo)):131 Districtinfo2.append(Districtinfo[i])132 if Districtinfo2[i] == '':133 Districtinfo2[i] = None134 self.assertEqual(Districtinfo2, districtlist, msg='必填添加区域二次编辑进入,数据显示错误')135 # 检查搜索136 def test_006(self):137 strnumber = time.strftime('%y%m%d%M%S', time.localtime())138 # 加号,英文冒号 系统未处理139 name2 = "TicketFree!@#$%^&*()Text" + strnumber140 # .get_attribute('content')141 EntranceAgentPage(self.driver).enter_district()142 time.sleep(5)143 # DistrictPage(self.driver).click_add()144 # time.sleep(3)145 # DistrictPage(self.driver).input_name(name2)146 # DistrictPage(self.driver).choose_valid()147 # DistrictPage(self.driver).addsubmit()148 #149 # num1, num2, num3, num4 = 0, 0, 0, 0150 # DistrictPage(self.driver).search('Ticket')151 # leftslaname = DistrictPage(self.driver).getleftslaname()152 # for i in range(0, len(leftslaname)):153 # print(len(leftslaname))154 # listinfo = leftslaname[i].get_attribute('content')155 # print(listinfo,1,name2)156 # if listinfo == name2:157 # num1 = num1 + 1158 #159 # DistrictPage(self.driver).search('Free')160 # leftslaname = DistrictPage(self.driver).getleftslaname()161 # for i in range(0, len(leftslaname)):162 # listinfo = leftslaname[i].text163 # if listinfo == name2:164 # num2 = num2 + 1165 #166 # DistrictPage(self.driver).search('Text')167 # leftslaname = DistrictPage(self.driver).getleftslaname()168 # for i in range(0, len(leftslaname)):169 # listinfo = leftslaname[i].text170 # if listinfo == name2:171 # num3 = num3 + 1172 #173 # DistrictPage(self.driver).search('!@#$%^&*()')174 # leftslaname = DistrictPage(self.driver).getleftslaname()175 # for i in range(0, len(leftslaname)):176 # listinfo = leftslaname[i].text177 # if listinfo == name2:178 # num4 = num4 + 1179 DistrictPage(self.driver).search('祥龙十八掌倚天屠龙记')180 empty_tip = DistrictPage(self.driver).get_empty_tip()181 # self.assertEqual(num1, 1, msg='错误:模糊搜索前段数据未查到匹配数据')182 # self.assertEqual(num2, 1, msg='错误:模糊搜索中段数据未查到匹配数据')183 # self.assertEqual(num3, 1, msg='错误:模糊搜索后段数据未查到匹配数据')184 # self.assertEqual(num4, 1, msg='错误:模糊搜索特殊字符未查到匹配数据')185 self.assertEqual(empty_tip, '暂无数据', msg='错误:模糊搜索特殊字符未查到匹配数据')186 # 全填创建区域 bug 列表中不显示备注,暂不判断列表数据187 # @Base.screenshot_about_case188 # def test_007(self):189 # # 未完成,区域值未取到190 # name, coment, parentdistrict = DistrictCommon(self.driver).DistrictFullCommon()191 # DistrictPage(self.driver).search(name)192 # DistrictPage(self.driver).click_search_result()193 # DistrictPage(self.driver).addsubmit()194 # DistrictPage(self.driver).search(name)195 # Districname = DistrictPage(self.driver).gettable_body()[0].text196 # Districcommon = DistrictPage(self.driver).gettable_body()[1].text197 # name2 = parentdistrict + "::" + name198 # self.assertEqual(Districname, name2, msg='错误,全填添加区域列表中名称显示错误')199 # # self.assertEqual(Districcommon, coment, msg='错误,全填添加区域列表中备注显示错误')200 #201 # DistrictPage(self.driver).click_search_result()202 # Districtinfo = DistrictCommon(self.driver).GetDistrictInfo()203 # districtlist = (name, parentdistrict, '有效', coment)...

Full Screen

Full Screen

test_page_objects.py

Source: test_page_objects.py Github

copy

Full Screen

...4 def go_to_google(self, sb):5 sb.open("https:/​/​google.com/​ncr")6 def do_search(self, sb, search_term):7 sb.type('input[title="Search"]', search_term + "\n")8 def click_search_result(self, sb, content):9 sb.click('a[href*="%s"]' % content)10class SeleniumBaseGitHubPage:11 def click_seleniumbase_io_link(self, sb):12 link = '#readme article a[href*="seleniumbase.io"]'13 sb.wait_for_element_visible(link)14 sb.js_click(link)15 sb.switch_to_newest_window()16class SeleniumBaseIOPage:17 def do_search_and_click(self, sb, search_term):18 if sb.is_element_visible('[for="__search"] svg'):19 sb.click('[for="__search"] svg')20 sb.type('form[name="search"] input', search_term)21 sb.click("li.md-search-result__item h1:contains(%s)" % search_term)22class MyTests(BaseCase):23 def test_page_objects(self):24 search_term = "SeleniumBase GitHub"25 expected_text = "seleniumbase/​SeleniumBase"26 GooglePage().go_to_google(self)27 GooglePage().do_search(self, search_term)28 self.assert_text(expected_text, "#search")29 GooglePage().click_search_result(self, expected_text)30 SeleniumBaseGitHubPage().click_seleniumbase_io_link(self)31 SeleniumBaseIOPage().do_search_and_click(self, "Dashboard")...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Feeding your QA Career – Developing Instinctive & Practical Skills

The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.

A Complete Guide To CSS Grid

Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.

Keeping Quality Transparency Throughout the organization

In general, software testers have a challenging job. Software testing is frequently the final significant activity undertaken prior to actually delivering a product. Since the terms “software” and “late” are nearly synonymous, it is the testers that frequently catch the ire of the whole business as they try to test the software at the end. It is the testers who are under pressure to finish faster and deem the product “release candidate” before they have had enough opportunity to be comfortable. To make matters worse, if bugs are discovered in the product after it has been released, everyone looks to the testers and says, “Why didn’t you spot those bugs?” The testers did not cause the bugs, but they must bear some of the guilt for the bugs that were disclosed.

A Detailed Guide To Xamarin Testing

Xamarin is an open-source framework that offers cross-platform application development using the C# programming language. It helps to simplify your overall development and management of cross-platform software applications.

How To Run Cypress Tests In Azure DevOps Pipeline

When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful