From 413f153acf2f03b1e1efc626358de8ff3259955a Mon Sep 17 00:00:00 2001 From: Hirok Sarker Date: Thu, 24 Oct 2019 13:57:50 +0600 Subject: [PATCH] C# SendKeys Example C# SendKeys Example --- .../content/webdriver/keyboard.en.md | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/docs_source_files/content/webdriver/keyboard.en.md b/docs_source_files/content/webdriver/keyboard.en.md index f6f352695009..b489f97abda4 100644 --- a/docs_source_files/content/webdriver/keyboard.en.md +++ b/docs_source_files/content/webdriver/keyboard.en.md @@ -44,9 +44,35 @@ driver.get("http://www.google.com") driver.find_element_by_name("q").send_keys("webdriver"+Keys.ENTER) {{< / code-panel >}} {{< code-panel language="csharp" >}} -// We don't have a C# code sample yet - Help us out and raise a PR +using OpenQA.Selenium; +using OpenQA.Selenium.Firefox; + +namespace HelloSeleniumTesting +{ + public class HelloSelenium + { + public static void Main(string[] args) + { + IWebDriver driver = new FirefoxDriver(); + try + { + // Navigate to Url + driver.Navigate().GoToUrl("https://google.com"); + + // Enter text "q" and perform keyboard action "Enter" + driver.FindElement(By.Name("q")).SendKeys("q" + Keys.Enter); + } + finally + { + driver.Quit(); + } + + } + } +} {{< / code-panel >}} {{< code-panel language="ruby" >}} + require 'selenium-webdriver' driver = Selenium::WebDriver.for :firefox begin @@ -101,4 +127,4 @@ class HelloSelenium { } } {{< / code-panel >}} -{{< / code-tab >}} \ No newline at end of file +{{< / code-tab >}}