本文整理汇总了Python中selenium.webdriver.common.action_chains.ActionChains.click_and_hold方法的典型用法代码示例。如果您正苦于以下问题:Python ActionChains.click_and_hold方法的具体用法?Python ActionChains.click_and_hold怎么用?Python ActionChains.click_and_hold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.common.action_chains.ActionChains
的用法示例。
在下文中一共展示了ActionChains.click_and_hold方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_credit_score_range
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def set_credit_score_range(self, slider_direction):
actions = ActionChains(self.driver)
# Get the pixel width of the slider control
slider_element = self.driver.find_element_by_xpath(SLIDER)
slider_width = int(slider_element.get_attribute("scrollWidth"))
self.logger.info("width: %s" % slider_width)
element = self.driver.find_element_by_xpath(SLIDER_HANDLE)
# Move the slider 1/4 of the total width to the right
if(slider_direction == "right"):
xOffset = (slider_width/4)
# Move the slider 1/4 of the total width to the left
elif(slider_direction == "left"):
xOffset = (slider_width/-4)
# Move the slider 1/2 of the total width to the left
elif(slider_direction == "lowest"):
xOffset = (slider_width/-2)
# Move the slider 1/2 of the total width to the right
elif(slider_direction == "highest"):
xOffset = (slider_width/2)
actions.click_and_hold(element)
actions.move_by_offset(xOffset, 0)
actions.release()
actions.perform()
示例2: add_multiple_textbox_question_to_survey
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def add_multiple_textbox_question_to_survey(self):
self.find_element(self._multiple_textbox_question_locator).click()
if self.is_multiple_textbox_question_add_displayed:
actions = ActionChains(self.selenium)
actions.click_and_hold(self.find_element(self._multiple_textbox_question_locator))
actions.drag_and_drop(self.find_element(self._multiple_textbox_question_locator),self.find_element(self._question_area_locator))
actions.perform()
示例3: step_impl
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def step_impl(context):
eq2_marker = context.browser.find_element_by_xpath("//body/div[@id='eq']/span[2]/span")
eq6_marker = context.browser.find_element_by_xpath("//body/div[@id='eq']/span[6]/span")
actions = ActionChains(context.browser)
actions.click_and_hold(eq2_marker).move_by_offset(0, 30).release().perform()
actions.click_and_hold(eq6_marker).move_by_offset(0, 60).release().perform()
time.sleep(5)
示例4: put_element_on_grid
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def put_element_on_grid(workspace_page, element_str):
'''find and get the 'assembly', and the div for the grid object'''
browser = workspace_page.browser
for retry in range(3):
try:
assembly = workspace_page.find_library_button(element_str)
chain = ActionChains(browser)
chain.click_and_hold(assembly)
chain.move_by_offset(-100, 0).perform()
except StaleElementReferenceException:
if retry < 2:
logging.warning('put_element_on_grid %s:'
' StaleElementReferenceException', element_str)
else:
raise
else:
break
grid = browser.find_element_by_xpath('//div[@id="-dataflow"]')
check_highlighting(grid, True, "Grid")
release(chain)
# deal with the modal dialog
name = NameInstanceDialog(workspace_page).create_and_dismiss()
# make sure it is on the grid
ensure_names_in_workspace(workspace_page, [name],
"Dragging '" + element_str + "' to grid did not produce a new element on page")
return name
示例5: move
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def move(self, delta_x, delta_y):
""" Move dialog. """
chain = ActionChains(self.browser)
chain.click_and_hold(self('dialog_title').element)
chain.move_by_offset(delta_x, delta_y)
chain.release(None)
chain.perform()
示例6: step_impl
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def step_impl(context):
slider = context.browser.find_element_by_xpath("//body/div[@id='slider-range']")
height = slider.size['height']
bottom_marker = context.browser.find_element_by_xpath("//body/div[@id='slider-range']/span[1]")
actions = ActionChains(context.browser)
actions.click_and_hold(bottom_marker).move_by_offset(0,-height).release().perform()
time.sleep(1)
示例7: setup
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def setup(self):
try:
button = self.window.find_element_by_link_text("Cone")
except NoSuchElementException:
print >>sys.stderr, "fatal error: could not find the 'Cone' button!"
print >>sys.stderr, "(visit %s to diagnose the problem)" % (url)
raise vtkwebtest.WebTest.Abort()
button.click()
# Wait for the vtkweb process to start (but time out after 10 seconds).
if not vtkwebtest.wait_with_timeout(delay=0.5, limit=10, criterion=found_viewport(self.window)):
print >>sys.stderr, "fatal error: timed out while waiting for vtkweb process to start"
raise vtkwebtest.WebTest.Abort()
# Grab the viewport element so we know where to put the mouse.
div = self.window.find_element_by_id("viewport")
# Click-and-drag on the cone to change its position a bit.
drag = ActionChains(self.window)
drag.move_to_element(div)
drag.click_and_hold()
drag.move_by_offset(-300, 100)
drag.release()
drag.perform()
# Give the page some time to update the image.
time.sleep(1)
示例8: _test_drop_on_component_editor_grid
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def _test_drop_on_component_editor_grid(browser):
project_dict, workspace_page = startup(browser)
workspace_page.add_library_item_to_dataflow('openmdao.main.assembly.Assembly', 'top')
top = workspace_page.get_dataflow_figure('top', '')
workspace_page.set_library_filter('Assembly') # put Assembly at top of lib
assembly = workspace_page.find_library_button('Assembly')
editor = top.editor_page(double_click=False, base_type='Assembly')
editor.show_dataflow()
editor_top = workspace_page.get_dataflow_fig_in_globals('top')
# sort through these to find the correct 'top'
chain = ActionChains(browser)
chain.click_and_hold(assembly)
chain.move_to_element(editor_top('header').find_element_by_xpath("..")).perform()
chain.move_by_offset(200, 1).perform()
chain.release(None).perform()
# don't bother checking to see if it appeared,
# the UI box will appear and screw the test if it did
closeout(project_dict, workspace_page)
示例9: test_lasso_select
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def test_lasso_select(output_file_url, selenium):
plot = generate_plot()
#limit to one callback on click release
plot.add_tools(LassoSelectTool(select_every_mousemove=False))
# Save the plot and start the test
save(plot)
selenium.get(output_file_url)
assert has_no_console_errors(selenium)
# Drag a lasso selection area around middle point
canvas = selenium.find_element_by_tag_name('canvas')
actions = ActionChains(selenium)
actions.move_to_element_with_offset(canvas, PLOT_DIM * 0.25, PLOT_DIM * 0.25)
actions.click_and_hold()
actions.move_by_offset(0, PLOT_DIM * 0.5)
actions.move_by_offset(PLOT_DIM * 0.5, 0)
actions.move_by_offset(0, PLOT_DIM * -0.5)
actions.release()
actions.perform()
# Get the alert from box select and assert that the middle item is selected
alert = selenium.switch_to_alert()
assert alert.text == 'middle'
示例10: step_impl
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def step_impl(context):
slider = context.browser.find_element_by_xpath("//body/div[@id='slider']")
width = slider.size['width']
marker = context.browser.find_element_by_xpath("//body/div[@id='slider']/span")
actions = ActionChains(context.browser)
actions.click_and_hold(marker).move_by_offset(-width, 0).release().perform()
time.sleep(1)
actions.click_and_hold(marker).move_by_offset(width*0.3, 0).release().perform()
示例11: add_single_textbox_question_to_survey
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def add_single_textbox_question_to_survey(self):
#self.scroll_element_into_view(self._single_textbox_question_locator)
self.find_element(self._single_textbox_question_locator).click()
if self.is_single_textbox_question_add_displayed:
actions = ActionChains(self.selenium)
actions.click_and_hold(self.find_element(self._single_textbox_question_locator))
actions.drag_and_drop(self.find_element(self._single_textbox_question_locator),self.find_element(self._question_area_locator))
actions.perform()
示例12: step_impl
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def step_impl(context):
scroller = context.browser.find_element_by_xpath("//body/div[contains(@class,'scroll-pane')]")
width = scroller.size['width']
scrollbar = context.browser.find_element_by_xpath("//div[@class='ui-handle-helper-parent']")
time.sleep(1)
actions = ActionChains(context.browser)
actions.click_and_hold(scrollbar).move_by_offset(width/20*17, 0).release().perform()
time.sleep(1)
示例13: step_impl
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def step_impl(context):
blue = context.browser.find_element_by_xpath("//body/div[@id='blue']/span")
width = 300
actions = ActionChains(context.browser)
actions.click_and_hold(blue).move_by_offset(-300, 0).release().perform()
time.sleep(.5)
actions.click_and_hold(blue).move_by_offset(41/255 * width, 0).release().perform()
time.sleep(5)
示例14: mouse_down_on_image
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def mouse_down_on_image(self, locator):
"""Simulates a mouse down event on an image.
Key attributes for images are `id`, `src` and `alt`. See
`introduction` for details about locating elements.
"""
element = self.find_element(locator, tag='image')
action = ActionChains(self.browser)
action.click_and_hold(element).perform()
示例15: mouse_down_on_link
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import click_and_hold [as 别名]
def mouse_down_on_link(self, locator):
"""Simulates a mouse down event on a link.
Key attributes for links are `id`, `name`, `href` and link text. See
`introduction` for details about locating elements.
"""
element = self.find_element(locator, tag='link')
action = ActionChains(self.browser)
action.click_and_hold(element).perform()