@@ -6,8 +6,20 @@ namespace OpenQA.Selenium.Interactions
6
6
[ TestFixture ]
7
7
public class CombinedInputActionsTest : DriverTestFixture
8
8
{
9
+ [ SetUp ]
10
+ public void Setup ( )
11
+ {
12
+ new Actions ( driver ) . SendKeys ( Keys . Null ) . Perform ( ) ;
13
+ }
14
+
15
+ [ TearDown ]
16
+ public void ReleaseModifierKeys ( )
17
+ {
18
+ new Actions ( driver ) . SendKeys ( Keys . Null ) . Perform ( ) ;
19
+ }
20
+
9
21
[ Test ]
10
- [ IgnoreBrowser ( Browser . IE , "Shift-click implementation not complete " ) ]
22
+ [ IgnoreBrowser ( Browser . IE , "IE reports [0,0] as location for <option> elements " ) ]
11
23
[ IgnoreBrowser ( Browser . Remote , "Shift-click implementation not complete" ) ]
12
24
[ IgnoreBrowser ( Browser . IPhone , "Shift-click implementation not complete" ) ]
13
25
[ IgnoreBrowser ( Browser . Android , "Shift-click implementation not complete" ) ]
@@ -35,7 +47,7 @@ public void ShouldAllowClickingOnFormElements()
35
47
}
36
48
37
49
[ Test ]
38
- [ IgnoreBrowser ( Browser . IE , "Control-click implementation not complete " ) ]
50
+ [ IgnoreBrowser ( Browser . IE , "Browser does not respond to combined input using SendMessage, only SendInput " ) ]
39
51
[ IgnoreBrowser ( Browser . Remote , "Control-click implementation not complete" ) ]
40
52
[ IgnoreBrowser ( Browser . IPhone , "Control-click implementation not complete" ) ]
41
53
[ IgnoreBrowser ( Browser . Android , "Control-click implementation not complete" ) ]
@@ -50,8 +62,7 @@ public void ShouldAllowSelectingMultipleItems()
50
62
51
63
ReadOnlyCollection < IWebElement > listItems = driver . FindElements ( By . TagName ( "li" ) ) ;
52
64
53
- Actions actionBuider = new Actions ( driver ) ;
54
- IAction selectThreeItems = actionBuider . KeyDown ( Keys . Control )
65
+ IAction selectThreeItems = new Actions ( driver ) . KeyDown ( Keys . Control )
55
66
. Click ( listItems [ 1 ] )
56
67
. Click ( listItems [ 3 ] )
57
68
. Click ( listItems [ 5 ] )
@@ -62,7 +73,7 @@ public void ShouldAllowSelectingMultipleItems()
62
73
Assert . AreEqual ( "#item2 #item4 #item6" , reportingElement . Text ) ;
63
74
64
75
// Now click on another element, make sure that's the only one selected.
65
- actionBuider . Click ( listItems [ 6 ] ) . Build ( ) . Perform ( ) ;
76
+ new Actions ( driver ) . Click ( listItems [ 6 ] ) . Build ( ) . Perform ( ) ;
66
77
Assert . AreEqual ( "#item7" , reportingElement . Text ) ;
67
78
}
68
79
@@ -143,7 +154,6 @@ public void MouseMovementWorksWhenNavigatingToAnotherPage()
143
154
[ IgnoreBrowser ( Browser . Safari ) ]
144
155
[ IgnoreBrowser ( Browser . HtmlUnit ) ]
145
156
[ IgnoreBrowser ( Browser . Opera ) ]
146
- [ IgnoreBrowser ( Browser . IE , "Windows native events library does not support storing modifiers state yet." ) ]
147
157
[ IgnoreBrowser ( Browser . Firefox , "Windows native events library does not support storing modifiers state yet." ) ]
148
158
public void ChordControlCutAndPaste ( )
149
159
{
@@ -171,17 +181,17 @@ public void ChordControlCutAndPaste()
171
181
172
182
//TODO: Figure out why calling sendKey(Key.CONTROL + "a") and then
173
183
//sendKeys("x") does not work on Linux.
174
- new Actions ( driver )
175
- . SendKeys ( Keys . Control + "a" + "x" )
184
+ new Actions ( driver ) . KeyDown ( Keys . Control )
185
+ . SendKeys ( "a" + "x" )
176
186
. Perform ( ) ;
177
187
178
188
// Release keys before next step.
179
189
new Actions ( driver ) . SendKeys ( Keys . Null ) . Perform ( ) ;
180
190
181
191
Assert . AreEqual ( string . Empty , element . GetAttribute ( "value" ) ) ;
182
192
183
- new Actions ( driver )
184
- . SendKeys ( Keys . Control + "v" )
193
+ new Actions ( driver ) . KeyDown ( Keys . Control )
194
+ . SendKeys ( "v" )
185
195
. SendKeys ( "v" )
186
196
. Perform ( ) ;
187
197
@@ -191,7 +201,7 @@ public void ChordControlCutAndPaste()
191
201
}
192
202
193
203
[ Test ]
194
- [ IgnoreBrowser ( Browser . IE ) ]
204
+ [ IgnoreBrowser ( Browser . IE , "Browser does not respond to combined input using SendMessage, only SendInput" ) ]
195
205
[ IgnoreBrowser ( Browser . Remote ) ]
196
206
[ IgnoreBrowser ( Browser . IPhone ) ]
197
207
[ IgnoreBrowser ( Browser . Android ) ]
@@ -209,20 +219,31 @@ public void CombiningShiftAndClickResultsInANewWindow()
209
219
IWebElement link = driver . FindElement ( By . Id ( "link" ) ) ;
210
220
string originalTitle = driver . Title ;
211
221
212
- int nWindows = driver . WindowHandles . Count ;
213
222
new Actions ( driver )
214
223
. MoveToElement ( link )
215
224
. KeyDown ( Keys . Shift )
216
- . Click ( )
225
+ . Click ( link )
217
226
. KeyUp ( Keys . Shift )
218
227
. Perform ( ) ;
219
-
220
- Assert . AreEqual ( nWindows + 1 , driver . WindowHandles . Count , "Should have opened a new window." ) ;
228
+ WaitFor ( ( ) => { return driver . WindowHandles . Count > 1 ; } , "Did not receive new window" ) ;
229
+ Assert . AreEqual ( 2 , driver . WindowHandles . Count , "Should have opened a new window." ) ;
221
230
Assert . AreEqual ( originalTitle , driver . Title , "Should not have navigated away." ) ;
231
+
232
+ string originalHandle = driver . CurrentWindowHandle ;
233
+ foreach ( string newHandle in driver . WindowHandles )
234
+ {
235
+ if ( newHandle != originalHandle )
236
+ {
237
+ driver . SwitchTo ( ) . Window ( newHandle ) ;
238
+ driver . Close ( ) ;
239
+ }
240
+ }
241
+
242
+ driver . SwitchTo ( ) . Window ( originalHandle ) ;
222
243
}
223
244
224
245
[ Test ]
225
- [ IgnoreBrowser ( Browser . IE ) ]
246
+ [ IgnoreBrowser ( Browser . IE , "Browser does not respond to combined input using SendMessage, only SendInput" ) ]
226
247
[ IgnoreBrowser ( Browser . Remote ) ]
227
248
[ IgnoreBrowser ( Browser . IPhone ) ]
228
249
[ IgnoreBrowser ( Browser . Android ) ]
@@ -240,7 +261,7 @@ public void HoldingDownShiftKeyWhileClicking()
240
261
241
262
IWebElement toClick = driver . FindElement ( By . Id ( "eventish" ) ) ;
242
263
243
- new Actions ( driver ) . KeyDown ( Keys . Shift ) . Click ( toClick ) . KeyUp ( Keys . Shift ) . Perform ( ) ;
264
+ new Actions ( driver ) . MoveToElement ( toClick ) . KeyDown ( Keys . Shift ) . Click ( ) . KeyUp ( Keys . Shift ) . Perform ( ) ;
244
265
245
266
IWebElement shiftInfo = WaitFor ( ( ) => { return driver . FindElement ( By . Id ( "shiftKey" ) ) ; } , "Could not find element with id 'shiftKey'" ) ;
246
267
Assert . AreEqual ( "true" , shiftInfo . Text ) ;
0 commit comments