19
19
20
20
import org .junit .Test ;
21
21
import org .openqa .selenium .JavascriptExecutor ;
22
- import org .openqa .selenium .StubDriver ;
23
22
import org .openqa .selenium .WebDriver ;
24
23
25
24
import static org .junit .Assert .fail ;
25
+ import static org .mockito .Mockito .mock ;
26
+ import static org .mockito .Mockito .withSettings ;
26
27
27
28
public class WebDriverCommandProcessorTest {
28
29
@ Test
29
30
public void testDriverNeedNotImplementHasCapabilities () {
30
- WebDriver driver = new StubJsDriver ();
31
+ WebDriver driver = mock (WebDriver .class ,
32
+ withSettings ().extraInterfaces (JavascriptExecutor .class ));
31
33
32
34
try {
33
35
new WebDriverCommandProcessor ("http://www.example.com" , driver );
@@ -38,28 +40,12 @@ public void testDriverNeedNotImplementHasCapabilities() {
38
40
39
41
@ Test
40
42
public void testRequiresAJavascriptEnabledDriver () {
41
- WebDriver driver = new StubDriver ( );
43
+ WebDriver driver = mock ( WebDriver . class );
42
44
43
45
try {
44
46
new WebDriverCommandProcessor ("http://example.com" , driver );
45
47
fail ("Was not expected to succeed" );
46
48
} catch (IllegalStateException expected ) {
47
49
}
48
50
}
49
-
50
- private static class StubJsDriver extends StubDriver implements JavascriptExecutor {
51
-
52
- @ Override
53
- public String getWindowHandle () {
54
- return null ;
55
- }
56
-
57
- public Object executeScript (String script , Object ... args ) {
58
- return null ;
59
- }
60
-
61
- public Object executeAsyncScript (String script , Object ... args ) {
62
- return null ;
63
- }
64
- }
65
51
}
0 commit comments