From b262a15455aa4435655196e75fe6c5f4416b115c Mon Sep 17 00:00:00 2001 From: Pallavi Date: Thu, 30 May 2024 18:16:54 +0530 Subject: [PATCH] interactions of elements csharp code added in github (#1728)[deploy site] Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com> --- .../SeleniumDocs/Elements/InteractionTest.cs | 45 ++++++++++++++++++- .../webdriver/elements/interactions.en.md | 42 ++++++----------- .../webdriver/elements/interactions.ja.md | 42 +++++------------ .../webdriver/elements/interactions.pt-br.md | 38 ++++------------ .../webdriver/elements/interactions.zh-cn.md | 41 +++++------------ 5 files changed, 89 insertions(+), 119 deletions(-) diff --git a/examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs b/examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs index 16ba341a1b90..e20b94b46929 100644 --- a/examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs +++ b/examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs @@ -1,9 +1,52 @@ +using System; using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium; +using OpenQA.Selenium.Chrome; namespace SeleniumDocs.Elements { [TestClass] - public class InteractionTest : BaseTest + public class InteractionTest { + [TestMethod] + public void TestInteractionCommands() + { + IWebDriver driver = new ChromeDriver(); + driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500); + + // Navigate to Url + driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); + // Click on the element + IWebElement checkInput = driver.FindElement(By.Name("checkbox_input")); + checkInput.Click(); + + //Verify + Boolean isChecked = checkInput.Selected; + Assert.AreEqual(isChecked, false); + + //SendKeys + // Clear field to empty it from any previous data + IWebElement emailInput = driver.FindElement(By.Name("email_input")); + emailInput.Clear(); + //Enter Text + String email = "admin@localhost.dev"; + emailInput.SendKeys(email); + + //Verify + String data = emailInput.GetAttribute("value"); + Assert.AreEqual(data, email); + + + //Clear Element + // Clear field to empty it from any previous data + emailInput.Clear(); + data = emailInput.GetAttribute("value"); + + //Verify + Assert.AreEqual(data, ""); + + //Quit the browser + driver.Quit(); + } } } \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/elements/interactions.en.md b/website_and_docs/content/documentation/webdriver/elements/interactions.en.md index 51c48da1169a..fd48fe994573 100644 --- a/website_and_docs/content/documentation/webdriver/elements/interactions.en.md +++ b/website_and_docs/content/documentation/webdriver/elements/interactions.en.md @@ -44,10 +44,11 @@ Selenium will return an [element click intercepted](https://w3c.github.io/webdri {{< tabpane langEqualsHeader=true >}} + {{< tab header="Java" text=true >}} {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/InteractionTest.java#L18-L22" >}} {{< /tab >}} - {{< tab header="Python" >}} +{{< tab header="Python" >}} # Navigate to url driver.get("https://www.selenium.dev/selenium/web/inputs.html") @@ -55,15 +56,11 @@ Selenium will return an [element click intercepted](https://w3c.github.io/webdri # Click on the element driver.find_element(By.NAME, "color_input").click() {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Click the element - driver.FindElement(By.Name("color_input")).Click(); + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L17-L21" >}} {{< /tab >}} + {{< tab header="Ruby" >}} # Navigate to URL @@ -117,20 +114,12 @@ possible keystrokes that WebDriver Supports. driver.find_element(By.NAME, "email_input").send_keys("admin@localhost.dev" ) {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Clear field to empty it from any previous data - driver.FindElement(By.Name("email_input")).Clear(); - - //Enter Text - driver.FindElement(By.Name("email_input")).SendKeys("admin@localhost.dev"); - -} + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L27-L33" >}} {{< /tab >}} + + {{< tab header="Ruby" >}} # Navigate to URL @@ -184,18 +173,13 @@ with a`content-editable` attribute. If these conditions are not met, {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Clear field to empty it from any previous data - driver.FindElement(By.Name("email_input")).Clear(); - -} + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L40-L43" >}} {{< /tab >}} + + {{< tab header="Ruby" >}} # Navigate to URL diff --git a/website_and_docs/content/documentation/webdriver/elements/interactions.ja.md b/website_and_docs/content/documentation/webdriver/elements/interactions.ja.md index b0e0769826b0..b9c85b5a46b1 100644 --- a/website_and_docs/content/documentation/webdriver/elements/interactions.ja.md +++ b/website_and_docs/content/documentation/webdriver/elements/interactions.ja.md @@ -52,15 +52,12 @@ Selenium will return an [element click intercepted](https://w3c.github.io/webdri # Click on the element driver.find_element(By.NAME, "color_input").click() {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Click the element - driver.FindElement(By.Name("color_input")).Click(); - + + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L17-L21" >}} {{< /tab >}} + + {{< tab header="Ruby" >}} # Navigate to URL @@ -113,20 +110,11 @@ possible keystrokes that WebDriver Supports. driver.find_element(By.NAME, "email_input").send_keys("admin@localhost.dev" ) {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Clear field to empty it from any previous data - driver.FindElement(By.Name("email_input")).Clear(); - - //Enter Text - driver.FindElement(By.Name("email_input")).SendKeys("admin@localhost.dev"); - -} + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L27-L33" >}} {{< /tab >}} + {{< tab header="Ruby" >}} # Navigate to URL @@ -180,18 +168,12 @@ with a`content-editable` attribute. If these conditions are not met, {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Clear field to empty it from any previous data - driver.FindElement(By.Name("email_input")).Clear(); - - -} + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L40-L43" >}} {{< /tab >}} + + {{< tab header="Ruby" >}} # Navigate to URL diff --git a/website_and_docs/content/documentation/webdriver/elements/interactions.pt-br.md b/website_and_docs/content/documentation/webdriver/elements/interactions.pt-br.md index fc39d39568f9..61bc712377cc 100644 --- a/website_and_docs/content/documentation/webdriver/elements/interactions.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/elements/interactions.pt-br.md @@ -53,15 +53,11 @@ Selenium will return an [element click intercepted](https://w3c.github.io/webdri # Click on the element driver.find_element(By.NAME, "color_input").click() {{< /tab >}} - {{< tab header="CSharp" >}} - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Click the element - driver.FindElement(By.Name("color_input")).Click(); - + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L17-L21" >}} {{< /tab >}} + {{< tab header="Ruby" >}} # Navigate to URL @@ -115,20 +111,11 @@ possible keystrokes that WebDriver Supports. driver.find_element(By.NAME, "email_input").send_keys("admin@localhost.dev" ) {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Clear field to empty it from any previous data - driver.FindElement(By.Name("email_input")).Clear(); - - //Enter Text - driver.FindElement(By.Name("email_input")).SendKeys("admin@localhost.dev"); - -} + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L27-L33" >}} {{< /tab >}} + {{< tab header="Ruby" >}} # Navigate to URL @@ -182,18 +169,11 @@ with a`content-editable` attribute. If these conditions are not met, {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Clear field to empty it from any previous data - driver.FindElement(By.Name("email_input")).Clear(); - - -} + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L40-L43" >}} {{< /tab >}} + {{< tab header="Ruby" >}} # Navigate to URL diff --git a/website_and_docs/content/documentation/webdriver/elements/interactions.zh-cn.md b/website_and_docs/content/documentation/webdriver/elements/interactions.zh-cn.md index b48cd51e6c75..1267f13ac410 100644 --- a/website_and_docs/content/documentation/webdriver/elements/interactions.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/elements/interactions.zh-cn.md @@ -55,15 +55,11 @@ Selenium将返回一个 [元素点击中断](https://w3c.github.io/webdriver/#df # Click on the element driver.find_element(By.NAME, "color_input").click() {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Click the element - driver.FindElement(By.Name("color_input")).Click(); - + + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L17-L21" >}} {{< /tab >}} + {{< tab header="Ruby" >}} # Navigate to URL @@ -117,20 +113,12 @@ Selenium将返回一个 [元素点击中断](https://w3c.github.io/webdriver/#df driver.find_element(By.NAME, "email_input").send_keys("admin@localhost.dev" ) {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Clear field to empty it from any previous data - driver.FindElement(By.Name("email_input")).Clear(); - - //Enter Text - driver.FindElement(By.Name("email_input")).SendKeys("admin@localhost.dev"); + + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L27-L33" >}} + {{< /tab >}} -} - {{< /tab >}} {{< tab header="Ruby" >}} # Navigate to URL @@ -185,18 +173,11 @@ Selenium将返回一个 [元素点击中断](https://w3c.github.io/webdriver/#df {{< /tab >}} - {{< tab header="CSharp" >}} - - // Navigate to Url - driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/inputs.html"); - - // Clear field to empty it from any previous data - driver.FindElement(By.Name("email_input")).Clear(); - - -} + {{< tab header="CSharp" text=true >}} + {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L40-L43" >}} {{< /tab >}} + {{< tab header="Ruby" >}} # Navigate to URL