How to use assert_element_visible method in SeleniumBase

Best Python code snippet using SeleniumBase

gui_tests.py

Source:gui_tests.py Github

copy

Full Screen

...55 self.driver.find_element_by_id('admin').click()56 self.driver.find_element_by_id('submit-login').click()57 self.driver.get(self.base_url + url)58 #----------------------------assert section -------------------------------59 def assert_element_visible(self, how, what, message):60 try:61 return WebDriverWait(self.driver, 10).until(62 EC.visibility_of_element_located((how, what)))63 except:64 logging.exception('')65 self.fail(message)66 def assert_element_invisible(self, how, what, message):67 try:68 return WebDriverWait(self.driver, 3).until(EC69 .invisibility_of_element_located((how, what)))70 except:71 self.fail(message)72 #------------------------bussines logic section ---------------------------73 def test_list(self):74 driver = self.driver75 fixtures.add_example_clean_process_users(amount=45)76 self.default_login('/admin/process')77 self.assert_element_visible(78 By.ID,'processes-list','Process list title does not appears')79 td_list1 = [td.text for td in driver.find_elements_by_xpath(80 '//*[@id="process-list"]/tbody/tr/td[1]')]81 self.assertEquals(constants.PAGE_SIZE, len(td_list1),'list len does '82 'not match')83 self.assert_element_invisible(By.ID,'prev-id','button appears')84 self.assert_element_visible(By.ID,'home-id','button does not appear')85 self.assert_element_visible(By.ID,'next-id','button does not '86 'appear').click()87 td_list2 = [td.text for td in driver.find_elements_by_xpath(88 '//*[@id="process-list"]/tbody/tr/td[1]')]89 self.assertEquals(constants.PAGE_SIZE, len(td_list2),'list len does '90 'not match')91 self.assert_element_visible(By.ID,'prev-id','button appears')92 self.assert_element_visible(By.ID,'home-id','button does not appear')93 self.assert_element_visible(By.ID,'next-id','button does not '94 'appear').click()95 self.assertNotEqual(set(td_list1),set(td_list2))96 td_list3 = [td.text for td in driver.find_elements_by_xpath(97 '//*[@id="process-list"]/tbody/tr/td[1]')]98 self.assertLess(len(td_list3),constants.PAGE_SIZE)99 self.assert_element_invisible(By.ID,'next-id','button does not appear')100 self.assert_element_visible(By.ID,'home-id','button does not appear')101 self.assert_element_visible(By.ID,'prev-id','button appears').click()102 self.assertNotEqual(set(td_list2),set(td_list3))103 td_list4 = [td.text for td in driver.find_elements_by_xpath(104 '//*[@id="process-list"]/tbody/tr/td[1]')]105 self.assertEquals(constants.PAGE_SIZE, len(td_list4),'list len does '106 'not match')107 self.assertEquals(set(td_list2),set(td_list4))108 def test_create(self):109 driver = self.driver110 self.default_login('/admin/process')111 driver.find_element_by_id('process_name').send_keys('process1')112 driver.find_element_by_id('source_email').send_keys('test')113 driver.find_element_by_id('source_password').send_keys(114 secret_keys.ADMIN_PASSWORD)115 driver.find_element_by_id('search_criteria').send_keys('search_criteria')116 driver.find_element_by_id('add-process-button').click()117 self.assert_element_invisible(By.CLASS_NAME, 'alert-success','object '118 'appears')119 driver.find_element_by_id('source_email').clear()120 driver.find_element_by_id('source_email').send_keys(121 secret_keys.ADMIN_USERNAME)122 driver.find_element_by_id('add-process-button').click()123 time.sleep(2)124 self.assert_element_visible(By.CLASS_NAME, 'alert-success','Object '125 'does not '126 'appears')127 td_list1 = [td.text for td in driver.find_elements_by_xpath(128 '//*[@id="process-list"]/tbody/tr/td[1]')]129 self.assertEquals(1, len(td_list1),'list len does not match')130if __name__ == '__main__':...

Full Screen

Full Screen

Test_Registration.py

Source:Test_Registration.py Github

copy

Full Screen

...6 )7 self.assert_title(8 'ტესტ ჩელენჯი'9 )10 self.assert_element_visible(11 'body > app-root > app-register-container > div.wrapper > div'12 )13 def test_geo_towns(self):14 self.open(15 'http://testing.challenge.crocoteam.ge:1110/#/'16 )17 self.assert_element_visible(18 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__form-input.country-city > div.wrapper__form-input__city > app-shared-select > div > ng-select > div'19 )20 self.click(21 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__form-input.country-city > div.wrapper__form-input__city > app-shared-select > div > ng-select > div'22 )23 city_list = self.find_elements(24 "//*[starts-with(@class, 'ng-option-label')]"25 )26 for i in city_list:27 print(i.text)28 def test_dates(self):29 self.open(30 'http://testing.challenge.crocoteam.ge:1110/#/'31 )32 self.assert_element_visible(33 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__form-date > div.wrapper__form-date-year > app-shared-select > div > ng-select > div'34 )35 self.click(36 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__form-date > div.wrapper__form-date-year > app-shared-select > div > ng-select > div'37 )38 expected_dates = ['2005',39 '2004',40 '2003',41 '2002',42 '2001',43 '2000',44 '1999',45 '1998',46 '1997',47 '1996',48 '1995',49 '1994',50 '1993',51 '1992',52 '1991',53 '1990',54 ]55 available_dates = self.find_elements("//*[starts-with(@class, 'ng-option-label')]")56 for idx,i in enumerate(available_dates):57 self.assertEqual(expected_dates[idx],i.text)58 def test_mail_input(self):59 self.open(60 'http://testing.challenge.crocoteam.ge:1110/#/'61 )62 self.assert_element_visible(63 '/html/body/app-root/app-register-container/div[2]/form/div[7]/app-shared-input/div/label'64 )65 self.send_keys(66 '/html/body/app-root/app-register-container/div[2]/form/div[7]/app-shared-input/div[1]/input',67 'სადადა'68 )69 self.click(70 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__account-details > div.wrapper__form-input > app-shared-input > div.input-container > input'71 )72 self.assert_text(73 'არასწორი ფორმატი'74 )75 self.send_keys(76 '/html/body/app-root/app-register-container/div[2]/form/div[7]/app-shared-input/div[1]/input',77 '@'78 )79 self.click(80 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__account-details > div.wrapper__form-input > app-shared-input > div.input-container > input'81 )82 self.assert_text(83 'არასწორი ფორმატი'84 )85 self.send_keys(86 '/html/body/app-root/app-register-container/div[2]/form/div[7]/app-shared-input/div[1]/input',87 'gmail.com'88 )89 def test_password_input(self):90 self.open(91 'http://testing.challenge.crocoteam.ge:1110/#/'92 )93 self.assert_element_visible(94 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__account-details > div.wrapper__passwords > div:nth-child(1) > app-shared-input > div.input-container > input'95 )96 self.assert_element_visible(97 '/html/body/app-root/app-register-container/div[2]/form/div[8]/div[3]/div[2]/app-shared-input/div/input'98 )99 self.send_keys(100 '/html/body/app-root/app-register-container/div[2]/form/div[8]/div[3]/div[1]/app-shared-input/div/input',101 'Sportman1'102 )103 self.send_keys(104 '/html/body/app-root/app-register-container/div[2]/form/div[8]/div[3]/div[2]/app-shared-input/div/input',105 'Sportman1'106 )107 self.assert_element_visible(108 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__account-details > div.warpper__validations > p:nth-child(1)'109 )110 self.assert_element_visible(111 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__account-details > div.warpper__validations > p:nth-child(2)'112 )113 self.assert_element_visible(114 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__account-details > div.warpper__validations > p:nth-child(3)'115 )116 self.assert_element_visible(117 'body > app-root > app-register-container > div.wrapper > form > div.wrapper__account-details > div.warpper__validations > p:nth-child(4)'...

Full Screen

Full Screen

navigation.py

Source:navigation.py Github

copy

Full Screen

...27 sb.assert_no_404_errors()28def test_article_feedback(sb, homeUrl):29 searchPickTop(sb, 'how')30 assert_onArticlePage(sb)31 sb.assert_element_visible(articleBtnYes)32 sb.assert_element_visible(articleBtnNo)33 btns = [articleBtnYes, articleBtnNo]34 pick = randrange(len(btns))35 print(f'clicking {btns[pick]}')36 sb.click(btns[pick])37 sb.assert_text_visible(FEEDBACK_THANKS)38@pytest.mark.desktop39def test_nav_back_from_article(sb, homeUrl):40 searchPickTop(sb, 'how')41 assert_onArticlePage(sb)42 sb.assert_element_visible(cssCrumbs)43 crumbLinks3 = sb.find_elements(cssCrumbLinks)44 assert len(crumbLinks3) == 345 crumbLinks3[-1].click()46 assert_onSubcatPage(sb)47 sb.assert_element_visible(cssCrumbs)48 crumbLinks3 = sb.find_elements(cssCrumbLinks)49 assert len(crumbLinks3) == 350 crumbLinks3[-2].click()51 assert_onCatPage(sb)52 sb.assert_element_visible(cssCrumbs)53 crumbLinks2 = sb.find_elements(cssCrumbLinks)54 assert len(crumbLinks2) == 255 crumbLinks2[-2].click()56 assert_onHomePage(sb, homeUrl)57 crumbLinks0 = sb.find_elements(cssCrumbLinks)58 assert len(crumbLinks0) == 059# --- helper funcs ----------------60def assert_onHomePage(sb, homeUrl):61 assert sb.get_current_url() in homeUrl62def assert_onCatPage(sb):63 sb.assert_element_visible(firstAccordion)64def assert_onSubcatPage(sb):65 sb.assert_element_visible(firstArticleLink)66def assert_onArticlePage(sb):67 sb.assert_element_visible(articleScreen)68 sb.assert_element_visible(articleFeedback)69def openCategoryPage(sb):70 sb.click(tileImages)71 assert_onCatPage(sb)72def openSubcategoryPage(sb):73 sb.click(firstAccordion)74 def waitForArticleLinks():75 vlinks = sb.find_visible_elements('a')76 alinks = [vl for vl in vlinks if vl.text.startswith(TEXT_ALL_ARTICLES)]77 assert len(alinks) > 078 return alinks79 alinks = retry(waitForArticleLinks, 10, 1)80 alinks[-1].click()81 assert_onSubcatPage(sb)82def openArticlePage(sb):...

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