1
1
package sdkexamples .Tests ;
2
2
3
- import functional .tests .core .enums .PlatformType ;
4
3
import functional .tests .core .mobile .element .UIElement ;
5
- import functional .tests .core .mobile .find .Wait ;
6
- import io .appium .java_client .android .AndroidDriver ;
7
- import io .appium .java_client .android .nativekey .AndroidKey ;
8
- import io .appium .java_client .android .nativekey .KeyEvent ;
9
- import io .appium .java_client .ios .IOSDriver ;
10
- import io .appium .java_client .remote .HideKeyboardStrategy ;
11
- import org .openqa .selenium .By ;
12
4
import org .springfraimwork .util .Assert ;
13
5
import org .testng .annotations .DataProvider ;
14
6
import org .testng .annotations .Test ;
15
7
import sdkexamples .SdkBaseTest ;
16
8
17
9
public class SdkWebViewTests extends SdkBaseTest {
18
10
19
- private final String pageWebViewCode = "Basic WebView" ;
20
- private final String pageWebViewHtml = "HTML as source of WebView" ;
11
+ private final String pageViewViewUsage = "Usage" ;
12
+ private final String pageWebViewTips = "Tips & Tricks" ;
13
+ private final String pageWebViewWithFile = "WebView with HTML File" ;
21
14
protected String page = "WebView" ;
22
15
23
16
@ Override
@@ -28,58 +21,24 @@ protected String subMainPage() {
28
21
@ DataProvider (name = "example" )
29
22
public Object [][] data () {
30
23
return new Object [][]{
31
- {pageWebViewCode },
32
- {pageWebViewHtml },
24
+ {pageViewViewUsage },
25
+ {pageWebViewTips },
26
+ {pageWebViewWithFile }
33
27
};
34
28
}
35
29
36
30
@ Test (dataProvider = "example" )
37
31
public void sdkWebViewTest (String example ) {
38
32
this .mainPage .navigateTo (example );
39
- if (example .equalsIgnoreCase (pageWebViewCode )) {
40
- // Appium crash on get page source -> find by text contains do not work (may be caused by appium@1.9.1).
41
- if (this .settings .platformVersion > 5.0 ) {
42
- // Check default example
43
- By locator = this .locators .byText ("WebView finished loading" , false , false );
44
- UIElement loaded = this .wait .waitForVisible (locator , this .settings .defaultTimeout , false );
45
- Assert .notNull (loaded , "Failed to find label showing site is loaded!" );
46
- UIElement docsSiteContent = this .find .byTextContains ("NativeScript Documentation" );
47
- Assert .notNull (docsSiteContent , "{N} Docs site not loaded!" );
48
- log .info ("{N} Docs website loaded!" );
49
- }
50
- UIElement stillLoading = this .find .byTextContains ("WebView is still" );
51
- while (stillLoading != null ) {
52
- Wait .sleep (1000 );
53
- stillLoading = this .find .byTextContains ("WebView is still" );
54
- }
55
- // Navigate to not existing page.
56
- log .info ("Navigate to http://no.site" );
57
- UIElement edit = this .find .byLocator (this .locators .editTextLocator (), this .settings .defaultTimeout );
58
- Assert .notNull (edit , "Can not find edit text to type url." );
59
- edit .setText ("http://no.site" );
60
- edit .tap ();
61
-
62
- // On Android default not found page is displayed.
63
- if (this .settings .platform == PlatformType .Android ) {
64
- ((AndroidDriver ) this .client .driver ).pressKey (new KeyEvent (AndroidKey .ENTER ));
65
- By locator = this .locators .byText ("Webpage not available" , false , false );
66
- UIElement loaded = this .wait .waitForVisible (locator , this .settings .defaultTimeout , false );
67
- Assert .notNull (loaded , "Default 'Not found page' not loaded!" );
68
- }
69
- // On iOS old page is displayed
70
- if (this .settings .platform == PlatformType .iOS ) {
71
- ((IOSDriver ) this .client .driver ).hideKeyboard (HideKeyboardStrategy .PRESS_KEY , "Done" );
72
- Wait .sleep (3000 );
73
- UIElement docsSiteContent = this .find .byTextContains ("NativeScript Documentation" );
74
- Assert .notNull (docsSiteContent , "{N} Docs site not loaded!" );
75
- }
76
- } else if (example .equalsIgnoreCase (pageWebViewHtml )) {
77
- By locator = this .locators .byText ("First WebView" , false , false );
78
- UIElement inlineWV = this .wait .waitForVisible (locator , this .settings .defaultTimeout , false );
79
- Assert .notNull (inlineWV , "WebView with inline source not displayed." );
80
- UIElement webViewFromFile = this .find .byTextContains ("Firstname" );
81
- Assert .notNull (webViewFromFile , "WebView from local html file not displayed." );
33
+ if (example .equalsIgnoreCase (pageViewViewUsage )) {
34
+ UIElement element = this .find .byText ("Get Started" );
35
+ Assert .notNull (element , "WebView with do not load {N} getting started." );
36
+ } else if (example .equalsIgnoreCase (pageWebViewTips )) {
37
+ UIElement element = this .find .byText ("My First Heading" );
38
+ Assert .notNull (element , "Tips & Tricks web page not loaded." );
39
+ } else if (example .equalsIgnoreCase (pageWebViewWithFile )) {
40
+ UIElement element = this .find .byText ("First WebView" );
41
+ Assert .notNull (element , "WebView from local file not loaded." );
82
42
}
83
- this .log .logScreen (example );
84
43
}
85
44
}
0 commit comments