हम Selenium WebDriver (C#) में Actions क्लास का उपयोग करके माउस पॉइंटर को विशिष्ट स्थान या एलिमेंट पर ले जा सकते हैं। हमें पहले इस क्लास का एक ऑब्जेक्ट बनाना होगा।
किसी एलिमेंट पर जाने के लिए हमें MoveToElement मेथड लागू करना होगा और इस मेथड के पैरामीटर के रूप में एलिमेंट लोकेटर पास करना होगा। अंत में, इस कार्य को वास्तव में करने के लिए Perform मेथड का उपयोग किया जाता है।
किसी एलिमेंट पर जाने के बाद, हम Click मेथड से उस पर क्लिक कर सकते हैं। किसी विशिष्ट स्थान पर जाने के लिए, हमें MoveByOffset मेथड का उपयोग करना होगा और फिर x और y अक्ष के साथ शिफ्ट किए जाने वाले ऑफसेट नंबरों को पैरामीटर के रूप में पास करना होगा।
सिंटैक्स
Actions a = new Actions(driver); a.MoveByOffset(10,20).Perform(); a.Click().Perform() //move to an element IWebElement l = driver.FindElement(By.name("txtnam")); a.MoveToElement(l).Perform();आइए माउस को Library लिंक पर ले जाकर फिर उसे क्लिक करने का प्रयास करें।

उदाहरण
using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System; using OpenQA.Selenium; using OpenQA.Selenium.Interactions; namespace NUnitTestProject2{ public class Tests{ String url = "https://www.tutorialspoint.com/index.htm"; IWebDriver driver; [SetUp] public void Setup(){ //creating object of FirefoxDriver driver = new FirefoxDriver(""); } [Test] public void Test2(){ //URL launch driver.Navigate().GoToUrl(url); //identify element IWebElement l = driver.FindElement(By.XPath("//*[text()='Library']")); //object of Actions class Actions a = new Actions(driver); //move to element a.MoveToElement(l); //click a.Click(); a.Perform(); Console.WriteLine("Page title: " + driver.Title); } [TearDown] public void close_Browser(){ driver.Quit(); } } }आउटपुट
