本文整理汇总了Python中selenium.webdriver.ActionChains类的典型用法代码示例。如果您正苦于以下问题:Python ActionChains类的具体用法?Python ActionChains怎么用?Python ActionChains使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActionChains类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_can_move_block_from_one_container_to_another
def test_can_move_block_from_one_container_to_another(live_server, browser,
admin_user):
page = factories.FancyPageFactory(node__name='Home')
main_container = page.containers.all()[0]
layout = factories.TwoColumnLayoutBlockFactory(container=main_container)
browser.visit(live_server.url + page.get_absolute_url())
right = layout.containers.get(name='right-container')
left = layout.containers.get(name='left-container')
moving_block = factories.TextBlockFactory(container=right)
factories.TextBlockFactory(container=right)
factories.TextBlockFactory(container=left)
browser.visit(live_server.url + page.get_absolute_url())
browser.find_by_css('#editor-handle').first.click()
source = browser.find_by_css(
'#block-{} div.move'.format(moving_block.uuid)).first
chain = ActionChains(browser.driver)
chain.drag_and_drop_by_offset(source._element, -600, 200).perform()
time.sleep(5)
assert right.blocks.count() == left.blocks.count() == 1
assert main_container.blocks.count() == 2
main_block_ids = [b.uuid for b in main_container.blocks.all()]
assert main_block_ids == [layout.uuid, moving_block.uuid]
开发者ID:aibon,项目名称:django-fancypages,代码行数:31,代码来源:test_moving_blocks.py
示例2: add_object_to_workflow_figure
def add_object_to_workflow_figure(self, obj_path, target_name, target_page=None):
""" Add `obj_path` object to `target_name` in workflow diagram. """
if target_page is None:
target_page = self
for retry in range(3):
try:
items = obj_path.split('.')
parent = items[:-1]
comp = items[-1]
obj = self.get_dataflow_figure(comp, parent)
workflow = target_page.get_workflow_figure(target_name)
flow_fig = workflow.flow
chain = ActionChains(self.browser)
chain.drag_and_drop(obj.root, flow_fig)
chain.perform()
except StaleElementReferenceException:
if retry < 2:
logging.warning('add_object_to_workflow_figure:'
' StaleElementReferenceException')
else:
raise
else:
break
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:27,代码来源:workspace.py
示例3: test_LoginRead
def test_LoginRead(self):#第二种方法,见main里的注释
cdr=self.cdr
Url=self.Url
cdr.get(Url)
#cdr.implicitly_wait(5)
WebDriverWait(cdr,10).until(lambda cdr:cdr.find_element_by_xpath(".//*[@id='J_connect']/div[2]/div/div/span/a[2]"))
fopen=open(r".\something\username.txt","r")
for us in fopen:#------这里是从文件里进行读取
time.sleep(2)
cdr.find_element_by_xpath(".//*[@id='J_connect']/div[2]/div/div/span/a[2]").click()#点击登录
WebDriverWait(cdr,10).until(lambda cdr:cdr.find_element_by_id("email_login"))
cdr.find_element_by_id("email_login").click()#点击使用邮箱登陆
print cdr.find_element_by_id("email_login").get_attribute("title")
#输入用户名密码
time.sleep(2)
cdr.find_element_by_id("login_email").send_keys(us)
print "登录用户名为:"+us
cdr.find_element_by_id("login_password").send_keys("123456")
cdr.find_element_by_id("remember_me").click()#去掉记住登陆 checkbox
#点击登录按钮
cdr.find_element_by_id("login").click()
time.sleep(5)
#鼠标移动到 头像旁边的下落箭头上
action=ActionChains(cdr)
action.move_to_element(cdr.find_element_by_xpath("//div[@class='tr']/div/span[2]")).perform()
#下拉菜单点击 退出帐号
cdr.find_element_by_xpath("//div[@class='tr']/div/span[3]/ul/li[4]/a").click()
fopen.close()
开发者ID:xlmysjz,项目名称:Python,代码行数:32,代码来源:LoginTopka.py
示例4: put_element_on_grid
def put_element_on_grid(self, type_str):
'''find 'type_str' in the Library, drag and drop it onto the grid'''
browser = self.browser
grid = browser.find_element_by_xpath('//div[@id="-dataflow"]')
for retry in range(3):
try:
objtype = self.find_library_button(type_str)
chain = ActionChains(browser)
chain.click_and_hold(objtype)
chain.move_to_element_with_offset(grid, 10, 10).perform()
except StaleElementReferenceException:
if retry < 2:
logging.warning('put_element_on_grid %s:'
' StaleElementReferenceException', type_str)
else:
raise
else:
break
self.check_highlighting(grid, True, "Grid")
self.release(chain)
# deal with the modal dialog
name = NameInstanceDialog(self).create_and_dismiss()
# make sure it is on the grid
self.ensure_names_in_workspace([name],
"Dragging '" + type_str +
"' to grid did not produce a new element on page")
return name
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:33,代码来源:workspace.py
示例5: add_object_to_workflow
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:
items = obj_path.split('.')
parent = items[:-1]
comp = items[-1]
obj = self.get_dataflow_figure(comp, parent)
target = self.find_object_button(target_name)
chain = ActionChains(self.browser)
chain.drag_and_drop(obj.root, target)
chain.perform()
#obj = self.find_object_button(obj_path)
#workflow = self.get_workflow_figure(target_name)
#flow_fig = workflow.flow
#chain = ActionChains(self.browser)
#chain.move_to_element(obj)
#chain.click_and_hold(obj)
#chain.move_to_element(flow_fig)
#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
开发者ID:Daiyu506,项目名称:OpenMDAO-Framework,代码行数:33,代码来源:workspace.py
示例6: drag_scroll_by_css
def drag_scroll_by_css(browser, offset_x, offset_y):
scroll, height = wait_element_present(browser)
action = ActionChains(browser)
try:
action.click_and_hold(scroll[0]).move_by_offset(int(offset_x), int(offset_y) + 1).release().perform()
except AssertionError:
drag_scroll_by_css(browser, offset_x, offset_y)
开发者ID:hedgeserv,项目名称:ember-table-addon-demo-app,代码行数:7,代码来源:basic_opr_module.py
示例7: go_to_my_room
def go_to_my_room(self):
self.wait_element_click(self.AVATAR)
room = self.driver.find_element_by_xpath(self.AVATAR)
mv = ActionChains(self.driver).move_to_element(room)
mv.perform()
room.click()
return MyRoomPage(self.driver)
开发者ID:Vasiliy-tech,项目名称:home-assignment-4,代码行数:7,代码来源:main_page.py
示例8: test_en_classify_products_function_drag_and_drop
def test_en_classify_products_function_drag_and_drop(self):
driver = self.driver
gb_login(self)
driver.get(self.base_url + "/ev/classifyproducts")
driver.find_element_by_xpath("//li[@id='categoryCol_category514']/div/span").click()
# Verify process missing.
try:
self.assertTrue(
self.is_element_present(
By.CSS_SELECTOR, "#categoryCol_subcategory515 > div.itemContent.subCategoryBg > div.handle"
)
)
except AssertionError as e:
self.verificationErrors.append(str(e))
try:
self.assertTrue(
self.is_element_present(
By.CSS_SELECTOR, "#categoryCol_category517 > div.categoryBg.itemContent > div.blockText"
)
)
except AssertionError as e:
self.verificationErrors.append(str(e))
element = driver.find_element_by_css_selector(
"#categoryCol_subcategory515 > div.itemContent.subCategoryBg > div.handle"
)
target = driver.find_element_by_css_selector(
"#categoryCol_category517 > div.categoryBg.itemContent > div.blockText"
)
action_chains = ActionChains(driver)
action_chains.drag_and_drop(element, target)
开发者ID:yueran,项目名称:EV-SeleniumTest,代码行数:30,代码来源:en_ClassifyProducts_Function_DragAndDrop.py
示例9: test_search_in_python_org
def test_search_in_python_org(self):
driver = self.driver
driver.implicitly_wait(10)
actions = ActionChains(driver)
driver.get("http://localhost:8080")
ens = driver.find_element_by_class_name('ens')
ens.click()
menu = driver.find_element_by_id('VIZ_popup_menu')
buttons = driver.find_elements_by_css_selector('#VIZ_popup_menu button')
for button in buttons:
text = button.get_attribute('textContent')
if text == 'Value':
button.click()
break
graph = driver.find_element_by_css_selector(".graph")
actions.drag_and_drop_by_offset(graph, xoffset=-15, yoffset=15).perform()
play_button = driver.find_element_by_id('VIZ.SimControl.play_button')
play_button.click()
time.sleep(3)
line = driver.find_element_by_css_selector("path.line:nth-child(1)")
data = line.rect
print data
test_val = data['height'] + data['width']
assert test_val != 0
block = driver.find_element_by_id("BlockTestCompletion")
开发者ID:Seanny123,项目名称:gui_test,代码行数:33,代码来源:line_visible_test.py
示例10: when_i_drag_pill_from_time1_to_time2
def when_i_drag_pill_from_time1_to_time2(step, pill, time1, time2):
# get the data id for this pill
pill = find_pill(pill)
assert pill is not None, "No pill named %s found." % pill
draggable = pill.find_element_by_css_selector(
"div.pill-image span.draggable")
assert draggable is not None, (
"This pill is not constructed properly: %s" % pill)
data_id = draggable.get_attribute("data-id")
bucket = get_bucket(time1)
assert bucket is not None, (
"Source time slot must be specified as day or evening. "
"No time slot called %s found" % time)
dest = get_bucket(time2)
assert dest is not None, (
"Destination time slot must be specified as day or evening. "
"No time slot called %s found" % time)
a = bucket.find_elements_by_css_selector('span.trashable')
assert len(a) > 0, (
"Expected at least 1 pill in bucket %s, instead it "
"contains %s pills" % (bucket, len(a)))
action = False
for dropped in a:
if (data_id == dropped.get_attribute("data-id")):
# found it, now, drag it to the second bucket
action_chains = ActionChains(world.browser)
action_chains.drag_and_drop(dropped, dest).perform()
action = True
assert action, (
"No dropped pills named %s found in %s slot" % (pill, time1))
开发者ID:ccnmtl,项目名称:smart_sa,代码行数:31,代码来源:pill-steps.py
示例11: bing_search
def bing_search(start, end):
# Generator: yield the url for beautifulsoup
global number_of_urls_to_search
local_count = number_of_urls_to_search
driver = webdriver.PhantomJS(executable_path='D:/phantomjs-2.1.1-windows/bin/phantomJS')
driver.get("http://global.bing.com/?FORM=HPCNEN&setmkt=en-us&setlang=en-us")
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "sb_feedback")))
except:
raise
finally:
searchField = driver.find_element(By.ID, "sb_form_q")
submitButton = driver.find_element(By.ID, "sb_form_go")
actions = ActionChains(driver).click(searchField).send_keys(start + " " + end + " " + "text").click(submitButton)
actions.perform()
try:
element = WebDriverWait(driver, 20).until(
EC.presence_of_element_located((By.CLASS_NAME, "b_footerRight")))
except:
raise
finally:
bsObj = BeautifulSoup(driver.page_source, 'html.parser')
results = bsObj.findAll('li', {'class': 'b_algo'})
for result in results:
if not local_count:
driver.close()
return
print(result.a['href'])
yield result.a['href']
local_count -= 1
driver.close()
开发者ID:Weiming-Hu,项目名称:text-based-six-degree,代码行数:32,代码来源:find_path_server.py
示例12: setup_google_driver
def setup_google_driver():
driver = webdriver.Firefox()
driver.get('http://google.com')
time.sleep(0.2)
#driver.maximize_window()
time.sleep(3)
driver.get('http://google.com/preferences')
time.sleep(2)
radios = driver.find_elements_by_css_selector('div.jfk-radiobutton')
radio = radios[-1]
radio.click()
time.sleep(1.2)
slider = driver.find_element_by_css_selector('div.goog-slider-scale')
dims = slider.size
width = dims['width']
move = ActionChains(driver)
slider2 = driver.find_element_by_css_selector('div.goog-slider-scale')
for i in range(4):
time.sleep(0.1)
move.click_and_hold(slider2).move_by_offset(width//9,0).release().perform()
move.click_and_hold(slider2).move_by_offset(width//2,0).release().perform()
time.sleep(1.5)
driver.switch_to_default_content()
#save settings
elems = driver.find_elements_by_id('form-buttons')
elems[0].find_elements_by_tag_name('div')[0].click()
alert = driver.switch_to_alert()
time.sleep(0.91)
alert.accept()
time.sleep(1)
return driver
开发者ID:danjump,项目名称:recipe_optimizer,代码行数:31,代码来源:google_search.py
示例13: test_search_in_python_org
def test_search_in_python_org(self):
driver = self.driver
driver.implicitly_wait(5)
actions = ActionChains(driver)
driver.get("http://localhost:8080")
value = driver.find_element_by_css_selector('.graph')
actions.click(on_element=value)
actions.perform()
menu = driver.find_element_by_id('VIZ_popup_menu')
buttons = driver.find_elements_by_css_selector('#VIZ_popup_menu button')
for button in buttons:
text = button.get_attribute('textContent')
if text == 'Set range':
button.click()
WebDriverWait(driver, 5).until(EC.alert_is_present())
alert = driver.switch_to_alert()
alert.send_keys("-0.1,0.1")
alert.accept()
break
tick = driver.find_element_by_css_selector('g.axis:nth-child(4) > g:nth-child(1)')
text = tick.get_attribute('textContent')
assert text == "-0.1"
开发者ID:Seanny123,项目名称:gui_test,代码行数:25,代码来源:set_range_test.py
示例14: drag_element_by_offset_class_name
def drag_element_by_offset_class_name(browser, className, index, rightOrLeft, offset):
elements = find_elements_by_class(browser, className)
action_chains = ActionChains(browser)
if str(rightOrLeft) == "left":
action_chains.drag_and_drop_by_offset(elements[int(index) - 1], -int(offset), 0).perform()
else:
action_chains.drag_and_drop_by_offset(elements[int(index) - 1], int(offset), 0).perform()
开发者ID:my-js-tools,项目名称:ember-table-addon-demo-app,代码行数:7,代码来源:steps.py
示例15: _select_case
def _select_case(self, suite, case):
"""Select the test case.
"""
# select the case
elem = Select(self._browser.find_element_by_id('select-dut'))
elem.select_by_value(str(suite))
time.sleep(1)
checkbox = None
elems = self._browser.find_elements_by_css_selector('.tree-node .tree-title')
for elem in elems:
action_chains = ActionChains(self._browser)
action_chains.move_to_element(elem)
action_chains.perform()
logger.debug(elem.text)
if elem.text.startswith(case):
parent = elem.find_element_by_xpath('..')
checkbox = parent.find_element_by_class_name('tree-checkbox')
break
if not checkbox:
time.sleep(5)
raise Exception('Failed to find the case')
checkbox.click()
time.sleep(1)
elem = self._browser.find_element_by_id('runTest')
elem.click()
if not self.wait_until(lambda: self._browser.find_element_by_id('stopTest') and True, 10):
raise Exception('Failed to start test case')
开发者ID:MatthewCoppola4,项目名称:openthread,代码行数:31,代码来源:harness_case.py
示例16: test_history
def test_history(self):
'''
1. Get the outer div id of the activecode component
2. Find the run button using its class name
3. Run the example
4. Check the output from the ac_output element
:return:
'''
self.driver.get(self.host + "/index.html")
t1 = self.driver.find_element_by_id("test1")
self.assertIsNotNone(t1)
rb = t1.find_element_by_class_name("run-button")
self.assertIsNotNone(rb)
rb.click()
ta = t1.find_element_by_class_name("cm-s-default")
self.assertIsNotNone(ta)
self.driver.execute_script("""edList['test1'].editor.setValue("print('GoodBye')")""")
WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "run-button")))
rb.click()
output = t1.find_element_by_class_name("ac_output")
self.assertEqual(output.text.strip(),"GoodBye")
move = ActionChains(self.driver)
slider = t1.find_element_by_class_name("ui-slider")
width = slider.size['width']
slider = t1.find_element_by_class_name("ui-slider-handle")
move.click_and_hold(slider).move_by_offset(-width,0).release().perform()
rb.click()
output = t1.find_element_by_class_name("ac_output")
self.assertEqual(output.text.strip(), "Hello World")
开发者ID:aerenchyma,项目名称:RunestoneComponents,代码行数:29,代码来源:test_activecode.py
示例17: test_event_detail_page_tab2
def test_event_detail_page_tab2(self):
"""
Test that the adverse event page has the tab and accordion items we expect
:return:
"""
# I want to see the top drugs that have a given adverse event
# I want to see the sex and age breakdown of the top drugs that have a given adverse event
item = CATEGORIES[1]
self.driver.get('%s/search/events/?q=%s' % (self.live_server_url, item['search'], ))
self.assertIn(item['detail'], self.driver.find_element_by_tag_name('h1').text)
self.assertIn(item['search'], self.driver.find_element_by_tag_name('h1').text)
# we should have two tabs
self.assertEqual(2, len(self.driver.find_element_by_class_name('ui-tabs-nav').find_elements_by_tag_name('li')))
# I want to see drugs with this adverse event, so i click that tab
self.driver.find_element_by_id('ui-id-2').click()
# I see a chart with drug information and I click and mouse over the first bar to get the count
chart_bar = self.driver.find_element_by_xpath(
"//div[@id='adverseChart']//*[local-name()='svg']//*[local-name()='g'][@class='highcharts-series highcharts-tracker']/*[local-name()='rect']")
chart_bar.click()
hover = ActionChains(self.driver).move_to_element(chart_bar)
hover.perform()
tool_tip = WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//div[@class='highcharts-tooltip']/span/div/span")))
self.assertEqual('Count', tool_tip.text)
开发者ID:artemis-consulting,项目名称:prototype-pool3,代码行数:29,代码来源:test_behavior.py
示例18: _select_case
def _select_case(self, role, case):
"""Select the test case.
"""
# select the case
elem = Select(self._browser.find_element_by_id('select-dut'))
elem.select_by_value(str(role))
time.sleep(1)
checkbox = None
wait_until(lambda: self._browser.find_elements_by_css_selector('.tree-node .tree-title') and True)
elems = self._browser.find_elements_by_css_selector('.tree-node .tree-title')
finder = re.compile(r'.*\b' + case + r'\b')
finder_dotted = re.compile(r'.*\b' + case.replace(' ', r'\.') + r'\b')
for elem in elems:
action_chains = ActionChains(self._browser)
action_chains.move_to_element(elem)
action_chains.perform()
logger.debug(elem.text)
if finder.match(elem.text) or finder_dotted.match(elem.text):
parent = elem.find_element_by_xpath('..')
checkbox = parent.find_element_by_class_name('tree-checkbox')
break
if not checkbox:
time.sleep(5)
raise Exception('Failed to find the case')
self._browser.execute_script("$('.overview').css('left', '0')")
checkbox.click()
time.sleep(1)
elem = self._browser.find_element_by_id('runTest')
elem.click()
if not wait_until(lambda: self._browser.find_element_by_id('stopTest') and True, 10):
raise Exception('Failed to start test case')
开发者ID:pvanhorn,项目名称:openthread,代码行数:35,代码来源:harness_case.py
示例19: setInputText
def setInputText(self, name, value):
textArea = self.workflow_input.find_element_by_xpath(
'./*[@data-input-name="{0}"]//textarea'.format(name)
)
action_chains = ActionChains(self.portal.browser)
action_chains.move_to_element(textArea).click().send_keys(
Keys.BACK_SPACE*len(textArea.text)+str(value)
).perform()
开发者ID:BioVeL,项目名称:portal-tests,代码行数:8,代码来源:PortalBrowser.py
示例20: test_drag
def test_drag(self):
global driver
element = driver.find_element_by_id("draggable")
target = driver.find_element_by_id("div2")
actions = ActionChains(driver)
actions.drag_and_drop(element, target).perform()
self.assertEqual("You are definitely not a bot!", driver.find_element_by_id("message").text)
开发者ID:xxg1413,项目名称:MachineLearning,代码行数:8,代码来源:combined-test.py
注:本文中的selenium.webdriver.ActionChains类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论