Python selenium.webdriver.common.by.By.CLASS_NAME Examples
The following are 30
code examples of selenium.webdriver.common.by.By.CLASS_NAME().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
selenium.webdriver.common.by.By
, or try the search function
.
Example #1
Source File: screenshot.py From AboveTustin with MIT License | 8 votes |
def loadmap(self): ''' loadmap() Creates a browser object and loads the webpage. It sets up the map to the proper zoom level. Returns the browser on success, None on fail. ''' browser = webdriver.PhantomJS(desired_capabilities={'phantomjs.page.settings.resourceTimeout': '20000'}) browser.set_window_size(abovetustin_image_width, abovetustin_image_height) print("getting web page {}".format(self.url)) browser.set_page_load_timeout(15) browser.get(self.url) # Need to wait for the page to load timeout = g_request_timeout print ("waiting for page to load...") wait = WebDriverWait(browser, timeout) element = wait.until(EC.element_to_be_clickable((By.CLASS_NAME,'vrsMenu'))) self.browser = browser
Example #2
Source File: scrape_espncricinfo.py From Awesome-Scripts with MIT License | 7 votes |
def get_latest_wallpapers(): browser = webdriver.PhantomJS(PHANTOMJS_PATH, service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any']) today_date = time.strftime("%d+%b+%Y") yesterday = datetime.now() - timedelta(days=1) yesterday_date = yesterday.strftime('%d+%b+%Y') first_page_url = 'http://www.espncricinfo.com/ci/content/image/?datefrom='+yesterday_date+'&dateupto='+today_date+';' browser.get(first_page_url) wait = WebDriverWait(browser, 10) wait.until(EC.visibility_of_element_located((By.CLASS_NAME, "img-wrap"))) time.sleep(2) # let's parse our html soup = BeautifulSoup(browser.page_source, "html.parser") images = soup.find_all('div', class_='picture') for image in images: url = "http://www.espncricinfo.com/" + image.find('a').get('href') print(url)
Example #3
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_single_decimal_question_bad_input(self): survey_id = self.get_single_node_survey_id('decimal') self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) ( self.drv .find_element_by_tag_name('input') .send_keys('3.3.3') ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_element_by_class_name('navigate-right')) # No submit button. self.assertEqual( len(self.drv.find_elements_by_tag_name('button')), 1 )
Example #4
Source File: tntapi.py From 20up with GNU General Public License v3.0 | 6 votes |
def getNextPicture(self): """ Get the next picture to the given picture. """ try: next = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.ID, INFOS['next']))) try: self.driver.execute_script("document.getElementById('" + INFOS['next'] + "').focus();") except: pass finally: next.click() except: try: next = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, INFOS['next3']))) next.click() except: pass
Example #5
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_single_time_question(self): survey_id = self.get_single_node_survey_id('time') existing_submission = self.get_last_submission(survey_id) self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) self.enter_time( self.drv.find_element_by_tag_name('input'), '3', '33', 'PM' ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_elements_by_tag_name('button')[0]) new_submission = self.get_last_submission(survey_id) self.assertIsNot(existing_submission, new_submission) answer = new_submission.answers[0].answer.isoformat() answer_parts = re.split('[-+]', answer) self.assertEqual(len(answer_parts), 2) self.assertEqual(answer_parts[0], '15:33:00')
Example #6
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_decimal_buckets_total_open(self): survey_id = self.survey_with_branch('decimal', '(,)') self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) ( self.drv .find_element_by_tag_name('input') .send_keys('-999.1') ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b0' ) self.click(self.drv.find_element_by_class_name('page_nav__prev')) self.input_field().send_keys(Keys.BACK_SPACE * 6, '999.1') self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b0' )
Example #7
Source File: gp_privacy_crawler.py From crawler with MIT License | 6 votes |
def get_privacy(driver, package_name): try: url = "https://play.google.com/store/apps/details?id={0}&hl=en".format(package_name) driver.get(url) driver.maximize_window() driver.find_element_by_link_text("View details").click() tmp = (By.CLASS_NAME, "fnLizd") WebDriverWait(driver, 20).until(EC.presence_of_element_located(tmp)) page_source = driver.page_source if "send SMS messages" in page_source: print("找到含有SMS权限的APP: {0}".format(package_name)) with open("privacy_with_sms.txt", "a+") as f: f.write(package_name + "\n") return package_name return False except Exception as e: print(e) return False
Example #8
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_offline_no_submit_button(self): survey_id = self.get_single_node_survey_id('integer') self.get('/enumerate/{}'.format(survey_id)) self.toggle_online() self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) ( self.drv .find_element_by_tag_name('input') .send_keys('3') ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual(len(self.drv.find_elements_by_tag_name('button')), 1)
Example #9
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_integer_buckets_total_open(self): survey_id = self.survey_with_branch('integer', '(,)') self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) ( self.drv .find_element_by_tag_name('input') .send_keys('-999') ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b0' ) self.click(self.drv.find_element_by_class_name('page_nav__prev')) self.input_field().send_keys(Keys.BACK_SPACE * 4, '999') self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b0' )
Example #10
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_single_timestamp_question(self): survey_id = self.get_single_node_survey_id('timestamp') existing_submission = self.get_last_submission(survey_id) self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) self.enter_timestamp( self.drv.find_element_by_tag_name('input'), '2015-08-11T15:33:00' ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_elements_by_tag_name('button')[0]) new_submission = self.get_last_submission(survey_id) self.assertIsNot(existing_submission, new_submission) answer = new_submission.answers[0].answer self.assertEqual(answer.isoformat(), '2015-08-11T15:33:00+00:00')
Example #11
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_single_date_question(self): survey_id = self.get_single_node_survey_id('date') existing_submission = self.get_last_submission(survey_id) self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) self.enter_date( self.drv.find_element_by_tag_name('input'), '2015', '08', '11' ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_elements_by_tag_name('button')[0]) new_submission = self.get_last_submission(survey_id) self.assertIsNot(existing_submission, new_submission) self.assertEqual( new_submission.answers[0].answer.isoformat(), '2015-08-11' )
Example #12
Source File: base.py From cadasta-platform with GNU Affero General Public License v3.0 | 6 votes |
def try_cancel_and_close_confirm_modal(self, click_on_button, modal_id, check_input=None): close_buttons = ['cancel', 'close'] for close in close_buttons: click_on_button() button = self.browser.find_element_by_xpath( "//div[@id='{id}']" "//button[contains(@class, '{button}')]".format( id=modal_id, button=close)) self.click_through_close( button, (By.CLASS_NAME, 'modal-backdrop')) if check_input: check_input()
Example #13
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_single_decimal_question(self): survey_id = self.get_single_node_survey_id('decimal') existing_submission = self.get_last_submission(survey_id) self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) ( self.drv .find_element_by_tag_name('input') .send_keys('3.3') ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_elements_by_tag_name('button')[0]) new_submission = self.get_last_submission(survey_id) self.assertIsNot(existing_submission, new_submission) self.assertEqual(new_submission.answers[0].answer, Decimal('3.3'))
Example #14
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_previous_and_next(self): survey_id = self.get_single_node_survey_id('integer') self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) ( self.drv .find_element_by_tag_name('input') .send_keys('3') ) self.click(self.drv.find_element_by_class_name('page_nav__prev')) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('input').get_attribute('value'), '3' )
Example #15
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_change_language(self): survey_id = 'c0816b52-204f-41d4-aaf0-ac6ae2970925' # login as enumerator self.get('/debug/login/test_enumerator@fixtures.com') self.sleep() self.get('/enumerate/{}'.format(survey_id)) self.sleep() self.wait_for_element('menu', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('menu')) lang = Select(self.drv.find_element_by_class_name('language_select')) self.assertEqual(len(lang.options), 3) self.select_by_index(lang, 1) self.sleep() title = self.drv.find_element_by_css_selector( '.content-padded h3').text self.assertEqual(title, 'ENUMERATOR_ONLY_SINGLE_SURVEY')
Example #16
Source File: OrganizationList.py From cadasta-platform with GNU Affero General Public License v3.0 | 6 votes |
def try_submit(self, err=None, ok=None, message=None): BY_ORG_DASHBOARD = (By.CLASS_NAME, 'organization-dashboard') fields = self.get_fields() sel = BY_ORG_DASHBOARD if err is None else self.test.BY_FIELD_ERROR self.test.click_through(fields['add'], sel, screenshot='tst') fields = self.get_fields() if err is not None: for f in err: try: self.test.assert_field_has_error(fields[f], message) except AssertionError: raise AssertionError( 'Field "' + f + '" should have error, but does not' ) if ok is not None: for f in ok: try: self.test.assert_field_has_no_error(fields[f]) except AssertionError: raise AssertionError( 'Field "' + f + '" should not have error, but does' )
Example #17
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_single_integer_question_bad_input(self): survey_id = self.get_single_node_survey_id('integer') self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) ( self.drv .find_element_by_tag_name('input') .send_keys('so not an integer') ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_element_by_class_name('navigate-right')) # No submit button. self.assertEqual( len(self.drv.find_elements_by_tag_name('button')), 1 )
Example #18
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_submission_details_button(self): self.get('/admin/b0816b52-204f-41d4-aaf0-ac6ae2970923') self.sleep() self.wait_for_element( '#submissions > tbody > tr:nth-of-type(1)', by=By.CSS_SELECTOR ) self.click(self.drv.find_element_by_css_selector( '#submissions > tbody > tr:nth-of-type(1)' )) self.wait_for_element('response-data', by=By.CLASS_NAME) self.assertEqual( self.drv.find_element_by_class_name('response-data').text, '3' )
Example #19
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_download_json_button(self): self.get('/admin/b0816b52-204f-41d4-aaf0-ac6ae2970923') self.wait_for_element('btn-primary', by=By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('btn-primary')) self.click(self.drv.find_element_by_css_selector( '.open > ul:nth-child(2) > li:nth-child(1) > a:nth-child(1)' )) self.sleep() self.switch_window() self.sleep() response = BeautifulSoup(self.drv.page_source, 'html.parser') try: json_str = response.find('pre').text except AttributeError: self.sleep() response = BeautifulSoup(self.drv.page_source, 'html.parser') json_str = response.find('pre').text data = json.loads(json_str) self.assertEqual(data['total_entries'], 101) self.assertEqual(data['total_entries'], 101) self.assertEqual(len(data['submissions']), 101)
Example #20
Source File: OrganizationMemberList.py From cadasta-platform with GNU Affero General Public License v3.0 | 6 votes |
def try_submit(self, err=None, ok=None, message=None): BY_MEMBER_PAGE = (By.CLASS_NAME, 'org-member-edit') fields = self.get_fields() sel = BY_MEMBER_PAGE if err is None else self.test.BY_FIELD_ERROR self.test.click_through(fields['submit'], sel, screenshot='tst') if err is not None: fields = self.get_fields() for f in err: try: self.test.assert_field_has_error(fields[f], message) except AssertionError: raise AssertionError( 'Field "' + f + '" should have error, but does not' )
Example #21
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_recent_submissions(self): self.get('/') self.wait_for_element( 'tr.submission-row:nth-child(1) > td:nth-child(1)', by=By.CSS_SELECTOR ) self.click(self.drv.find_element_by_css_selector( 'tr.submission-row:nth-child(1) > td:nth-child(1)' )) self.wait_for_element('stat-label', by=By.CLASS_NAME) self.assertGreater( len(self.drv.find_elements_by_class_name('stat-label')), 0 )
Example #22
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 6 votes |
def test_login(self): if self.browser == 'android': raise unittest.SkipTest("The popup doesn't open in the webview.") self.get('/') self.wait_for_element('btn-login', By.CLASS_NAME) self.click(self.drv.find_elements_by_class_name('btn-login')[-1]) self.sleep() self.switch_window() self.wait_for_element('authentication_email', visible=True) ( self.drv .find_element_by_id('authentication_email') .send_keys('test@mockmyid.com', Keys.RETURN) ) self.switch_window(go_back=True) self.wait_for_element('UserDropdown', timeout=10) self.assertIn('Recent Submissions', self.drv.page_source)
Example #23
Source File: tv.py From Kairos with GNU General Public License v3.0 | 6 votes |
def is_indicator_loaded(browser, chart_index, pane_index, indicator_index, name=""): # get css selector that has the loading animation for the indicator elem_loading = find_elements(find_elements( find_elements(find_elements(browser, 'chart-container', By.CLASS_NAME)[chart_index], 'pane', By.CLASS_NAME)[pane_index], 'div[data-name="legend-source-item"]', By.CSS_SELECTOR)[ indicator_index], 'div[class^="valuesWrapper"] > span[class^="loader"]', By.CSS_SELECTOR) # check if any of the elements is loaded indicator_loaded = True if len(elem_loading) == 0: if name != "": name = "{} at index ".format(name) log.warn("unable to find 'loading' elements of indicator {}{} on pane {} on chart {}".format(name, indicator_index, pane_index, chart_index)) for elem in elem_loading: if elem.is_displayed(): indicator_loaded = False break return indicator_loaded or len(elem_loading) == 0
Example #24
Source File: base.py From cadasta-platform with GNU Affero General Public License v3.0 | 6 votes |
def try_cancel_and_close(self, click_on_button, fill_inputbox=None, check_input=None): """ Check to make sure that the close and cancel buttons work on modals. """ close_buttons = ['btn-link', 'close'] for close in close_buttons: if fill_inputbox: fill_inputbox() cancel = self.link(close) self.click_through_close( cancel, (By.CLASS_NAME, 'modal-backdrop')) click_on_button() if check_input: check_input()
Example #25
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 5 votes |
def test_decimal_buckets_open_ranges(self): survey_id = self.survey_with_branch('decimal', '(, 0.1)', '[10.1,)') self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) ( self.drv .find_element_by_tag_name('input') .send_keys('-5.1') ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b0' ) self.click(self.drv.find_element_by_class_name('page_nav__prev')) self.input_field().send_keys(Keys.BACK_SPACE * 4, '15.1') self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b1' ) self.click(self.drv.find_element_by_class_name('page_nav__prev')) self.input_field().send_keys(Keys.BACK_SPACE * 4, '5.1') self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'last question' )
Example #26
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 5 votes |
def test_timestamp_buckets(self): survey_id = self.survey_with_branch( 'timestamp', '(2015-01-01T12:00:00Z, 2015-01-03T12:00:00Z)', '[2015-01-04T12:00:00Z, 2015-01-05T12:00:00Z]' ) self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) self.enter_timestamp( self.drv.find_element_by_tag_name('input'), '2015-01-02T12:00:00' ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b0' ) self.click(self.drv.find_element_by_class_name('page_nav__prev')) self.input_field().send_keys(Keys.RIGHT * 30, Keys.BACK_SPACE * 30) self.enter_timestamp( self.drv.find_element_by_tag_name('input'), '2015-01-04T12:00:00' ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b1' ) self.click(self.drv.find_element_by_class_name('page_nav__prev')) self.input_field().send_keys(Keys.RIGHT * 30, Keys.BACK_SPACE * 30) self.enter_timestamp( self.drv.find_element_by_tag_name('input'), '2015-01-01T12:00:00' ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'last question' )
Example #27
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 5 votes |
def test_date_buckets_total_open(self): survey_id = self.survey_with_branch('date', '(,)') self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) self.enter_date( self.drv.find_element_by_tag_name('input'), '1970', '01', '05' ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b0' ) self.click(self.drv.find_element_by_class_name('page_nav__prev')) self.input_field().send_keys(Keys.BACK_SPACE * 10) self.enter_date( self.drv.find_element_by_tag_name('input'), '2070', '01', '05' ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b0' )
Example #28
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 5 votes |
def test_decimal_buckets(self): survey_id = self.survey_with_branch( 'decimal', '(1.2, 3.2)', '[4.2, 5.2]' ) self.get('/enumerate/{}'.format(survey_id)) self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) ( self.drv .find_element_by_tag_name('input') .send_keys('1.3') ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b0' ) self.click(self.drv.find_element_by_class_name('page_nav__prev')) self.input_field().send_keys(Keys.BACK_SPACE * 3, '4.2') self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'b1' ) self.click(self.drv.find_element_by_class_name('page_nav__prev')) self.input_field().send_keys(Keys.BACK_SPACE * 3, '1.2') self.click(self.drv.find_element_by_class_name('navigate-right')) self.assertEqual( self.drv.find_element_by_tag_name('h3').text, 'last question' )
Example #29
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 5 votes |
def test_offline_work_is_saved(self): survey_id = self.get_single_node_survey_id('integer') existing_submission = self.get_last_submission(survey_id) enumerate_url = '/enumerate/{}'.format(survey_id) self.get(enumerate_url) self.toggle_online() self.wait_for_element('navigate-right', By.CLASS_NAME) self.click(self.drv.find_element_by_class_name('navigate-right')) ( self.drv .find_element_by_tag_name('input') .send_keys('3') ) self.click(self.drv.find_element_by_class_name('navigate-right')) self.click(self.drv.find_element_by_class_name('navigate-right')) self.drv.get('about:blank') # unload the page self.get(enumerate_url) self.click(self.drv.find_elements_by_tag_name('button')[0]) new_submission = self.get_last_submission(survey_id) self.assertIsNot(existing_submission, new_submission) self.assertEqual(new_submission.answers[0].answer, 3)
Example #30
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 5 votes |
def test_add_user(self): self.get('/admin/user-administration') self.wait_for_element('btn-edit-user', by=By.CLASS_NAME) rows = self.drv.find_elements_by_class_name('btn-edit-user') self.assertEqual(len(rows), 3) self.sleep(1) self.click(self.drv.find_element_by_class_name('btn-add-user')) self.wait_for_element('user-name') ( self.drv .find_element_by_id('user-name') .send_keys('new_user') ) ( self.drv .find_element_by_id('user-email') .send_keys('new@email.com') ) save_btn = self.drv.find_element_by_class_name('btn-save-user') self.sleep() save_btn.click() self.sleep() self.get('/admin/user-administration') self.sleep() rows = self.drv.find_elements_by_css_selector('table#users tbody tr') self.assertEqual(len(rows), 4)