Python selenium.webdriver.common.keys.Keys.DELETE Examples
The following are 8
code examples of selenium.webdriver.common.keys.Keys.DELETE().
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_utils.py From sos-notebook with BSD 3-Clause "New" or "Revised" License | 6 votes |
def edit_cell(self, cell=None, index=0, content="", render=False): """Set the contents of a cell to *content*, by cell object or by index """ if cell is not None: index = self.index(cell) # # Select & delete anything already in the cell # self.current_cell.send_keys(Keys.ENTER) # if platform == "darwin": # command(self.browser, 'a') # else: # ctrl(self.browser, 'a') # self.current_cell.send_keys(Keys.DELETE) self.browser.execute_script("IPython.notebook.get_cell(" + str(index) + ").set_text(" + repr(dedent(content)) + ")") self._focus_cell(index) if render: self.execute_cell(self.current_index) # # Get info #
Example #2
Source File: end2end_test.py From promnesia with MIT License | 6 votes |
def set_position(driver, settings: str): browser = browser_(driver) # TODO figure out browser from driver?? field = driver.find_element_by_xpath('//*[@id="position_css_id"]') if browser.name == 'chrome': # ugh... for some reason wouldn't send the keys... field.click() import pyautogui # type: ignore # it usually ends up in the middle of the area... pyautogui.press(['backspace'] * 500 + ['delete'] * 500) pyautogui.typewrite(settings, interval=0.05) else: area = field.find_element_by_xpath('.//textarea') area.send_keys([Keys.DELETE] * 1000) area.send_keys(settings)
Example #3
Source File: page_objects.py From poium with Apache License 2.0 | 5 votes |
def delete(self): elem = self.__get_element(self.k, self.v) elem.send_keys(Keys.DELETE)
Example #4
Source File: base.py From tir with MIT License | 5 votes |
def send_keys(self, element, arg): """ [Internal] Clicks two times on the Selenium element. :param element: Selenium element :type element: Selenium object :param arg: Text or Keys to be sent to the element :type arg: str or selenium.webdriver.common.keys Usage: >>> #Defining the element: >>> element = lambda: self.driver.find_element_by_id("example_id") >>> #Calling the method with a string >>> self.send_keys(element(), "Text") >>> #Calling the method with a Key >>> self.send_keys(element(), Keys.ENTER) """ try: if arg.isprintable(): element.clear() element.send_keys(Keys.CONTROL, 'a') element.send_keys(arg) except Exception: actions = ActionChains(self.driver) actions.move_to_element(element) actions.click() if arg.isprintable(): actions.key_down(Keys.CONTROL).send_keys('a').key_up(Keys.CONTROL).send_keys(Keys.DELETE) actions.send_keys(Keys.HOME) actions.send_keys(arg) actions.perform()
Example #5
Source File: tv.py From Kairos with GNU General Public License v3.0 | 5 votes |
def clear(element): element.clear() element.send_keys(SELECT_ALL) element.send_keys(Keys.DELETE) time.sleep(DELAY_BREAK_MINI * 0.5)
Example #6
Source File: webdriver.py From seldom with Apache License 2.0 | 5 votes |
def delete(self): self.elem.send_keys(Keys.DELETE)
Example #7
Source File: whatsappRB.py From RomanceBreaker with GNU General Public License v3.0 | 5 votes |
def morningMessage(): #Sending message global driver global bae msg = random.choice(config.custom_morning_messages) baestr = str('"' + bae + '"') #Some Selenium stuff, don't bother try: pyperclip.copy(bae) searchbar = driver.find_elements_by_xpath('//*[@id="side"]/div[1]/div/label/input')[0] searchbar.click() #Click on searchbar searchbar.send_keys(Keys.CONTROL, 'v') #Search for contact for more speed x_arg = '//span[contains(@title,' + baestr + ')]' group_title = wait.until(EC.presence_of_element_located((By.XPATH, x_arg))) group_title.click() time.sleep(0.1) pyperclip.copy(msg) #Copies random message to clipboard message = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')[0] message.send_keys(Keys.CONTROL, 'v') #Sends message from clipboard time.sleep(0.1) sendbutton = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[3]/button')[0] sendbutton.click() #Presses send button searchbar.click() #Click on searchbar searchbar.send_keys(Keys.CONTROL, 'a') #Select all searchbar.send_keys(Keys.DELETE) #Delete searchbar content print("Message {} successfully sent to {}" .format(msg, bae)) except: print("Problem sending, retrying...") morningMessage() pass return #Getting username & pwd
Example #8
Source File: test_selenium.py From dokomoforms with GNU General Public License v3.0 | 4 votes |
def test_remove_url_slug(self): user = ( self.session .query(Administrator) .get('b7becd02-1a3f-4c1d-a0e1-286ba121aef4') ) with self.session.begin(): survey = construct_survey( creator=user, survey_type='public', title={'English': 'slug playground'}, ) self.session.add(survey) survey_id = survey.id self.get('/admin/' + survey_id) edit_btn = self.drv.find_element_by_class_name('glyphicon-pencil') self.click(edit_btn) slug_field = self.drv.find_element_by_class_name('shareable-url-slug') slug_field.send_keys('slug') self.click(self.drv.find_element_by_class_name('save-survey-url')) new_link = self.drv.find_element_by_id('shareable-link').text self.assertEqual(new_link, 'http://localhost:9999/enumerate/slug') edit_btn = self.drv.find_element_by_class_name('glyphicon-pencil') self.click(edit_btn) slug_field = self.drv.find_element_by_class_name('shareable-url-slug') slug_field.send_keys(Keys.DELETE) self.click(self.drv.find_element_by_class_name('save-survey-url')) new_old_link = self.drv.find_element_by_id('shareable-link').text self.assertEqual( new_old_link, 'http://localhost:9999/enumerate/' + survey_id ) self.get('/enumerate/slug') self.assertIn('404', self.drv.page_source)