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 2020import org .junit .jupiter .api .BeforeAll ;
2121import org .junit .jupiter .api .Test ;
2222
23+ import static io .appium .java_client .HasBrowserCheck .NATIVE_CONTEXT ;
2324import static org .junit .jupiter .api .Assertions .assertEquals ;
2425import static org .junit .jupiter .api .Assertions .assertThrows ;
2526
@@ -31,7 +32,7 @@ public class AndroidContextTest extends BaseAndroidTest {
3132 }
3233
3334 @ Test public void testGetContext () {
34- assertEquals ("NATIVE_APP" , driver .getContext ());
35+ assertEquals (NATIVE_CONTEXT , driver .getContext ());
3536 }
3637
3738 @ Test public void testGetContextHandles () {
@@ -42,8 +43,8 @@ public class AndroidContextTest extends BaseAndroidTest {
4243 driver .getContextHandles ();
4344 driver .context ("WEBVIEW_io.appium.android.apis" );
4445 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 );
4748 }
4849
4950 @ Test public void testContextError () {
Original file line number Diff line number Diff line change 1818import java .util .regex .Matcher ;
1919import java .util .regex .Pattern ;
2020
21+ import static io .appium .java_client .HasBrowserCheck .NATIVE_CONTEXT ;
2122import static java .time .Duration .ofMillis ;
2223import static java .time .Duration .ofSeconds ;
2324import static org .hamcrest .MatcherAssert .assertThat ;
@@ -75,7 +76,7 @@ public static void startWebViewActivity() {
7576 @ BeforeEach
7677 public void setUp () {
7778
78- driver .context ("NATIVE_APP" );
79+ driver .context (NATIVE_CONTEXT );
7980 }
8081
8182 @ Test
Original file line number Diff line number Diff line change 2323
2424import java .util .concurrent .CopyOnWriteArrayList ;
2525
26+ import static io .appium .java_client .HasBrowserCheck .NATIVE_CONTEXT ;
2627import static org .junit .jupiter .api .Assertions .assertFalse ;
2728
2829public class IOSBiDiTest extends AppIOSTest {
@@ -31,7 +32,7 @@ public class IOSBiDiTest extends AppIOSTest {
3132 @ Disabled ("Need to resolve compatibility issues" )
3233 public void listenForIosLogs () {
3334 var logs = new CopyOnWriteArrayList <LogEntry >();
34- try (var logInspector = new LogInspector (driver )) {
35+ try (var logInspector = new LogInspector (NATIVE_CONTEXT , driver )) {
3536 logInspector .onLog (logs ::add );
3637 driver .getPageSource ();
3738 }
Original file line number Diff line number Diff line change 1919import io .appium .java_client .NoSuchContextException ;
2020import org .junit .jupiter .api .Test ;
2121
22+ import static io .appium .java_client .HasBrowserCheck .NATIVE_CONTEXT ;
2223import static org .hamcrest .MatcherAssert .assertThat ;
2324import static org .hamcrest .core .StringContains .containsString ;
2425import static org .junit .jupiter .api .Assertions .assertEquals ;
2728public class IOSContextTest extends BaseIOSWebViewTest {
2829
2930 @ Test public void testGetContext () {
30- assertEquals ("NATIVE_APP" , driver .getContext ());
31+ assertEquals (NATIVE_CONTEXT , driver .getContext ());
3132 }
3233
3334 @ Test public void testGetContextHandles () {
@@ -38,7 +39,7 @@ public class IOSContextTest extends BaseIOSWebViewTest {
3839 driver .getContextHandles ();
3940 findAndSwitchToWebView ();
4041 assertThat (driver .getContext (), containsString ("WEBVIEW" ));
41- driver .context ("NATIVE_APP" );
42+ driver .context (NATIVE_CONTEXT );
4243 }
4344
4445 @ Test public void testContextError () {
Original file line number Diff line number Diff line change 1010import static java .util .Objects .requireNonNull ;
1111
1212public interface HasBrowserCheck extends ExecutesMethod , HasCapabilities {
13+ String NATIVE_CONTEXT = "NATIVE_APP" ;
14+
1315 /**
1416 * Validates if the driver is currently in a web browser context.
1517 *
@@ -32,7 +34,7 @@ default boolean isBrowser() {
3234 }
3335 try {
3436 var context = ((ContextAware ) this ).getContext ();
35- return context != null && !context .toUpperCase ().contains ("NATIVE_APP" );
37+ return context != null && !context .toUpperCase ().contains (NATIVE_CONTEXT );
3638 } catch (WebDriverException e ) {
3739 return false ;
3840 }
Original file line number Diff line number Diff line change 2828
2929import java .util .Optional ;
3030
31+ import static io .appium .java_client .HasBrowserCheck .NATIVE_CONTEXT ;
3132import static io .appium .java_client .pagefactory .bys .ContentType .HTML_OR_DEFAULT ;
3233import static io .appium .java_client .pagefactory .bys .ContentType .NATIVE_MOBILE_SPECIFIC ;
3334
3435public final class WebDriverUnpackUtility {
35- private static final String NATIVE_APP_PATTERN = "NATIVE_APP" ;
36-
3736 private WebDriverUnpackUtility () {
3837 }
3938
@@ -109,7 +108,7 @@ public static ContentType getCurrentContentType(SearchContext context) {
109108
110109 var contextAware = unpackObjectFromSearchContext (context , ContextAware .class );
111110 if (contextAware .map (ContextAware ::getContext )
112- .filter (c -> c .toUpperCase ().contains (NATIVE_APP_PATTERN )).isPresent ()) {
111+ .filter (c -> c .toUpperCase ().contains (NATIVE_CONTEXT )).isPresent ()) {
113112 return NATIVE_MOBILE_SPECIFIC ;
114113 }
115114
You can’t perform that action at this time.
0 commit comments