1+ package org .openqa .selenium .remote ;
2+
3+ import static org .openqa .selenium .remote .CapabilityType .BROWSER_NAME ;
4+
5+ import com .google .auto .service .AutoService ;
6+
7+ import org .openqa .selenium .Capabilities ;
8+ import org .openqa .selenium .ImmutableCapabilities ;
9+ import org .openqa .selenium .SessionNotCreatedException ;
10+ import org .openqa .selenium .WebDriver ;
11+ import org .openqa .selenium .WebDriverInfo ;
12+
13+ import java .util .Optional ;
14+
15+ @ AutoService (WebDriverInfo .class )
16+ public class FakeWebDriverInfo implements WebDriverInfo {
17+
18+ @ Override
19+ public String getDisplayName () {
20+ return "selenium-test" ;
21+ }
22+
23+ @ Override
24+ public Capabilities getCanonicalCapabilities () {
25+ return new ImmutableCapabilities (BROWSER_NAME , "selenium-test" );
26+ }
27+
28+ @ Override
29+ public boolean isSupporting (Capabilities capabilities ) {
30+ return true ;
31+ }
32+
33+ @ Override
34+ public boolean isSupportingCdp () {
35+ return false ;
36+ }
37+
38+ @ Override
39+ public boolean isAvailable () {
40+ return true ;
41+ }
42+
43+ @ Override
44+ public int getMaximumSimultaneousSessions () {
45+ return Runtime .getRuntime ().availableProcessors ();
46+ }
47+
48+ @ Override
49+ public Optional <WebDriver > createDriver (Capabilities capabilities )
50+ throws SessionNotCreatedException {
51+
52+ return Optional .of (new FakeWebDriver ());
53+ }
54+
55+ private static class FakeWebDriver extends RemoteWebDriver {
56+
57+ @ Override
58+ protected void startSession (Capabilities capabilities ) {
59+ // no-op
60+ }
61+
62+ @ Override
63+ public void quit () {
64+ // no-op
65+ }
66+ }
67+ }
0 commit comments