Skip to content

Commit 16c09a2

Browse files
pujaganititusfortner
authored andcommitted
[dotnet] Add test to ensure actions happen in sequence
1 parent 9c18587 commit 16c09a2

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

common/src/web/login.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<html>
2+
3+
<head>
4+
<title>Login</title>
5+
</head>
6+
7+
<body>
8+
<main id="main-holder">
9+
<h1 id="login-header">Login</h1>
10+
<form id="login-form">
11+
<input type="text" name="username" id="username-field" class="login-form-field" placeholder="Username">
12+
<input type="password" name="password" id="password-field" class="login-form-field" placeholder="Password">
13+
<input type="submit" value="Login" id="login-form-submit">
14+
</form>
15+
16+
</main>
17+
</body>
18+
19+
<script type="text/javascript">
20+
const loginForm = document.getElementById("login-form");
21+
const loginButton = document.getElementById("login-form-submit");
22+
23+
loginButton.addEventListener("click", (e) => {
24+
e.preventDefault();
25+
26+
const username = loginForm.username.value;
27+
const password = loginForm.password.value;
28+
29+
if (username === "username" && password === "password") {
30+
alert("You have successfully logged in.");
31+
} else {
32+
alert("Please enter valid credentials");
33+
location.reload();
34+
}
35+
})
36+
37+
</script>
38+
39+
</html>

dotnet/test/common/DriverTestFixture.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public abstract class DriverTestFixture
2626

2727
public string javascriptPage = EnvironmentManager.Instance.UrlBuilder.WhereIs("javascriptPage.html");
2828

29+
public string loginPage = EnvironmentManager.Instance.UrlBuilder.WhereIs("login.html");
30+
2931
public string clickEventPage = EnvironmentManager.Instance.UrlBuilder.WhereIs("clickEventPage.html");
3032

3133
public string resultPage = EnvironmentManager.Instance.UrlBuilder.WhereIs("resultPage.html");

dotnet/test/common/Interactions/CombinedInputActionsTest.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@ public void PlainClickingOnMultiSelectionList()
5555
Assert.AreEqual("cheddar", resultElement.Text, "Should have picked the third option only.");
5656
}
5757

58+
[Test]
59+
public void ShouldAllowSettingActivePointerWithKeyBoardActions()
60+
{
61+
driver.Url = loginPage;
62+
63+
IWebElement username = driver.FindElement(By.Id("username-field"));
64+
IWebElement password = driver.FindElement(By.Id("password-field"));
65+
IWebElement login = driver.FindElement(By.Id("login-form-submit"));
66+
67+
Actions actionProvider = new Actions(driver);
68+
IAction loginAction = actionProvider
69+
.SendKeys(username, "username")
70+
.SendKeys(password, "password")
71+
.setActivePointer(PointerKind.Mouse, "test")
72+
.MoveToElement(login)
73+
.Click()
74+
.Build();
75+
76+
loginAction.Perform();
77+
78+
IAlert alert = driver.SwitchTo().Alert();
79+
Assert.AreEqual("You have successfully logged in.", alert.Text);
80+
81+
alert.Accept();
82+
}
83+
5884
[Test]
5985
[IgnoreBrowser(Browser.IE, "IE reports [0,0] as location for <option> elements")]
6086
public void ShiftClickingOnMultiSelectionList()

0 commit comments

Comments
 (0)