本文整理汇总了Python中selenium.webdriver.ActionChains.click方法的典型用法代码示例。如果您正苦于以下问题:Python ActionChains.click方法的具体用法?Python ActionChains.click怎么用?Python ActionChains.click使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.ActionChains
的用法示例。
在下文中一共展示了ActionChains.click方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_search_in_python_org
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
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"
示例2: test_tamplate
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def test_tamplate(self):
''' Test a situation when unlogged user tries to download a file '''
item_to_download = WebDriverWait(self.driver, 10).until(
ec.visibility_of_element_located((By.CLASS_NAME, 'ent-title')))
action = ActionChains(self.driver)
action.move_to_element(item_to_download)
action.click(item_to_download)
action.perform()
time.sleep(5)
download_button = self.driver.find_elements_by_class_name('download')
download_button_1 = download_button[0]
download_button_2 = download_button[1]
action = ActionChains(self.driver)
action.move_to_element(download_button_2)
action.click(download_button_2)
action.perform()
time.sleep(8)
#Alert message
try:
alert_message = WebDriverWait(self.driver, 10).until(
ec.visibility_of_element_located((By.CLASS_NAME, 'xw-hdr-text')))
finally:
print ('oops')
示例3: visit
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def visit( self, url ):
'''
'''
if self.__jscoverage_loaded:
self.__browser.switch_to_window( self.__browser.window_handles[0] )
else:
# load JSCoverage
self.__browser.get( "http://localhost:8080/jscoverage.html" )
self.__jscoverage_loaded = True
# clear the jscoverage location field
locationfield = self.__browser.find_element_by_id( 'location' )
locationfield.clear()
# fill in url
actions = ActionChains( self.__browser )
actions.click( locationfield )
actions.send_keys( url )
actions.send_keys( Keys.TAB )
actions.send_keys( Keys.TAB )
actions.send_keys( Keys.RETURN )
actions.perform()
# switch to the new window
self.__browser.switch_to_window( self.__browser.window_handles[-1] )
示例4: click_menu_option_by_visible_text
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def click_menu_option_by_visible_text(self, menu_locator, list_of_menu_options):
"""
Performs support move_to_element action on every link <support...> contained in
menu_locator if its visible text matches any of the names defined in
list_of_menu_options and clicks on the last matching link.
:param menu_locator:
:param list_of_menu_options:
"""
menu_options = self.driver.find_elements(*menu_locator)
actions = ActionChains(self.driver)
menu_index = 0
expected_option = None
for option in menu_options:
if menu_index >= len(list_of_menu_options):
break
if expected_option is None:
expected_option = list_of_menu_options[menu_index].strip()
if option.get_attribute('title') == expected_option or option.get_attribute(
'text') == expected_option or option.text == expected_option:
actions.move_to_element(option)
menu_index += 1
expected_option = None
actions.click()
actions.perform()
示例5: click_img
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def click_img(self, answer, height, identify_img_xpath1=None,
identify_button_xpath=None):
"""
根据打码返回的坐标进行点击操作
仅适用与点击型验证码
:param answer: 打码返回结果
:param height: 答案高度
:param identify_img_xpath1: 题目xpath
:param identify_button_xpath: 验证按钮
:return:
"""
actions = ActionChains(self.driver)
img = self.driver.find_element_by_xpath(identify_img_xpath1)
points = answer.split('|')
for point in points:
x, y = eval(point)
actions.move_to_element_with_offset(
img, x, y - int((height / self.device_pixel_ratio)))
actions.click()
actions.perform()
time.sleep(2)
if not identify_button_xpath:
return
self.driver.find_element_by_xpath(identify_button_xpath).click()
示例6: test_basic_functionality
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def test_basic_functionality(driver, test_file):
try:
#Test page response by clicking the reset button and applying new code to ace-editor
tt.reset_page(driver)
tt.update_editor(driver, test_file)
ens_elements = driver.find_elements_by_xpath('//*[@class="ens"]')
assert (len(ens_elements) > 0)
side_script = '''var right = document.getElementById("rightpane"); \
right.style.width = "200px"
'''
driver.execute_script(side_script)
#Creates graph objects by right clicking on nodes and selecting from menu
actions = ActionChains(driver)
elements = ['node', 'ens']
for elem in elements:
node = driver.find_element_by_xpath('//*[@class="'+elem+'"]')
actions = ActionChains(driver)
actions.move_to_element(node)
actions.context_click()
actions.perform()
time.sleep(1)
actions = ActionChains(driver)
menu = driver.find_element_by_xpath('//*[@class="dropdown-menu"]/li[1]')
actions.move_to_element(menu)
actions.click()
actions.perform()
time.sleep(0.5)
graph_elements = driver.find_elements_by_xpath('//*[@class="graph"]')
assert len(graph_elements) > 0
tt.start_stop_sim(driver)
time.sleep(1.5)
tt.start_stop_sim(driver)
time.sleep(0.5)
ticker = driver.find_element_by_xpath('//*[@id="ticks_tr"]/td')
sim_time = ticker.get_attribute('textContent')
assert (float(sim_time) > 0)
except Exception as e:
#Travis Only: On fail takes screenshot and uploads it to imgur
if('TRAVIS' in os.environ):
tt.imgur_screenshot(driver)
_, _, tb = sys.exc_info()
traceback.print_tb(tb) # Fixed format
tb_info = traceback.extract_tb(tb)
filename, line, func, text = tb_info[-1]
print('An error occurred on line {} in statement {}'.format(line, text))
print(str(e))
exit(1)
示例7: stop
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def stop():
main_window = driver.current_window_handle
driver.switch_to_window(main_window)
actions = ActionChains(driver)
stop = driver.find_element_by_xpath("//span[contains(text(), 'stop')]")
actions.move_to_element(stop)
actions.click(stop)
actions.perform()
示例8: get_properties
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def get_properties(self, name, prefix=None):
self.show_properties()
self.show_dataflow()
obj = self.get_dataflow_figure(name, prefix=prefix)
chain = ActionChains(self.browser)
chain.click(obj.root)
chain.perform()
time.sleep(0.5)
return (self.props_header, self.props_inputs, self.props_outputs)
示例9: mouse_move_to_menu
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def mouse_move_to_menu():
mouse_move_to_menu_themes = ActionChains(driver)
mouse_move_to_menu_themes.move_to_element(menu)
mouse_move_to_menu_themes.move_to_element(tab)
mouse_move_to_menu_themes.move_to_element(subitem)
mouse_move_to_menu_themes.click(subitem)
mouse_move_to_menu_themes.perform()
time.sleep(5)
示例10: clicketi_click_list_row
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def clicketi_click_list_row(context, item):
"""
This is a special clicketi click for list items that might not be clickable
in the middle.
"""
action_chain = ActionChains(context.browser)
action_chain.move_to_element_with_offset(item, item.size['width'] / 4, item.size['height'] / 2)
action_chain.click()
action_chain.perform()
示例11: clickElement
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def clickElement(element):
if useNativeEvents > 0:
# move and click the mouse like a user
actions = ActionChains(driver)
actions.click(element)
actions.perform()
else:
# use the traditional accessibility action
element.click()
示例12: test_search_in_python_org
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def test_search_in_python_org(self):
driver = self.driver
actions = ActionChains(driver)
driver.get("http://localhost:8000")
# Test for text in editor
elem = driver.find_element_by_id('menu_nengo_viz')
actions.click(elem)
示例13: do_it
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def do_it(self):
mouse_move_to_menu_themes = ActionChains(self.driver)
mouse_move_to_menu_themes.move_to_element(self.menu)
mouse_move_to_menu_themes.move_to_element(self.tab)
mouse_move_to_menu_themes.move_to_element(self.subitem)
mouse_move_to_menu_themes.click(self.subitem)
mouse_move_to_menu_themes.perform()
time.sleep(5)
示例14: create_rerun
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def create_rerun(self, course_key):
"""
Clicks the create rerun link of the course specified by course_key
'Re-run course' link doesn't show up until you mouse over that course in the course listing
"""
actions = ActionChains(self.browser)
button_name = self.browser.find_element_by_css_selector('.rerun-button[href$="' + course_key + '"]')
actions.move_to_element(button_name)
actions.click(button_name)
actions.perform()
示例15: test_report
# 需要导入模块: from selenium.webdriver import ActionChains [as 别名]
# 或者: from selenium.webdriver.ActionChains import click [as 别名]
def test_report(self):
self.browser.get(self.live_server_url + '/')
# Login
username = self.browser.find_element_by_id('username')
username.send_keys('Jim')
password = self.browser.find_element_by_id('password')
# Send the wrong password
password.send_keys('correcthorsebatterystaple')
# Submit the form
submit = self.browser.find_element_by_id('submit')
submit.click()
# Navigate to the sale page
img = self.browser.find_element_by_xpath(
'//div[@class="card small grey darken-3"][1]//img[@id="report-image"]')
img.click()
# Get the choose showing modal
showing = self.browser.find_element_by_xpath(
'//div[@class="col s6 center-align"][1]/button')
showing.click()
wait = WebDriverWait(self.browser, 10)
element = wait.until(EC.element_to_be_clickable((By.ID, 'picker-modal')))
modal = self.browser.find_element_by_id('picker-modal')
self.assertTrue(modal.is_displayed())
occ = self.browser.find_element_by_id('showing')
occ.click()
free_text = self.browser.find_element_by_xpath('//div[@id="sale-update"]//p').text
self.assertIn('No tickets sold', free_text)
self.assertIn('No tickets reserved', free_text)
self.assertIn('80 tickets left', free_text)
# Check selling tickets adds up properly
pricing = models.InHousePricing.objects.get(id=1)
member_price = pricing.member_price
concession_price = pricing.concession_price
public_price = pricing.public_price
mat_f_price = pricing.matinee_freshers_price
mat_f_nnt_price = pricing.matinee_freshers_nnt_price
out = self.browser.find_element_by_id('out1').text
member = self.browser.find_element_by_id('member')
action = ActionChains(self.browser)
action.click(on_element=member)
action.send_keys('1')
action.key_down(Keys.CONTROL)
action.key_up(Keys.CONTROL)
action.perform()