Created
August 7, 2022 10:37
-
-
Save bharathmuddada/7ac69a2c002b9d8eb7f1b4a14dbce634 to your computer and use it in GitHub Desktop.
C# Selenium Program to copy paste text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SeleniumSample { | |
| public static void Main(string[] args) { | |
| new DriverManager().SetUpDriver(new ChromeConfig()); | |
| var driver = new ChromeDriver(); | |
| driver.Navigate().GoToUrl("https://www.google.com/"); | |
| driver.Manage().Window.Maximize(); | |
| var search_field = driver.FindElement(By.Name("q")); | |
| search_field.SendKeys("Selenium"); | |
| Actions actions = new Actions(driver); | |
| //To copy text from the search input field | |
| actions.DoubleClick(search_field).KeyDown(Keys.Control).SendKeys("c").Perform(); | |
| //To Save text in the search input field | |
| actions.Click(search_field).KeyDown(Keys.Space).KeyDown(Keys.Command).SendKeys("v").SendKeys(Keys.Enter).Perform(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment