本文整理汇总了Python中selenium.webdriver.common.action_chains.ActionChains.move_to_element_with_offset方法的典型用法代码示例。如果您正苦于以下问题:Python ActionChains.move_to_element_with_offset方法的具体用法?Python ActionChains.move_to_element_with_offset怎么用?Python ActionChains.move_to_element_with_offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.common.action_chains.ActionChains
的用法示例。
在下文中一共展示了ActionChains.move_to_element_with_offset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_to_shimo
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def add_to_shimo(content):
driver = webdriver.Chrome(sys.argv[1]) # Optional argument, if not specified will search path.
#driver.add_cookie({'name' : 'session', 'value' : 'eyJfaWQiOnsiIGIiOiJaalUyTm1aak5EVTRPRE5qWWpVNU9HWmtNalZoWmpBNE4yUTNaR016TkRrPSJ9fQ', 'path' : '/'})
driver.implicitly_wait(0)
driver.get('https://www.shimo.im/')
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
driver.add_cookie(cookie)
driver.get('https://www.shimo.im/doc/g8XvnVEvCtEWnvrB')
try:
search_box = driver.find_element_by_class_name('locate')
mouse = ActionChains(driver)
mouse.move_to_element_with_offset(search_box, 0, 0)
mouse.click()
mouse.send_keys(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ': %s\n' % content)
mouse.perform()
except:
mouse = ActionChains(driver)
mouse.move_by_offset(290, 400)
mouse.click()
mouse.send_keys(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ': %s\n' % content)
mouse.perform()
time.sleep(5)
driver.quit()
示例2: test_vessel_track
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def test_vessel_track(self):
driver = server.driver
try:
driver.set_window_size(1280, 776)
driver.get("http://localhost:8000/index.html?workspace=/ui_tests/data/testtiles/workspace")
time.sleep(5)
self.setAnimation("ClusterAnimation")
self.load_helpers()
point = self.latLng2Point({'lat':22.5, 'lng':0.0})
actions = ActionChains(driver)
actions.move_to_element_with_offset(driver.find_element_by_xpath("//div[@class='animations']/div/div/div[2]"), point['x'], point['y'])
actions.click()
actions.perform()
server.wait_for(lambda: self.animationHasLoaded("VesselTrackAnimation"))
self.assertEqual(self.getHover(point, "ClusterAnimation"), 27200, "Seriesgroup not present at x,y")
except:
name = os.path.realpath("ui_tests.test.test_home.png")
driver.get_screenshot_as_file(name)
raise
示例3: test_patches_hover_still_works_when_a_seleciton_is_preselcted
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def test_patches_hover_still_works_when_a_seleciton_is_preselcted(output_file_url, selenium):
# This tests an edge case interaction when Patches (specifically) is used
# with a tool that requires hit testing e.g. HitTool AND a selection is
# pre-made on the data source driving it.
plot = Plot(
x_range=Range1d(0, 100),
y_range=Range1d(0, 100),
min_border=0
)
source = ColumnDataSource(dict(
xs=[[0, 50, 50, 0], [50, 100, 100, 50]],
ys=[[0, 0, 100, 100], [0, 0, 100, 100]],
color=['pink', 'blue']
))
source.selected = {
'0d': {'glyph': None, 'indices': []},
'1d': {'indices': [1]},
'2d': {}
}
plot.add_glyph(source, Patches(xs='xs', ys='ys', fill_color='color'))
plot.add_tools(HoverTool())
plot.add_layout(LinearAxis(), 'below')
plot.add_layout(LinearAxis(), 'left')
save(plot)
selenium.get(output_file_url)
assert has_no_console_errors(selenium)
# Hover plot and test no error
canvas = selenium.find_element_by_tag_name('canvas')
actions = ActionChains(selenium)
actions.move_to_element_with_offset(canvas, 100, 100)
actions.perform()
# If this assertion fails then there were likely errors on hover
assert has_no_console_errors(selenium)
示例4: test_home
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def test_home(self):
driver = server.driver
try:
driver.set_window_size(1280, 776)
driver.get("http://localhost:8000/index.html?workspace=/ui_tests/data/testtiles/workspace")
time.sleep(5)
self.setAnimation("ClusterAnimation")
self.load_helpers()
point = self.latLng2Point({'lat':22.5, 'lng':0.0})
# Shift click is not supported by webdriver right now...
driver.execute_script("""
KeyModifiers = require("app/Visualization/KeyModifiers");
KeyModifiers.active.Shift = true
""")
actions = ActionChains(driver)
actions.move_to_element_with_offset(driver.find_element_by_xpath("//div[@class='animations']/div/div/div[2]"), point['x'], point['y'])
actions.click()
actions.perform()
server.wait_for(lambda: not server.is_element_present('//div[@id="vessel_identifiers"]//table//td[@class="imo"]'))
self.failUnless(server.is_element_present('//div[@id="vessel_identifiers"]//table//td[text()="27200"]'))
except:
name = os.path.realpath("ui_tests.test.test_home.png")
driver.get_screenshot_as_file(name)
raise
示例5: waitUntilOverlayText
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def waitUntilOverlayText(elm:WebElement, timeOut=7.1, pollFreq=0.5):
global driver
CSS=driver.find_element_by_css_selector
act=ActionChains(driver)
timeElap=0.0
ulog('elm.rect=%s'%elm.rect)
retries = 0
while timeElap < timeOut:
timeBegin = time.time()
try:
if retries==0:
x,y=0,0
else:
x,y = OffsetGenerator(elm.rect)
ulog('move to elm with ofs x=%d, y=%d'%(x,y))
act.move_to_element_with_offset(elm,x,y).perform()
time.sleep(pollFreq)
imageOverlay=CSS('#image_overlay')
if imageOverlay.is_displayed():
return imageOverlay.text
ulog('#image_overlay not displayed, sleep')
except Exception:
ipdb.set_trace()
print(ex); print(type(ex)); traceback.print_exc()
pass
timeElap += (time.time()-timeBegin)
retries += 1
raise TimeoutException('waitUntilOverlayText: timeOut=%f'%timeOut)
示例6: setup
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def setup(self):
# Click on the PhyloTree app launcher and wait for it to load.
try:
button = self.window.find_element_by_link_text("PhyloTree")
except NoSuchElementException:
print >>sys.stderr, "fatal error: could not find the 'PhyloTree' button!"
print >>sys.stderr, "(visit %s to diagnose the problem)" % (url)
self.window.quit()
sys.exit(1)
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"
# Grab the body element to use as a positional reference.
body = self.window.find_element_by_tag_name("body")
# Double-click on a sub-tree to collapse it.
dblclick = ActionChains(self.window)
dblclick.move_to_element_with_offset(body, 475, 333)
dblclick.double_click()
dblclick.perform()
# Give the page some time to update the image.
time.sleep(1)
示例7: goToMatsPerformQuery
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def goToMatsPerformQuery(self):
# Try to find "Return to search page" link.
t = g_bd.d.find_elements_by_link_text('Return')
if len(t) > 0:
self.focusActiveElement()
t[0].click()
time.sleep(g_param['waitMainMenu']/2)
return
# Otherwise, assume we are on the main menu and try to click on
# MATS Perform Query image.
else:
imgs = g_bd.d.find_elements_by_tag_name('img')
i=1
for img in imgs:
if (img.get_attribute('src').find(g_mats['imageLinkPerform'])\
>= 0
):
test = ActionChains(g_bd.d)
test.move_to_element_with_offset(img, 158, 1)
test.click()
self.focusActiveElement()
test.perform()
# Give some time for the click to take effect.
time.sleep(g_param['waitMainMenu'])
return
# If no appropriate image/link has been found, go back to eQ home
# and try again.
self.goToHome()
return self.goToMatsPerformQuery()
示例8: test_lasso_select
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [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'
示例9: click_element_with_offset
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def click_element_with_offset(driver, elem, x, y):
action = ActionChains(driver)
echo_print("Moving to x position", x)
echo_print("Moving to y position", y)
action.move_to_element_with_offset(elem, x, y)
print("OK now see where the mouse is...")
action.click()
action.perform()
示例10: _context_click
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def _context_click(self, name, offset=15):
""" Display context menu. """
chain = ActionChains(self.browser)
chain.move_to_element_with_offset(self.root, offset, 15)
chain.context_click(None)
chain.perform()
time.sleep(0.5)
self(name).click()
示例11: step_impl
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def step_impl(context):
elem = find_css_class_with_wait(context, STEP_NUMBER_CLASS)
actions = ActionChains(context.browser)
# Move the mouse postion to the top left of the element, and
# then offset the position. Should lay outside of the element.
actions.move_to_element_with_offset(elem, -50, -50)
actions.click()
actions.peform()
示例12: i_select_a_highlight_on_the_first_page_of_document
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def i_select_a_highlight_on_the_first_page_of_document(step, docnum):
doc = csss('.edit-document')[int(docnum) - 1]
el = css("canvas.page-image", doc)
chain = ActionChains(world.browser)
chain.move_to_element_with_offset(el, 20, 20)
chain.click_and_hold(None)
chain.move_by_offset(300, 100)
chain.release(None)
chain.perform()
示例13: isc_test
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def isc_test(self):
pla = platform_get()
pla.get('/explore')
pla.wait_new_page("//b[contains(text(), 'Seismic Hazard Data Sets and Models')]",
"/explore", strategy="next", timeout=10)
# <li>
# <a href="/maps/23">
enter_button = pla.xpath_finduniq(
"//li/a[@href='/maps/23' and normalize-space(text()) = 'Global "
"Instrumental Earthquake Catalogue (1900 - 2009)']")
enter_button.click()
pla.wait_new_page(enter_button, '/maps/23')
enter_button = pla.xpath_finduniq(
"//a[@href='/maps/23/view' and "
"normalize-space(text()) = 'View Map']")
enter_button.click()
pla.wait_new_page(enter_button, '/maps/23/view', timeout=15)
# <button id="ext-gen159" class=" x-btn-text gxp-icon-getfeatureinfo"
# type="button">Identify
enter_button = pla.xpath_finduniq(
"//button[@type='button' and normalize-space(text())"
"= 'Identify']", 50)
enter_button.click()
action = ActionChains(pla.driver)
action.move_by_offset(500, 400)
action.click_and_hold()
action.move_by_offset(150, 150)
action.release()
action.perform()
time.sleep(3)
# wait info button will be clicked
pla.xpath_finduniq(
"//button[@type='button' and normalize-space(text())"
"= 'Identify']/../../../../..[contains(concat(' ', @class, ' '),"
" ' x-btn-pressed ')]", 100)
tile = pla.xpath_finduniq(
"//img[contains(@src, 'wms?LAYERS=oqplatform%3Aisc_viewer_measure"
"&FORMAT=image%2Fpng&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1"
"&REQUEST=GetMap&STYLES=&TILED=true&SRS=EPSG%3A900913&BBOX="
"-10018754.17,0,-5009377.085,5009377.085&WIDTH=256&HEIGHT=256')]",
50)
action = ActionChains(pla.driver)
action.move_to_element_with_offset(tile, 107, 115)
action.click()
action.perform()
pla.xpath_finduniq("//div[text() = '1951-03-19T04:23:00']", 50)
示例14: drag_element_at_position
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def drag_element_at_position(self, element, x, y, dx, dy, mod=None):
actions = ActionChains(self._driver)
if mod:
actions.key_down(mod)
actions.move_to_element_with_offset(element, x, y)
actions.click_and_hold()
actions.move_by_offset(dx, dy)
actions.release()
if mod:
actions.key_up(mod)
actions.perform()
示例15: draw_point
# 需要导入模块: from selenium.webdriver.common.action_chains import ActionChains [as 别名]
# 或者: from selenium.webdriver.common.action_chains.ActionChains import move_to_element_with_offset [as 别名]
def draw_point(self):
"""
Click somewhere on the map.
"""
action = ActionChains(self.driver)
map = self.get_element_if_visible(EntryLocators.MAP)
xOffset = map.size['width'] / 2
yOffset = map.size['height'] / 2
action.move_to_element_with_offset(map, xOffset, yOffset)
action.click()
action.perform()