当前位置: 首页>>代码示例>>Python>>正文


Python action_chains.ActionChains方法代码示例

本文整理汇总了Python中selenium.webdriver.common.action_chains.ActionChains方法的典型用法代码示例。如果您正苦于以下问题:Python action_chains.ActionChains方法的具体用法?Python action_chains.ActionChains怎么用?Python action_chains.ActionChains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium.webdriver.common.action_chains的用法示例。


在下文中一共展示了action_chains.ActionChains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_dbm3002_rotate

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def test_dbm3002_rotate(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div([
        dash_bio.Molecule3dViewer(
            id=_COMPONENT_ID,
            modelData=_model_data,
            styles=_styles_data
        )
    ])

    dash_duo.start_server(app)
    dash_duo.wait_for_element('#' + _COMPONENT_ID)

    mol3d = dash_duo.find_element('#' + _COMPONENT_ID + ' canvas')
    ac = ActionChains(dash_duo.driver)
    ac.drag_and_drop_by_offset(mol3d, 100, 50).perform()

    dash_duo.percy_snapshot('test-mol3d_rotate') 
开发者ID:plotly,项目名称:dash-bio,代码行数:22,代码来源:test_molecule3d.py

示例2: prepare

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def prepare(self):
        self.browser.get("http://music.163.com")
        # self.browser.set_window_size(1920, 1080)
        action = action_chains.ActionChains(self.browser)
        action.send_keys()
        self.browser.switch_to.frame("contentFrame")
        self.browser.execute_script("document.getElementById('index-enter-default').click()")
        self.browser.switch_to.default_content()
        sleep(0.5)
        self.browser.execute_script("document.querySelectorAll('[data-type=\"netease\"]')[0].click()")
        sleep(0.5)
        element = self.browser.find_element_by_css_selector('input[class="js-input u-txt"]')
        element.send_keys(self.config.account)
        sleep(0.5)
        element = self.browser.find_element_by_css_selector('input[type=\"password\"]')
        element.send_keys(self.config.password)
        sleep(0.5)
        self.browser.execute_script("document.querySelectorAll('[data-action=\"login\"]')[6].click()")
        print("login sucess") 
开发者ID:Denon,项目名称:syncPlaylist,代码行数:21,代码来源:QQtoWY.py

示例3: move_to_element

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def move_to_element(self, element):
        """
        [Internal]

        Move focus to element on the screen.

        :param element: Selenium element
        :type element: Selenium object

        Usage:

        >>> #Defining an element:
        >>> element = lambda: self.driver.find_element_by_id("example_id")
        >>> #Calling the method
        >>> self.scroll_to_element(element())
        """
        ActionChains(self.driver).move_to_element(element).perform() 
开发者ID:totvs,项目名称:tir,代码行数:19,代码来源:base.py

示例4: _move_simulation

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def _move_simulation(device, e):
    try:
        action = ActionChains(device)
        action.click_and_hold(e).perform()
        # action.reset_actions()
        offset = 21
        for i in range(210 / offset):
            ActionChains(device).move_by_offset(xoffset=offset, yoffset=0).perform()
            time.sleep((offset - i) / 50)
        action.release().perform()
        action.reset_actions()
    except Exception as e:
        if DEBUG: print e


# 模拟输入 
开发者ID:iQuick,项目名称:TB-Crawler,代码行数:18,代码来源:tb_login.py

示例5: clear_chat

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def clear_chat(self, name):
        self.browser.find_element_by_css_selector("._3FRCZ").send_keys(name+Keys.ENTER)
        menu_xpath = "/html/body/div[1]/div/div/div[4]/div/header/div[3]/div/div[3]/div/span"
        WebDriverWait(self.browser, self.timeout).until(EC.presence_of_element_located(
                (By.XPATH, menu_xpath)))
        menu = self.browser.find_element_by_xpath(menu_xpath)
        menu.click()
        chains = ActionChains(self.browser)
        for i in range(4):
            chains.send_keys(Keys.ARROW_DOWN)
        chains.send_keys(Keys.ENTER)
        chains.perform()
        clear_xpath = '//*[@id="app"]/div/span[2]/div/div/div/div/div/div/div[2]/div[2]'
        WebDriverWait(self.browser, self.timeout).until(EC.presence_of_element_located(
                (By.XPATH, clear_xpath)))
        self.browser.find_element_by_xpath(clear_xpath).click()



    # override the timeout 
开发者ID:VISWESWARAN1998,项目名称:Simple-Yet-Hackable-WhatsApp-api,代码行数:22,代码来源:whatsapp.py

示例6: test_dbsp001_rotate

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def test_dbsp001_rotate(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        dash_bio.Speck(
            id=_COMPONENT_ID,
            data=_data
        )
    )

    dash_duo.start_server(app)
    dash_duo.wait_for_element('#' + _COMPONENT_ID)

    speck = dash_duo.find_element('#' + _COMPONENT_ID + ' canvas')
    ac = ActionChains(dash_duo.driver)
    ac.move_to_element(speck).drag_and_drop_by_offset(
        speck, 150, 200).perform()

    dash_duo.percy_snapshot('test-speck_rotate') 
开发者ID:plotly,项目名称:dash-bio,代码行数:22,代码来源:test_speck.py

示例7: test_dbsp002_click_and_drag

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def test_dbsp002_click_and_drag(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        dash_bio.Speck(
            id=_COMPONENT_ID,
            data=_data
        )
    )

    dash_duo.start_server(app)
    dash_duo.wait_for_element('#' + _COMPONENT_ID)

    speck = dash_duo.find_element('#' + _COMPONENT_ID + ' canvas')
    ac = ActionChains(dash_duo.driver)
    ac.move_to_element(speck).key_down(Keys.SHIFT).drag_and_drop_by_offset(
        speck, -50, 100).key_up(Keys.SHIFT).perform()

    dash_duo.percy_snapshot('test-speck_click_and_drag') 
开发者ID:plotly,项目名称:dash-bio,代码行数:22,代码来源:test_speck.py

示例8: random_youtube

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def random_youtube():
    iterations = randint(1,8)
    count = 0
    while(1):
        item = words[randint(0,len(words))]
        driver.get("https://www.youtube.com/results?search_query="+item)
        element = driver.find_element_by_class_name('yt-uix-tile-link')
        element.click()
        actions = ActionChains(driver)
        actions.send_keys('K')
        actions.perform()
        time.sleep(randint(15,50))
        print("currently on site: " + driver.current_url)
        count = count +1
        if count == iterations:
            break; 
开发者ID:nikshepsvn,项目名称:ScatterFly,代码行数:18,代码来源:make_noise.py

示例9: shake

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def shake(self):
        """ Simulates a shake of the screen

        By shaking, the current topology information will be updated in
        browser's localstorage
        """
        # shake the screen once to update localstorage
        action = ActionChains(self._selenium.driver)
        element = self._selenium.get_webelement('//body')
        action.move_to_element_with_offset(element,0, 0).perform()
        action.move_to_element_with_offset(element,200,200).perform()
        action.click_and_hold(element).perform()
        action.move_by_offset(1,0).perform()
        action.move_by_offset(-1,0).perform()
        action.release().perform()
        self.refresh_canvas()
        BuiltIn().log("Shaked the canvas once") 
开发者ID:bachng2017,项目名称:RENAT,代码行数:19,代码来源:Fic.py

示例10: move_to

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def move_to(self,x=u'0',y=u'0',delay=u'1s',element=u'//canvas',mark_screen=False):
        """ Moves the pointer to screen coodinate of the element

        Default element is `canvas`
        """
        action = ActionChains(self._selenium.driver)
        action.move_to_element_with_offset(self._selenium.get_webelement(element), 0, 0).perform()
        time.sleep(5)
        action.move_to_element_with_offset(self._selenium.get_webelement(element), int(x),int(y)).perform()
        time.sleep(DateTime.convert_time(delay))
        if mark_screen:
            BuiltIn().log("Marked to screen on (%d,%d)" % (x,y))
            img_file = self.capture_screenshot(extra='_move')
            img = cv2.imread(Common.get_result_path() + '/' + img_file)
            cv2.drawMarker(img, (int(x),int(y)), color=(0,255,0), markerType=cv2.MARKER_CROSS, thickness=2)
            cv2.imwrite(Common.get_result_path() + '/' + img_file,img)
        BuiltIn().log('Moved the pointer to (%d,%d)' % (x,y)) 
开发者ID:bachng2017,项目名称:RENAT,代码行数:19,代码来源:Fic.py

示例11: click_on

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def click_on(self,point,element=u'//canvas',mark_screen=False):
        """ Click on a screen coordinate of an element

        Default element is `//cannvas`
        """
        x,y = point
        el = self._selenium.get_webelement(element)
        action = ActionChains(self._selenium.driver)
        action.move_to_element_with_offset(el,0,0).perform()
        action.move_to_element_with_offset(el,x,y).perform()
        if mark_screen:
            BuiltIn().log("Marked to screen on (%d,%d)" % (x,y))
            img_file = self.capture_screenshot(extra='_click')
            img = cv2.imread(Common.get_result_path() + '/' + img_file)
            cv2.drawMarker(img, (int(x),int(y)), color=(0,255,0), markerType=cv2.MARKER_CROSS, thickness=2)
            cv2.imwrite(Common.get_result_path() + '/' + img_file,img)
        action.click().perform()
        self.wait_until_loaded()
        BuiltIn().log("Clicked on element %s at (%d,%d)" % (element,x,y)) 
开发者ID:bachng2017,项目名称:RENAT,代码行数:21,代码来源:Fic.py

示例12: test_edit_item

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def test_edit_item(self):
        self.login()
        time.sleep(1)

        try:
            item = self.client.find_element_by_xpath("//span[text()='test item 1']")
            item_body = 'test item 1'
        except NoSuchElementException:
            item = self.client.find_element_by_xpath("//span[text()='test item 2']")
            item_body = 'test item 2'

        hover_item = ActionChains(self.client).move_to_element(item)
        hover_item.perform()
        edit_button = self.client.find_element_by_class_name('edit-btn')
        edit_button.click()
        edit_item_input = self.client.find_element_by_id('edit-item-input')
        edit_item_input.send_keys(' edited')
        edit_item_input.send_keys(Keys.RETURN)
        time.sleep(1)
        self.assertIn('%s edited' % item_body, self.client.page_source) 
开发者ID:greyli,项目名称:todoism,代码行数:22,代码来源:test_ui.py

示例13: perform_actions_3

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def perform_actions_3(self, actions, delay=0, pause=True):
        action_chains = ActionChains(self.driver)

        for key, flag in self.dir_keys.items():
            if flag:
                if key not in actions:
                    self.keyup(key)
            else:
                if key in actions:
                    self.keydown(key)

        if pause:
            action_chains.send_keys(Keys.F2)
            for _ in range(delay):
                action_chains.send_keys(Keys.F2)

        action_chains.perform() 
开发者ID:elvisyjlin,项目名称:lf2gym,代码行数:19,代码来源:lf2environment.py

示例14: perform_actions_3_2

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def perform_actions_3_2(self, actions, delay=0, pause=True):
        action_chains = ActionChains(self.driver)

        for key, flag in self.dir_keys_2.items():
            if flag:
                if key not in actions:
                    self.keyup_2(key)
            else:
                if key in actions:
                    self.keydown_2(key)

        if pause:
            action_chains.send_keys(Keys.F2)
            for _ in range(delay):
                action_chains.send_keys(Keys.F2)

        action_chains.perform() 
开发者ID:elvisyjlin,项目名称:lf2gym,代码行数:19,代码来源:lf2environment.py

示例15: move_to_element

# 需要导入模块: from selenium.webdriver.common import action_chains [as 别名]
# 或者: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
def move_to_element(self, element, offset=None):
        """
        Moves the mouse to the middle of an element

        :param element: CSS Selector or XPATH used to locate the element
        :type element: str
        :param offset: optional tuple of x/y offsets to offset mouse from center
        :type offset: tuple
        :return:
        """
        elem = self.get_element(element)
        actions = ActionChains(self)
        if offset:
            actions.move_to_element_with_offset(elem, *offset)
        else:
            actions.move_to_element(elem)
        actions.perform() 
开发者ID:spyoungtech,项目名称:behave-webdriver,代码行数:19,代码来源:driver.py


注:本文中的selenium.webdriver.common.action_chains.ActionChains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。