File tree 2 files changed +23
-5
lines changed
java/client/src/org/openqa/selenium/interactions
2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 30
30
* method calls.
31
31
*/
32
32
public class Actions {
33
+ protected WebDriver driver ;
33
34
protected Mouse mouse ;
34
35
protected Keyboard keyboard ;
35
36
protected CompositeAction action ;
@@ -39,8 +40,10 @@ public class Actions {
39
40
* @param driver the driver providing the implementations to use.
40
41
*/
41
42
public Actions (WebDriver driver ) {
42
- this (((HasInputDevices ) driver ).getKeyboard (),
43
- ((HasInputDevices ) driver ).getMouse ());
43
+ this .driver = driver ;
44
+ this .mouse = ((HasInputDevices ) driver ).getMouse ();
45
+ this .keyboard = ((HasInputDevices ) driver ).getKeyboard ();
46
+ resetCompositeAction ();
44
47
}
45
48
46
49
/**
@@ -65,7 +68,7 @@ public Actions(Keyboard keyboard) {
65
68
}
66
69
67
70
private void resetCompositeAction () {
68
- action = new CompositeAction ();
71
+ action = new CompositeAction (driver );
69
72
}
70
73
71
74
/**
Original file line number Diff line number Diff line change 19
19
20
20
import com .google .common .collect .ImmutableList ;
21
21
22
+ import org .openqa .selenium .WebDriver ;
23
+
22
24
import java .util .ArrayList ;
23
25
import java .util .List ;
24
26
27
29
*
28
30
*/
29
31
public class CompositeAction implements Action {
32
+ private WebDriver driver ;
30
33
private List <Action > actionsList = new ArrayList <Action >();
31
34
35
+ public CompositeAction () {
36
+ }
37
+
38
+ public CompositeAction (WebDriver driver ) {
39
+ this .driver = driver ;
40
+ }
41
+
32
42
public void perform () {
33
- for (Action action : actionsList ) {
34
- action .perform ();
43
+ if (driver != null && driver instanceof CanPerformActionChain ) {
44
+ ((CanPerformActionChain ) driver ).getActionChainExecutor ().execute (this );
45
+
46
+ } else {
47
+ for (Action action : actionsList ) {
48
+ action .perform ();
49
+ }
35
50
}
36
51
}
37
52
You can’t perform that action at this time.
0 commit comments