當前位置: 首頁>>代碼示例>>Python>>正文


Python Keys.CONTROL屬性代碼示例

本文整理匯總了Python中selenium.webdriver.common.keys.Keys.CONTROL屬性的典型用法代碼示例。如果您正苦於以下問題:Python Keys.CONTROL屬性的具體用法?Python Keys.CONTROL怎麽用?Python Keys.CONTROL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在selenium.webdriver.common.keys.Keys的用法示例。


在下文中一共展示了Keys.CONTROL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_code_editor_go_to_line_function

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def test_code_editor_go_to_line_function(self):
        # * Harold logs in and creates a new sheet
        self.login_and_create_new_sheet()

        # He enters some long and complicated usercode and doesn't hit "save".
        code = ""
        for i in range(200):
            code += "a\n"

        self.enter_usercode(code, commit_change=False)

        # He hits ^L, and types 100 into the resulting dialog.
        self.get_element('id=id_usercode').click()
        with self.key_down(Keys.CONTROL):
            self.human_key_press('l')
        alert = self.browser.switch_to_alert()
        alert.send_keys(100)
        alert.accept()

        # The editor jumps to line 100
        self.assertEquals(self.get_editor_selected_range(), (0, 99, 0, 99))

        # The line is, of course, visible.
        self.assert_editor_line_visible(100) 
開發者ID:pythonanywhere,項目名稱:dirigible-spreadsheet,代碼行數:26,代碼來源:test_2521_CodeEditor.py

示例2: send_mks_keys

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def send_mks_keys(self,keys,wait='5s'):
    """ Sends key strokes to current web console

    Special Ctrl char could be used as ``${CTRL_A}`` to ``${CTRL_Z}``

    Examples:
    | `Send MKS Key`   |     ${CTRL_L} |

    *Notes*: For other usable key value, see Selenium document
    """
    driver = BuiltIn().get_library_instance('SeleniumLibrary')
    canvas = driver.get_webelement('mainCanvas')
    if len(keys) == 1 and ord(keys) < ord('@'):
        canvas.send_keys(Keys.CONTROL + chr(ord(keys) + ord('@')))
    else:
        canvas.send_keys(keys)
    time.sleep(DateTime.convert_time(wait))
    BuiltIn().log('Sent keystrokes to the web console') 
開發者ID:bachng2017,項目名稱:RENAT,代碼行數:20,代碼來源:vmware.py

示例3: find_children

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def find_children(driver):
    body = driver.find_elements_by_tag_name('body')
    assert len(body) == 1
    body = body[0]

    body.send_keys(Keys.CONTROL, 0)

    buttons = body.find_elements_by_tag_name('button')
    links = body.find_elements_by_tag_name('a')
    inputs = body.find_elements_by_tag_name('input')
    selects = body.find_elements_by_tag_name('select')
    children = buttons + links + inputs + selects

    random.shuffle(children)

    return children 
開發者ID:mozilla,項目名稱:coverage-crawler,代碼行數:18,代碼來源:crawler.py

示例4: execute_cell

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def execute_cell(self,
                     cell_or_index=None,
                     in_console=False,
                     expect_error=False):
        if isinstance(cell_or_index, int):
            index = cell_or_index
        elif isinstance(cell_or_index, WebElement):
            index = self.index(cell_or_index)
        else:
            raise TypeError("execute_cell only accepts a WebElement or an int")
        self._focus_cell(index)
        if in_console:
            self.current_cell.send_keys(Keys.CONTROL, Keys.SHIFT, Keys.ENTER)
            self._wait_for_done(-1, expect_error)
        else:
            self.current_cell.send_keys(Keys.CONTROL, Keys.ENTER)
            self._wait_for_done(index, expect_error) 
開發者ID:vatlab,項目名稱:sos-notebook,代碼行數:19,代碼來源:test_utils.py

示例5: edit_prompt_cell

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def edit_prompt_cell(self,
                         content,
                         kernel='SoS',
                         execute=False,
                         expect_error=False):
        # print("panel", self.prompt_cell.get_attribute("innerHTML"))
        self.browser.execute_script("window.my_panel.cell.set_text(" +
                                    repr(dedent(content)) + ")")

        # the div is not clickable so I use send_key to get around it
        self.prompt_cell.send_keys('\n')
        self.select_console_kernel(kernel)
        #   self.prompt_cell.find_element_by_css_selector('.CodeMirror').click()
        if execute:
            self.prompt_cell.send_keys(Keys.CONTROL, Keys.ENTER)
            self._wait_for_done(-1, expect_error=expect_error) 
開發者ID:vatlab,項目名稱:sos-notebook,代碼行數:18,代碼來源:test_utils.py

示例6: switch_tab

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def switch_tab(driver):
    main_window = driver.current_window_handle
    body = driver.find_element_by_tag_name("body")
    # body.send_keys(Keys.CONTROL + 't')
    body.send_keys(Keys.CONTROL + 't')
    driver.switch_to_window(main_window)
    body_tab = driver.find_element_by_tag_name("body")
    time.sleep(.5)
    if body == body_tab:
        logging.warning("Switch tab failed")
    else:
        body_tab.send_keys(Keys.CONTROL + Keys.TAB)
        driver.switch_to_window(main_window)
        body = driver.find_element_by_tag_name("body")
        body.send_keys(Keys.CONTROL + 'w')
        driver.switch_to_window(main_window)
        body_tab = driver.find_element_by_tag_name("body")
        body_tab.send_keys(Keys.CONTROL + Keys.TAB)
        driver.switch_to_window(main_window)
        body = driver.find_element_by_tag_name("body")
        if body != body_tab:
            logging.warning("Failed to switch tab, switch back to previous tab") 
開發者ID:iclab,項目名稱:centinel,代碼行數:24,代碼來源:foctor_core.py

示例7: test_fuzz

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def test_fuzz(tmp_path, browser):
    # TODO ugh. this still results in 'tab permissions' pages, but perhaps because of closed tabs?
    # dunno if it's worth fixing..
    urls = {
        'https://www.iana.org/domains/reserved': 'IANA',
        'iana.org/domains/reserved': 'IANA2',
    }
    with _test_helper(tmp_path, index_urls(urls), 'https://example.com', browser=browser) as helper:
        driver = helper.driver
        tabs = 30
        for _ in range(tabs):
            driver.find_element_by_tag_name('a').send_keys(Keys.CONTROL + Keys.RETURN)

        sleep(5)
        for _ in range(tabs - 2):
            driver.close()
            sleep(0.1)
            driver.switch_to.window(driver.window_handles[0])

        def cb():
            for _ in range(10):
                send_key('Ctrl+Shift+t')
                sleep(0.1)
        trigger_callback(driver, cb)
        confirm("shouldn't result in 'unexpected error occured'; show only show single notification per page") 
開發者ID:karlicoss,項目名稱:promnesia,代碼行數:27,代碼來源:end2end_test.py

示例8: add_information

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def add_information(driver, link, title_):
        # 點擊模板
        driver.find_element_by_xpath(r'//*[@class="normal-title-wrp"]/div/p').click()
        driver.find_element_by_class_name(r'template-list-small-item').click()
        # driver.find_element_by_xpath(
        #     r'//*[@id="app"]/div[3]/div[2]/div[3]/div[1]/div[1]/div/div[2]/div[1]').click()
        # 輸入轉載來源
        input_o = driver.find_element_by_xpath(
            '//*[@class="upload-v2-container"]/div[2]/div[3]/div[1]/div[4]/div[3]/div/div/input')
        input_o.send_keys(link)
        # 選擇分區
        # driver.find_element_by_xpath(r'//*[@id="item"]/div/div[2]/div[3]/div[2]/div[2]/div[1]/div[2]/div[2]/div[1]/div[3]/div').click()
        # driver.find_element_by_xpath(r'//*[@id="item"]/div/div[2]/div[3]/div[2]/div[2]/div[1]/div[2]/div[2]/div[1]/div[3]/div[2]/div[6]').click()
        # 稿件標題
        title = driver.find_element_by_xpath(
            '//*[@class="upload-v2-container"]/div[2]/div[3]/div[1]/div[8]/div[2]/div/div/input')
        title.send_keys(Keys.CONTROL + 'a')
        title.send_keys(Keys.BACKSPACE)
        title.send_keys(title_)
        # js = "var q=document.getElementsByClassName('content-tag-list')[0].scrollIntoView();"
        # driver.execute_script(js)
        # time.sleep(3)
        # 輸入相關遊戲
        # driver.save_screenshot('bin/err.png')
        # print('截圖')
        # text_1 = driver.find_element_by_xpath(
        #     '//*[@id="item"]/div/div[2]/div[3]/div[2]/div[2]/div[1]/div[5]/div/div/div[1]/div[2]/div/div/input')
        # text_1.send_keys('星際爭霸2')
        # 簡介
        text_2 = driver.find_element_by_xpath(
            '//*[@class="upload-v2-container"]/div[2]/div[3]/div[1]/div[12]/div[2]/div/textarea')
        text_2.send_keys('職業選手直播第一視角錄像。這個自動錄製上傳的小程序開源在Github:'
                         'http://t.cn/RgapTpf(或者在Github搜索ForgQi)交流群:837362626'
                         '\n順便推廣一下自己的網站http://web-form.me/') 
開發者ID:ForgQi,項目名稱:bilibiliupload,代碼行數:36,代碼來源:upload.py

示例9: select_all

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def select_all(self):
        elem = self.__get_element(self.k, self.v)
        if platform.system().lower() == "darwin":
            elem.send_keys(Keys.COMMAND, "a")
        else:
            elem.send_keys(Keys.CONTROL, "a") 
開發者ID:SeldomQA,項目名稱:poium,代碼行數:8,代碼來源:page_objects.py

示例10: cut

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def cut(self):
        elem = self.__get_element(self.k, self.v)
        if platform.system().lower() == "darwin":
            elem.send_keys(Keys.COMMAND, "x")
        else:
            elem.send_keys(Keys.CONTROL, "x") 
開發者ID:SeldomQA,項目名稱:poium,代碼行數:8,代碼來源:page_objects.py

示例11: copy

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def copy(self):
        elem = self.__get_element(self.k, self.v)
        if platform.system().lower() == "darwin":
            elem.send_keys(Keys.COMMAND, "c")
        else:
            elem.send_keys(Keys.CONTROL, "c") 
開發者ID:SeldomQA,項目名稱:poium,代碼行數:8,代碼來源:page_objects.py

示例12: paste

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def paste(self):
        elem = self.__get_element(self.k, self.v)
        if platform.system().lower() == "darwin":
            elem.send_keys(Keys.COMMAND, "v")
        else:
            elem.send_keys(Keys.CONTROL, "v") 
開發者ID:SeldomQA,項目名稱:poium,代碼行數:8,代碼來源:page_objects.py

示例13: send_keys

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
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() 
開發者ID:totvs,項目名稱:tir,代碼行數:36,代碼來源:base.py

示例14: press

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def press(key):
	"""
	:param key: Key or combination of keys to be pressed.

	Presses the given key or key combination. To press a normal letter key such
	as 'a' simply call `press` for it::

		press('a')

	You can also simulate the pressing of upper case characters that way::

		press('A')

	The special keys you can press are those given by Selenium's class
	:py:class:`selenium.webdriver.common.keys.Keys`. Helium makes all those keys
	available through its namespace, so you can just use them without having to
	refer to :py:class:`selenium.webdriver.common.keys.Keys`. For instance, to
	press the Enter key::

		press(ENTER)

	To press multiple keys at the same time, concatenate them with `+`. For
	example, to press Control + a, call::

		press(CONTROL + 'a')
	"""
	_get_api_impl().press_impl(key) 
開發者ID:mherrmann,項目名稱:selenium-python-helium,代碼行數:29,代碼來源:__init__.py

示例15: Refresh

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import CONTROL [as 別名]
def Refresh(self, times=4):
        logger.step_normal("Element [%s]: Browser Refresh" % (self.__name__,))

        for i in range(times):
            action = webdriver.ActionChains(Browser.RunningBrowser)
            action.key_down(Keys.CONTROL).send_keys(Keys.F5).key_up(Keys.CONTROL).perform()
            time.sleep(5) 
開發者ID:hw712,項目名稱:knitter,代碼行數:9,代碼來源:webelement.py


注:本文中的selenium.webdriver.common.keys.Keys.CONTROL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。