This method is used to move the mouse to the middle of an element.It takes webelement as an argument.
Perform() method helps to do the operation of move_to_element() Method.
Syntax: actionchain_object.move_to_element(webelement).perform()
Example:
Scroll_Operation.py
from selenium import webdriver import time from selenium.common.exceptions import ElementNotVisibleException, NoSuchElementException from selenium.webdriver import ActionChains from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as ec driver = webdriver.Chrome("/Users/admin/Documents/Skill2Lead/Others/drivers/chromedriver.exe") #driver = webdriver.Firefox(executable_path="/Users/sujithreddy/Documents/Code2Lead/Others/drivers/geckodriver") driver.get("http://www.dummypoint.com/seleniumtemplate.html") assert "Selenium Template" in driver.title time.sleep(2) wait = WebDriverWait(driver,25,poll_frequency=1,ignored_exceptions=[ElementNotVisibleException,NoSuchElementException]) wait.until(ec.presence_of_element_located((By.LINK_TEXT,"Form"))).click() wait.until(ec.presence_of_element_located((By.ID,"reused_form"))) time.sleep(2) wait.until(ec.presence_of_element_located((By.ID,"name"))).send_keys("Skill2Lead") wait.until(ec.presence_of_element_located((By.ID,"email"))).send_keys("abc@gmail.com") wait.until(ec.presence_of_element_located((By.ID,"message"))).send_keys("ABCDEFG") captcha = wait.until(ec.presence_of_element_located((By.ID,"captcha_image"))) wait.until(ec.presence_of_element_located((By.ID,"captcha"))).send_keys(captcha.text) postButton = wait.until(ec.presence_of_element_located((By.ID,"btnContactUs"))) # Scroll Gesture actions = ActionChains(driver) actions.move_to_element(postButton).perform() postButton.click() time.sleep(5) driver.quit()