How to use get_link_status_code method in SeleniumBase

Best Python code snippet using SeleniumBase

bls_cs_home_page.py

Source:bls_cs_home_page.py Github

copy

Full Screen

...21 self.open("https://blsvnint.brayleinosplash.com/")22 self.maximize_window()23 sleep(3)24 self.click('//a[@class="btn btn-ico btn-prev"]', delay=2)25 self.get_link_status_code('link:/work.html', True, 2)26 self.assert_title('Work - Bray Leino Splash Vietnam ')27 # Checking if each case study content is visible28 def test_case_study_contents(self):29 err_lst = []30 self.open("https://blsvnint.brayleinosplash.com/")31 self.maximize_window()32 sleep(3)33 elements = self.find_elements(34 '//div[@class="bls-select"]//select[@class="btn-select--white invisible"]//option')35 elements = self.find_elements(36 '//div[@class="case-studies__topic"]//div[@class="bls-select"]//ul[@class="bls-options"]/li')37 for i in range(len(elements)):38 if elements[i].get_attribute('class') == 'selected':39 current_active_item = i40 self.assert_('selected', current_active_item)41 break42 print("Total elements: ", len(elements))43 print(list(elements))44 print(len(elements))45 for i in range(len(elements) - 2):46 # self.assert_element('//div[@class="case-studies__topic"]//div[@class="bls-select"]//ul['47 # '@class="bls-options"]//li[@class="selected"]',"")48 self.click('//a[@class="btn btn-ico btn-next"]', delay=2)49 self.is_element_visible('//div[@id="divCaseStudyDescription"]//div[@class="desc"]//p')50 self.is_element_visible('//div[@class="case-studies-slide__wrapper"]//div[@class="img"]')51 self.is_element_visible('//div[@class="case-studies-slide__wrapper"]//div[@class="img"]//span['52 '@class="text-left"]')53 self.is_element_visible('//div[@class="case-studies-slide__wrapper"]//div[@class="desc"]')54 # div#divCaseStudySlide a55 link_cs = self.get_attribute('//div[@class="case-studies-slide__wrapper"]//a[@class="btn btn-secondary"]',56 'href')57 print(link_cs)58 status = self.get_link_status_code(link_cs)59 if status == 200:60 err_lst.append(1)61 else:62 err_lst.append(0)63 print('404 Link:', link_cs)64 link_to_current_cs = self.get_link_status_code('//ul[@class="case-studies__carousel bls-carousel__slider '65 'no-bls-carousel"]//a[@class="btn btn-secondary"]')66 if link_to_current_cs == 200:67 err_lst.append(1)68 else:69 err_lst.append(0)70 print('404 Link:', link_to_current_cs)71 link_to_all_cs = self.get_link_status_code('//div[@class="cmd text-center"]//a[@class="btn btn-text '72 'btn-text--white"]')73 if link_to_all_cs == 200:74 err_lst.append(1)75 else:76 err_lst.append(0)77 print('404 Link:', link_to_all_cs)78 # Checking is slider is available if the slider item >179 is_slider_visible = self.is_element_visible('//div[@class="bls-carousel"]//div['80 '@class="bls-carousel__dots"]//button['81 '@class="bls-carousel__dot"]')82 if is_slider_visible != '':83 slider_items_arr = self.find_elements(84 '//div[@class="case-studies-slide__wrapper"]//div[@class="bls-carousel"]//div['85 '@class="bls-carousel__dots"]')...

Full Screen

Full Screen

bls_live_cs_home_page.py

Source:bls_live_cs_home_page.py Github

copy

Full Screen

...21 self.open("https://www.brayleinosplash.com.sg/")22 self.maximize_window()23 sleep(3)24 self.click('//a[@class="btn btn-ico btn-prev"]', delay=2)25 self.get_link_status_code('link:/work.html', True, 2)26 self.assert_title('Work - Bray Leino Splash Vietnam ')27 # Checking if each case study content is visible28 def test_case_study_contents(self):29 err_lst = []30 self.open("https://www.brayleinosplash.com.sg/")31 self.maximize_window()32 sleep(3)33 elements = self.find_elements(34 '//div[@class="bls-select"]//select[@class="btn-select--white invisible"]//option')35 elements = self.find_elements(36 '//div[@class="case-studies__topic"]//div[@class="bls-select"]//ul[@class="bls-options"]/li')37 for i in range(len(elements)):38 if elements[i].get_attribute('class') == 'selected':39 current_active_item = i40 self.assert_('selected', current_active_item)41 break42 print("Total elements: ", len(elements))43 print(list(elements))44 print(len(elements))45 for i in range(len(elements) - 2):46 # self.assert_element('//div[@class="case-studies__topic"]//div[@class="bls-select"]//ul['47 # '@class="bls-options"]//li[@class="selected"]',"")48 self.click('//a[@class="btn btn-ico btn-next"]', delay=2)49 self.is_element_visible('//div[@id="divCaseStudyDescription"]//div[@class="desc"]//p')50 self.is_element_visible('//div[@class="case-studies-slide__wrapper"]//div[@class="img"]')51 self.is_element_visible('//div[@class="case-studies-slide__wrapper"]//div[@class="img"]//span['52 '@class="text-left"]')53 self.is_element_visible('//div[@class="case-studies-slide__wrapper"]//div[@class="desc"]')54 # div#divCaseStudySlide a55 link_cs = self.get_attribute('//div[@class="case-studies-slide__wrapper"]//a[@class="btn btn-secondary"]',56 'href')57 print(link_cs)58 status = self.get_link_status_code(link_cs)59 if status == 200:60 err_lst.append(1)61 else:62 err_lst.append(0)63 print('404 Link:', link_cs)64 link_to_current_cs = self.get_link_status_code('//ul[@class="case-studies__carousel bls-carousel__slider '65 'no-bls-carousel"]//a[@class="btn btn-secondary"]')66 if link_to_current_cs == 200:67 err_lst.append(1)68 else:69 err_lst.append(0)70 print('404 Link:', link_to_current_cs)71 link_to_all_cs = self.get_link_status_code('//div[@class="cmd text-center"]//a[@class="btn btn-text '72 'btn-text--white"]')73 if link_to_all_cs == 200:74 err_lst.append(1)75 else:76 err_lst.append(0)77 print('404 Link:', link_to_all_cs)78 # Checking is slider is available if the slider item >179 is_slider_visible = self.is_element_visible('//div[@class="bls-carousel"]//div['80 '@class="bls-carousel__dots"]//button['81 '@class="bls-carousel__dot"]')82 if is_slider_visible != '':83 slider_items_arr = self.find_elements(84 '//div[@class="case-studies-slide__wrapper"]//div[@class="bls-carousel"]//div['85 '@class="bls-carousel__dots"]')...

Full Screen

Full Screen

test_404.py

Source:test_404.py Github

copy

Full Screen

...20 def testNot404OnLogout(self):21 self.open(base_url + '/logout')22 self.assert_element_absent("#Error-funny")23 def test404OnSell(self):24 assert str(self.get_link_status_code(base_url + "/sell")).startswith('40')25 def test404OnBuy(self):26 assert str(self.get_link_status_code(base_url + "/buy")).startswith('40')27 def test404OnUpdate(self):28 assert str(self.get_link_status_code(base_url + "/update")).startswith('40')29 def test404(self):30 self.open(base_url + "/asdf")...

Full Screen

Full Screen

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