当前位置: 首页>>代码示例>>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;未经允许,请勿转载。