File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff 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" ) ;
Original file line number Diff line number Diff 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 ( )
You can’t perform that action at this time.
0 commit comments