Skip to content

Commit

Permalink
interactions of elements csharp code added in github (#1728)[deploy s…
Browse files Browse the repository at this point in the history
…ite]

Co-authored-by: Sri Harsha <[email protected]>
  • Loading branch information
pallavigitwork and harsha509 authored May 30, 2024
1 parent cb2ea86 commit b262a15
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 119 deletions.
45 changes: 44 additions & 1 deletion examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]";
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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,23 @@ 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")

# 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
Expand Down Expand Up @@ -117,20 +114,12 @@ possible keystrokes that WebDriver Supports.
driver.find_element(By.NAME, "email_input").send_keys("[email protected]" )

{{< /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("[email protected]");


}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L27-L33" >}}
{{< /tab >}}


{{< tab header="Ruby" >}}

# Navigate to URL
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -113,20 +110,11 @@ possible keystrokes that WebDriver Supports.
driver.find_element(By.NAME, "email_input").send_keys("[email protected]" )

{{< /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("[email protected]");


}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L27-L33" >}}
{{< /tab >}}

{{< tab header="Ruby" >}}

# Navigate to URL
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -115,20 +111,11 @@ possible keystrokes that WebDriver Supports.
driver.find_element(By.NAME, "email_input").send_keys("[email protected]" )

{{< /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("[email protected]");


}
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L27-L33" >}}
{{< /tab >}}

{{< tab header="Ruby" >}}

# Navigate to URL
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -117,20 +113,12 @@ Selenium将返回一个 [元素点击中断](https://w3c.github.io/webdriver/#df
driver.find_element(By.NAME, "email_input").send_keys("[email protected]" )

{{< /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("[email protected]");

{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Elements/InteractionTest.cs#L27-L33" >}}
{{< /tab >}}


}
{{< /tab >}}
{{< tab header="Ruby" >}}

# Navigate to URL
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b262a15

Please sign in to comment.