55import functional .tests .core .mobile .appium .Client ;
66import functional .tests .core .mobile .element .UIElement ;
77import functional .tests .core .settings .Settings ;
8- import functional . tests . core . utils . OSUtils ;
8+ import io . appium . java_client . MobileBy ;
99import io .appium .java_client .MobileElement ;
1010import org .openqa .selenium .By ;
1111
1515/**
1616 * TODO(): Add docs.
1717 */
18+ @ SuppressWarnings ({"unused" , "WeakerAccess" })
1819public class Find {
1920 private static final LoggerBase LOGGER_BASE = LoggerBase .getLogger ("Find" );
2021
@@ -38,7 +39,7 @@ public UIElement byLocator(By locator, int timeOut) {
3839 try {
3940 result = this .byLocator (locator );
4041 } catch (Exception e ) {
41- LOGGER_BASE .debug ("Failed to find element by locator: " + locator + " in " + String . valueOf ( timeOut ) + " seconds." );
42+ LOGGER_BASE .debug ("Failed to find element by locator: " + locator + " in " + timeOut + " seconds." );
4243 result = null ;
4344 }
4445
@@ -56,7 +57,7 @@ public UIElement byType(String value, int timeOut) {
5657 try {
5758 result = this .byType (value );
5859 } catch (Exception e ) {
59- LOGGER_BASE .error ("Failed to find element by value: " + value + " in " + String . valueOf ( timeOut ) + " seconds." );
60+ LOGGER_BASE .error ("Failed to find element by value: " + value + " in " + timeOut + " seconds." );
6061 result = null ;
6162 }
6263 this .client .setWait (this .settings .defaultTimeout );
@@ -72,17 +73,12 @@ public UIElement byText(String value, int timeOut) {
7273 UIElement result ;
7374 try {
7475 if (this .settings .platform == PlatformType .iOS ) {
75- String xcodeVersionString = OSUtils .runProcess ("xcodebuild -version" ).split ("/n" )[0 ].replace ("Xcode" , "" ).trim ();
76- if (xcodeVersionString .startsWith ("9" )) {
77- result = this .byLocator (By .id (value ));
78- } else {
79- result = this .byLocator (this .locators .byText (value ));
80- }
76+ result = this .byLocator (MobileBy .AccessibilityId (value ));
8177 } else {
8278 result = this .byLocator (this .locators .byText (value ));
8379 }
8480 } catch (Exception e ) {
85- LOGGER_BASE .error ("Failed to find element by text: " + value + " in " + String . valueOf ( timeOut ) + " seconds." );
81+ LOGGER_BASE .error ("Failed to find element by text: " + value + " in " + timeOut + " seconds." );
8682 result = null ;
8783 }
8884 this .client .setWait (this .settings .defaultTimeout );
@@ -95,7 +91,7 @@ public UIElement byText(String value, Boolean exactMatch, int timeOut) {
9591 try {
9692 result = this .byLocator (this .locators .byText (value , exactMatch , false ));
9793 } catch (Exception e ) {
98- LOGGER_BASE .error ("Failed to find element by text: " + value + " in " + String . valueOf ( timeOut ) + " seconds." );
94+ LOGGER_BASE .error ("Failed to find element by text: " + value + " in " + timeOut + " seconds." );
9995 result = null ;
10096 }
10197 this .client .setWait (this .settings .defaultTimeout );
@@ -120,7 +116,7 @@ public List<UIElement> elementsByLocator(By locator, int timeOut) {
120116 try {
121117 result = this .elementsByLocator (locator );
122118 } catch (Exception e ) {
123- LOGGER_BASE .error ("Failed to find elements by locator: " + locator + " in " + String . valueOf ( timeOut ) + " seconds." );
119+ LOGGER_BASE .error ("Failed to find elements by locator: " + locator + " in " + timeOut + " seconds." );
124120 result = null ;
125121 }
126122 this .client .setWait (this .settings .defaultTimeout );
@@ -137,7 +133,7 @@ public List<UIElement> elementsbyType(String value, int timeOut) {
137133 try {
138134 result = this .elementsbyType (value );
139135 } catch (Exception e ) {
140- LOGGER_BASE .error ("Failed to find elements by type: " + value + " in " + String . valueOf ( timeOut ) + " seconds." );
136+ LOGGER_BASE .error ("Failed to find elements by type: " + value + " in " + timeOut + " seconds." );
141137 result = null ;
142138 }
143139 this .client .setWait (this .settings .defaultTimeout );
0 commit comments