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


Python Keys.LEFT屬性代碼示例

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


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

示例1: play

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import LEFT [as 別名]
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}') 
開發者ID:kudeh,項目名稱:automate-the-boring-stuff-projects,代碼行數:26,代碼來源:2048.py

示例2: send_keys

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import LEFT [as 別名]
def send_keys(self, *args):
        """
        Send keystrokes to the node.

        Examples::

            from selenium.webdriver.common.keys import Keys

            element.send_keys("foo")                  # => value: "foo"
            element.send_keys("tet", Keys.LEFT, "s")  # => value: "test"

        Args:
            *args: Variable length list of keys to send.
        """

        raise NotImplementedError() 
開發者ID:elliterate,項目名稱:capybara.py,代碼行數:18,代碼來源:node.py

示例3: send_keys

# 需要導入模塊: from selenium.webdriver.common.keys import Keys [as 別名]
# 或者: from selenium.webdriver.common.keys.Keys import LEFT [as 別名]
def send_keys(self, *args):
        """
        Send keystrokes to the element.

        Examples::

            from selenium.webdriver.common.keys import Keys

            element.send_keys("foo")                  # => value: "foo"
            element.send_keys("tet", Keys.LEFT, "s")  # => value: "test"

        Args:
            *args: Variable length list of keys to send.
        """

        self.base.send_keys(*args) 
開發者ID:elliterate,項目名稱:capybara.py,代碼行數:18,代碼來源:element.py


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