File tree Expand file tree Collapse file tree 6 files changed +16
-11
lines changed
e2eAndroidTest/java/io/appium/java_client/android
e2eIosTest/java/io/appium/java_client/ios
main/java/io/appium/java_client Expand file tree Collapse file tree 6 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 20
20
import org .junit .jupiter .api .BeforeAll ;
21
21
import org .junit .jupiter .api .Test ;
22
22
23
+ import static io .appium .java_client .HasBrowserCheck .NATIVE_CONTEXT ;
23
24
import static org .junit .jupiter .api .Assertions .assertEquals ;
24
25
import static org .junit .jupiter .api .Assertions .assertThrows ;
25
26
@@ -31,7 +32,7 @@ public class AndroidContextTest extends BaseAndroidTest {
31
32
}
32
33
33
34
@ Test public void testGetContext () {
34
- assertEquals ("NATIVE_APP" , driver .getContext ());
35
+ assertEquals (NATIVE_CONTEXT , driver .getContext ());
35
36
}
36
37
37
38
@ Test public void testGetContextHandles () {
@@ -42,8 +43,8 @@ public class AndroidContextTest extends BaseAndroidTest {
42
43
driver .getContextHandles ();
43
44
driver .context ("WEBVIEW_io.appium.android.apis" );
44
45
assertEquals (driver .getContext (), "WEBVIEW_io.appium.android.apis" );
45
- driver .context ("NATIVE_APP" );
46
- assertEquals (driver .getContext (), "NATIVE_APP" );
46
+ driver .context (NATIVE_CONTEXT );
47
+ assertEquals (driver .getContext (), NATIVE_CONTEXT );
47
48
}
48
49
49
50
@ Test public void testContextError () {
Original file line number Diff line number Diff line change 18
18
import java .util .regex .Matcher ;
19
19
import java .util .regex .Pattern ;
20
20
21
+ import static io .appium .java_client .HasBrowserCheck .NATIVE_CONTEXT ;
21
22
import static java .time .Duration .ofMillis ;
22
23
import static java .time .Duration .ofSeconds ;
23
24
import static org .hamcrest .MatcherAssert .assertThat ;
@@ -75,7 +76,7 @@ public static void startWebViewActivity() {
75
76
@ BeforeEach
76
77
public void setUp () {
77
78
78
- driver .context ("NATIVE_APP" );
79
+ driver .context (NATIVE_CONTEXT );
79
80
}
80
81
81
82
@ Test
Original file line number Diff line number Diff line change 23
23
24
24
import java .util .concurrent .CopyOnWriteArrayList ;
25
25
26
+ import static io .appium .java_client .HasBrowserCheck .NATIVE_CONTEXT ;
26
27
import static org .junit .jupiter .api .Assertions .assertFalse ;
27
28
28
29
public class IOSBiDiTest extends AppIOSTest {
@@ -31,7 +32,7 @@ public class IOSBiDiTest extends AppIOSTest {
31
32
@ Disabled ("Need to resolve compatibility issues" )
32
33
public void listenForIosLogs () {
33
34
var logs = new CopyOnWriteArrayList <LogEntry >();
34
- try (var logInspector = new LogInspector (driver )) {
35
+ try (var logInspector = new LogInspector (NATIVE_CONTEXT , driver )) {
35
36
logInspector .onLog (logs ::add );
36
37
driver .getPageSource ();
37
38
}
Original file line number Diff line number Diff line change 19
19
import io .appium .java_client .NoSuchContextException ;
20
20
import org .junit .jupiter .api .Test ;
21
21
22
+ import static io .appium .java_client .HasBrowserCheck .NATIVE_CONTEXT ;
22
23
import static org .hamcrest .MatcherAssert .assertThat ;
23
24
import static org .hamcrest .core .StringContains .containsString ;
24
25
import static org .junit .jupiter .api .Assertions .assertEquals ;
27
28
public class IOSContextTest extends BaseIOSWebViewTest {
28
29
29
30
@ Test public void testGetContext () {
30
- assertEquals ("NATIVE_APP" , driver .getContext ());
31
+ assertEquals (NATIVE_CONTEXT , driver .getContext ());
31
32
}
32
33
33
34
@ Test public void testGetContextHandles () {
@@ -38,7 +39,7 @@ public class IOSContextTest extends BaseIOSWebViewTest {
38
39
driver .getContextHandles ();
39
40
findAndSwitchToWebView ();
40
41
assertThat (driver .getContext (), containsString ("WEBVIEW" ));
41
- driver .context ("NATIVE_APP" );
42
+ driver .context (NATIVE_CONTEXT );
42
43
}
43
44
44
45
@ Test public void testContextError () {
Original file line number Diff line number Diff line change 10
10
import static java .util .Objects .requireNonNull ;
11
11
12
12
public interface HasBrowserCheck extends ExecutesMethod , HasCapabilities {
13
+ String NATIVE_CONTEXT = "NATIVE_APP" ;
14
+
13
15
/**
14
16
* Validates if the driver is currently in a web browser context.
15
17
*
@@ -32,7 +34,7 @@ default boolean isBrowser() {
32
34
}
33
35
try {
34
36
var context = ((ContextAware ) this ).getContext ();
35
- return context != null && !context .toUpperCase ().contains ("NATIVE_APP" );
37
+ return context != null && !context .toUpperCase ().contains (NATIVE_CONTEXT );
36
38
} catch (WebDriverException e ) {
37
39
return false ;
38
40
}
Original file line number Diff line number Diff line change 28
28
29
29
import java .util .Optional ;
30
30
31
+ import static io .appium .java_client .HasBrowserCheck .NATIVE_CONTEXT ;
31
32
import static io .appium .java_client .pagefactory .bys .ContentType .HTML_OR_DEFAULT ;
32
33
import static io .appium .java_client .pagefactory .bys .ContentType .NATIVE_MOBILE_SPECIFIC ;
33
34
34
35
public final class WebDriverUnpackUtility {
35
- private static final String NATIVE_APP_PATTERN = "NATIVE_APP" ;
36
-
37
36
private WebDriverUnpackUtility () {
38
37
}
39
38
@@ -109,7 +108,7 @@ public static ContentType getCurrentContentType(SearchContext context) {
109
108
110
109
var contextAware = unpackObjectFromSearchContext (context , ContextAware .class );
111
110
if (contextAware .map (ContextAware ::getContext )
112
- .filter (c -> c .toUpperCase ().contains (NATIVE_APP_PATTERN )).isPresent ()) {
111
+ .filter (c -> c .toUpperCase ().contains (NATIVE_CONTEXT )).isPresent ()) {
113
112
return NATIVE_MOBILE_SPECIFIC ;
114
113
}
115
114
You can’t perform that action at this time.
0 commit comments