@@ -76,7 +76,6 @@ public class AppiumDriver<T extends WebElement>
7676 private ExecuteMethod executeMethod ;
7777 private final String platformName ;
7878 private final String automationName ;
79- private String currentContext ;
8079
8180
8281 /**
@@ -92,35 +91,21 @@ public AppiumDriver(HttpCommandExecutor executor, Capabilities capabilities) {
9291 locationContext = new RemoteLocationContext (executeMethod );
9392 super .setErrorHandler (errorHandler );
9493 this .remoteAddress = executor .getAddressOfRemoteServer ();
95- final AppiumDriver <?> driver = this ;
96-
97- HasSessionDetails hasSessionDetails = new HasSessionDetails () {
98- @ Override
99- public Response execute (String driverCommand , Map <String , ?> parameters ) {
100- return driver .execute (driverCommand , parameters );
101- }
102-
103- @ Override
104- public Response execute (String driverCommand ) {
105- return driver .execute (driverCommand );
106- }
107- };
10894
10995 Object capabilityPlatform1 = getCapabilities ().getCapability (PLATFORM_NAME );
11096 Object capabilityAutomation1 = getCapabilities ().getCapability (AUTOMATION_NAME );
11197
11298 Object capabilityPlatform2 = capabilities .getCapability (PLATFORM_NAME );
11399 Object capabilityAutomation2 = capabilities .getCapability (AUTOMATION_NAME );
114100
115- platformName = ofNullable (ofNullable (hasSessionDetails .getPlatformName ())
101+ platformName = ofNullable (ofNullable (super .getPlatformName ())
116102 .orElse (capabilityPlatform1 != null ? String .valueOf (capabilityPlatform1 ) : null ))
117103 .orElse (capabilityPlatform2 != null ? String .valueOf (capabilityPlatform2 ) : null );
118- automationName = ofNullable (ofNullable (hasSessionDetails .getAutomationName ())
104+ automationName = ofNullable (ofNullable (super .getAutomationName ())
119105 .orElse (capabilityAutomation1 != null ? String .valueOf (capabilityAutomation1 ) : null ))
120106 .orElse (capabilityAutomation2 != null ? String .valueOf (capabilityAutomation2 ) : null );
121107
122108 this .setElementConverter (new JsonToMobileElementConverter (this , this ));
123- currentContext = getContext ();
124109 }
125110
126111 public AppiumDriver (URL remoteAddress , Capabilities desiredCapabilities ) {
@@ -352,7 +337,6 @@ public void zoom(int x, int y) {
352337 @ Override public WebDriver context (String name ) {
353338 checkNotNull (name , "Must supply a context name" );
354339 execute (DriverCommand .SWITCH_TO_CONTEXT , ImmutableMap .of ("name" , name ));
355- currentContext = name ;
356340 return this ;
357341 }
358342
@@ -430,9 +414,6 @@ public URL getRemoteAddress() {
430414 }
431415
432416 @ Override public boolean isBrowser () {
433- if (super .isBrowser ()) {
434- return true ;
435- }
436- return !currentContext .toLowerCase ().contains ("NATIVE_APP" .toLowerCase ());
417+ return !getContext ().toLowerCase ().contains ("NATIVE_APP" .toLowerCase ());
437418 }
438419}
0 commit comments