Python selenium.webdriver.common.keys.Keys.RIGHT Examples
The following are 6
code examples of selenium.webdriver.common.keys.Keys.RIGHT().
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.keys.Keys
, or try the search function
.
Example #1
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 #2
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 5 votes |
def test_timestamp_buckets_open_ranges(self): survey_id = self.survey_with_branch( 'timestamp', '(, 2015-01-01T1:00:00Z)', '[2015-01-10T1: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'), '2014-11-22T01: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-11-22T01: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-05T01: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 #3
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 5 votes |
def test_timestamp_buckets_total_open(self): survey_id = self.survey_with_branch('timestamp', '(,)') 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'), '1970-01-05T01: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'), '2070-01-05T01: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' )
Example #4
Source File: 2048.py From automate-the-boring-stuff-projects with MIT License | 5 votes |
def play(): """ Args: None Returns: None """ driver = webdriver.Firefox(executable_path='/Users/keneudeh/Downloads/geckodriver') driver.get('https://play2048.co/') key_select = [Keys.UP, Keys.DOWN, Keys.LEFT, Keys.RIGHT] gameStatusElem = driver.find_element_by_css_selector('.game-container p') htmlElem = driver.find_element_by_css_selector('html') while gameStatusElem.text != 'Game over!': htmlElem.send_keys(key_select[random.randint(0, 3)]) gameStatusElem = driver.find_element_by_css_selector('.game-container p') score = driver.find_element_by_css_selector('.score-container').text print(f'You scored: {score}')
Example #5
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 4 votes |
def test_required_question_bad_answer(self): user = ( self.session .query(Administrator) .get('b7becd02-1a3f-4c1d-a0e1-286ba121aef4') ) node = ( self.session .query(Node) .filter(Node.title['English'].astext == 'integer_node') .one() ) with self.session.begin(): survey = construct_survey( creator=user, survey_type='public', title={'English': 'required question'}, nodes=[ construct_survey_node( required=True, node=node, ), ], ) self.session.add(survey) survey_id = 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('not an integer') ) self.click(self.drv.find_element_by_class_name('navigate-right')) # An alert pops up # TODO: change this behavior alert = self.drv.switch_to.alert alert.accept() self.input_field().send_keys( Keys.RIGHT * 14, Keys.BACK_SPACE * 14, '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.assertEqual(new_submission.answers[0].answer, 3)
Example #6
Source File: collect_links.py From AutoCrawler with Apache License 2.0 | 4 votes |
def naver_full(self, keyword, add_url=""): print('[Full Resolution Mode]') self.browser.get("https://search.naver.com/search.naver?where=image&sm=tab_jum&query={}{}".format(keyword, add_url)) time.sleep(1) elem = self.browser.find_element_by_tag_name("body") print('Scraping links') self.wait_and_click('//div[@class="img_area _item"]') time.sleep(1) links = [] count = 1 last_scroll = 0 scroll_patience = 0 while True: try: xpath = '//div[@class="image_viewer_wrap _sauImageViewer"]//img[@class="_image_source"]' imgs = self.browser.find_elements(By.XPATH, xpath) for img in imgs: self.highlight(img) src = img.get_attribute('src') if src not in links and src is not None: links.append(src) print('%d: %s' % (count, src)) count += 1 except StaleElementReferenceException: # print('[Expected Exception - StaleElementReferenceException]') pass except Exception as e: print('[Exception occurred while collecting links from naver_full] {}'.format(e)) scroll = self.get_scroll() if scroll == last_scroll: scroll_patience += 1 else: scroll_patience = 0 last_scroll = scroll if scroll_patience >= 30: break elem.send_keys(Keys.RIGHT) links = self.remove_duplicates(links) print('Collect links done. Site: {}, Keyword: {}, Total: {}'.format('naver_full', keyword, len(links))) self.browser.close() return links