本文整理汇总了Python中selenium.webdriver.ActionChains.release方法的典型用法代码示例。如果您正苦于以下问题:Python ActionChains.release方法的具体用法?Python ActionChains.release怎么用?Python ActionChains.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.ActionChains
的用法示例。
在下文中一共展示了ActionChains.release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test_reorder_file_bar
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def _test_reorder_file_bar(self, page):
page.add_file([x for x in FILES if x.name == 'test.jpg'][0])
WebDriverWait(page.driver, 3).until(
ec.visibility_of_element_located(
(
By.CSS_SELECTOR,
'div.grid-canvas div.ui-widget-content.slick-row.odd'
)
)
)
ac = ActionChains(page.driver)
a = page.driver.find_elements_by_css_selector(
'DIV.container DIV.slick-header.ui-state-default DIV.slick-header-columns.ui-sortable SPAN.slick-column-name'
)[3]
b = page.driver.find_elements_by_css_selector(
'DIV.container DIV.slick-header.ui-state-default DIV.slick-header-columns.ui-sortable SPAN.slick-column-name'
)[0]
ac.click_and_hold(a).perform()
a_chain = ActionChains(page.driver)
a_chain.move_to_element(b).perform()
a_chain.release(b).perform()
downloads = page.driver.find_element_by_css_selector(
'div.grid-canvas div.ui-widget-content.slick-row.odd DIV.slick-cell.l0.r0'
).text
self.assertIn('0', downloads)
page.close()
示例2: add_library_item_to_dataflow
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def add_library_item_to_dataflow(self, item_name, instance_name, check=True, offset=None, prefix=None):
""" Add component `item_name`, with name `instance_name`. """
library_item = self.get_library_item(item_name)
target = WebDriverWait(self.browser, TMO).until(
lambda browser: browser.find_element_by_xpath("//*[@id='-dataflow']")
)
offset = offset or (90, 90)
chain = ActionChains(self.browser)
if False:
chain.drag_and_drop(library_item, target)
else:
chain.click_and_hold(library_item)
chain.move_to_element_with_offset(target, offset[0], offset[1])
chain.release(None)
chain.perform()
page = ValuePrompt(self.browser, self.port)
page.set_value(instance_name)
# Check that the prompt is gone so we can distinguish a prompt problem
# from a dataflow update problem.
time.sleep(0.25)
self.browser.implicitly_wait(1) # We don't expect to find anything.
try:
eq(len(self.browser.find_elements(*page("prompt")._locator)), 0)
finally:
self.browser.implicitly_wait(TMO)
retval = None
if check: # Check that it's been added.
retval = WebDriverWait(self.browser, TMO).until(
lambda browser: self.get_dataflow_figure(instance_name, prefix)
)
return retval
示例3: drag
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def drag(self, x_offset, y_offset):
center = self.driver.execute_script(GetScripts.getContainerCenter)
actions = ActionChains(self.driver)
actions.move_to_element_with_offset(self.element, int(center['x']), int(center['y']))
actions.click_and_hold()
actions.move_by_offset(x_offset, y_offset)
actions.release().perform()
示例4: zoom_selection
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def zoom_selection(self):
center = self.driver.execute_script(GetScripts.getContainerCenter)
actions = ActionChains(self.driver)
actions.move_to_element_with_offset(self.element, int(center['x']), int(center['y']))
actions.key_down(Keys.SHIFT)
actions.click_and_hold()
actions.move_by_offset(300, 300)
actions.release()
actions.perform()
示例5: add_library_item_to_dataflow
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def add_library_item_to_dataflow(self, item_name, instance_name,
check=True, offset=None, prefix=None,
args=None):
""" Add component `item_name`, with name `instance_name`. """
offset = offset or (90, 90)
xpath = "//*[@id='-dataflow']"
library_item = self.get_library_item(item_name)
target = WebDriverWait(self.browser, TMO).until(
lambda browser: browser.find_element_by_xpath(xpath))
for retry in range(3):
try:
chain = ActionChains(self.browser)
if False:
chain.drag_and_drop(library_item, target)
else:
chain.click_and_hold(library_item)
chain.move_to_element_with_offset(target,
offset[0], offset[1])
chain.release(None)
chain.perform()
except StaleElementReferenceException:
if retry < 2:
logging.warning('add_library_item_to_dataflow:'
' StaleElementReferenceException')
library_item = self.get_library_item(item_name)
target = WebDriverWait(self.browser, TMO).until(
lambda browser: browser.find_element_by_xpath(xpath))
else:
raise
else:
break
page = ArgsPrompt(self.browser, self.port)
page.set_name(instance_name)
if args is not None:
for i, arg in enumerate(args):
page.set_argument(i, arg)
page.click_ok()
# Check that the prompt is gone so we can distinguish a prompt problem
# from a dataflow update problem.
time.sleep(0.25)
self.browser.implicitly_wait(1) # We don't expect to find anything.
try:
eq(len(self.browser.find_elements(*page('prompt')._locator)), 0)
finally:
self.browser.implicitly_wait(TMO)
retval = None
if check: # Check that it's been added.
retval = WebDriverWait(self.browser, TMO).until(
lambda browser: self.get_dataflow_figure(instance_name,
prefix))
return retval
示例6: action_elements_events
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def action_elements_events(self, element_menu, drag_divs):
action = ActionChains(self.driver)
action.move_to_element(element_menu).click(element_menu)
action.click_and_hold(drag_divs)
action.move_by_offset(35, 35)
action.move_by_offset(15, 20)
action.move_by_offset(55, 15)
action.release()
action.perform()
event_start = self.driver.find_element_by_xpath("//li[@id = 'event-start']/span[2]").text
event_drag = self.driver.find_element_by_xpath("//li[@id='event-drag']/span[2]").text
event_stop = self.driver.find_element_by_xpath("//li[@id = 'event-stop']/span[2]").text
return event_start, event_drag, event_stop
示例7: get_column_cursor
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def get_column_cursor(step, column_name):
with AssertContextManager(step):
cursor_css = "body.ember-application"
action_chains = ActionChains(world.browser)
element = world.browser.execute_script(
"return $('.ember-table-header-container .ember-table-content:contains(" + column_name + ")').parent().parent().children()[1]")
action_chains.drag_and_drop_by_offset(element, 10, 0).release().perform()
cursor = find_elements_by_css(world.browser, cursor_css)
style = cursor[0].get_attribute("style")
assert_true(step, ("auto" in style) or ("resize" in style) or ("pointer" in style))
action_chains.release()
world.browser.refresh()
示例8: connect
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def connect(self, src, dst):
""" Return :class:`ConnectionsPage` for connecting `src` to `dst`. """
chain = ActionChains(self.browser)
chain.click_and_hold(src.output_port)
# Using root rather than input_port since for some reason
# even using a negative Y offset can select the parent's input.
chain.move_to_element(dst.input_port)
chain.release(None)
chain.perform()
parent, dot, srcname = src.pathname.rpartition(".")
parent, dot, dstname = dst.pathname.rpartition(".")
editor_id = "ConnectionsFrame-%s" % (parent)
editor_id = editor_id.replace(".", "-")
return ConnectionsPage(self.browser, self.port, (By.ID, editor_id))
示例9: editor_page
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def editor_page(self, double_click=True, base_type='Component', version=ComponentPage.Version.OLD):
""" Return :class:`ComponentPage` for this component. """
chain = ActionChains(self.browser)
if double_click:
chain.double_click(self.root).perform()
else:
self._context_click('edit_button')
editor_id = 'ObjectFrame_%s' % self.pathname.replace('.', '-')
chain.release(None).perform()
if base_type == 'Assembly':
return AssemblyPage(self.browser, self.port, (By.ID, editor_id))
elif base_type == 'Driver':
return DriverPage(self.browser, self.port, (By.ID, editor_id))
else:
return ComponentPage(self.browser, self.port, (By.ID, editor_id), version=version)
示例10: replace
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def replace(self, name, classname, confirm=True):
""" Replace `name` with an instance of `classname`. """
library_item = self.get_library_item(classname)
target = self.get_dataflow_figure(name).root
chain = ActionChains(self.browser)
chain.click_and_hold(library_item)
chain.move_to_element_with_offset(target, 125, 30)
chain.release(None)
chain.perform()
dialog = ConfirmationPage(self)
if confirm:
dialog.click_ok()
else:
dialog.click_cancel()
示例11: add_object_to_workflow
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def add_object_to_workflow(self, obj_path, target_name):
""" Add `obj_path` object to `target_name` in workflow. """
for retry in range(3):
try:
obj = self.find_object_button(obj_path)
target = self.get_workflow_figure(target_name)
chain = ActionChains(self.browser)
chain.move_to_element(obj)
chain.click_and_hold(obj)
chain.move_to_element(target.root)
chain.move_by_offset(2, 1)
chain.release(None)
chain.perform()
except StaleElementReferenceException:
if retry < 2:
logging.warning("add_object_to_workflow:" " StaleElementReferenceException")
else:
raise
else:
break
示例12: _add_device
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def _add_device(self, port, device_type_id):
browser = self._browser
test_bed = browser.find_element_by_id('test-bed')
device = browser.find_element_by_id(device_type_id)
# drag
action_chains = ActionChains(browser)
action_chains.click_and_hold(device)
action_chains.move_to_element(test_bed).perform()
time.sleep(1)
# drop
drop_hw = browser.find_element_by_class_name('drop-hw')
action_chains = ActionChains(browser)
action_chains.move_to_element(drop_hw)
action_chains.release(drop_hw).perform()
time.sleep(0.5)
selected_hw = browser.find_element_by_class_name('selected-hw')
form_inputs = selected_hw.find_elements_by_tag_name('input')
form_port = form_inputs[0]
form_port.clear()
form_port.send_keys(port)
示例13: setUpClass
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def setUpClass(cls):
super(ReorderComponentTest, cls).setUpClass()
cls.project_url = cls.page.driver.current_url
cls.page.add_component(
title='first',
component_type='hypothesis',
)
cls.page.driver.get(cls.project_url)
cls.page.add_component(
title='second',
component_type='hypothesis',
)
cls.title = cls.page.title
cls.page.driver.get(cls.project_url)
# Second method: by element
ac = ActionChains(cls.page.driver)
a = cls.page.driver.find_element_by_css_selector('#Nodes li:first-child')
b = cls.page.driver.find_element_by_css_selector('#Nodes li:last-child')
ac.click_and_hold(a).perform()
a_chain = ActionChains(cls.page.driver)
a_chain.move_to_element(b).perform()
a_chain.release(b).perform()
示例14: fill_slot_from_library
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def fill_slot_from_library(self, slot, classname, args=None):
""" Fill slot with `classname` instance from library. """
for retry in range(3):
try:
button = self.find_library_button(classname)
chain = ActionChains(self.browser)
chain.move_to_element(button)
chain.click_and_hold(button)
chain.move_to_element(slot.root)
chain.release(None)
chain.perform()
except StaleElementReferenceException:
if retry < 2:
logging.warning('fill_slot_from_library:'
'StaleElementReferenceException')
else:
raise
else:
break
# Handle arguments for the slotted class
page = ArgsPrompt(self.browser, self.port)
argc = page.argument_count()
if argc > 0:
if args is not None:
for i, arg in enumerate(args):
page.set_argument(i, arg)
page.click_ok()
# Check that the prompt is gone so we can distinguish a prompt problem
# from a dataflow update problem.
time.sleep(0.5)
self.browser.implicitly_wait(1) # We don't expect to find anything.
try:
eq(len(self.browser.find_elements(*page('prompt')._locator)), 0)
finally:
self.browser.implicitly_wait(TMO)
示例15: interact_mouse
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import release [as 别名]
def interact_mouse( self ):
'''
Perform some mouse interaction in the current active browser window.
'''
canvas = self.__browser.find_element_by_tag_name( 'canvas' )
canvas_width = canvas.get_attribute('width')
canvas_height = canvas.get_attribute('height')
# move to canvas center to trigger a caption
actions = ActionChains( self.__browser )
actions.click( canvas )
actions.move_to_element_with_offset( canvas, int(canvas_width)/2, int(canvas_height)/2 )
actions.perform()
time.sleep(3)
#
# rotate, pan, zoom
#
actions = ActionChains( self.__browser )
actions.click( canvas )
# rotate
for i in range( 30 ):
actions.click_and_hold( None )
actions.move_to_element_with_offset( canvas, 10, 0 );
actions.release( canvas )
for i in range( 30 ):
actions.click_and_hold( None )
actions.move_to_element_with_offset( canvas, 0, -10 );
actions.release( canvas )
# zoom (not possible right now since the scrollwheel can't be triggered)
# pan
for i in range( 10 ):
actions.key_down( Keys.LEFT_SHIFT )
actions.click_and_hold( None )
actions.move_to_element_with_offset( canvas, 0, 10 );
actions.release( canvas )
actions.perform()