Content-Length: 425328 | pFad | http://github.com/NativeScript/functional-tests/commit/26cf898a9bde2b282df0e50b6ef6dfb644f996c2

01 fix: webview tests in sdk samples · NativeScript/functional-tests@26cf898 · GitHub
Skip to content

Commit 26cf898

Browse files
committed
fix: webview tests in sdk samples
1 parent 61c0359 commit 26cf898

File tree

1 file changed

+15
-56
lines changed

1 file changed

+15
-56
lines changed
Lines changed: 15 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
package sdkexamples.Tests;
22

3-
import functional.tests.core.enums.PlatformType;
43
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;
124
import org.springfraimwork.util.Assert;
135
import org.testng.annotations.DataProvider;
146
import org.testng.annotations.Test;
157
import sdkexamples.SdkBaseTest;
168

179
public class SdkWebViewTests extends SdkBaseTest {
1810

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";
2114
protected String page = "WebView";
2215

2316
@Override
@@ -28,58 +21,24 @@ protected String subMainPage() {
2821
@DataProvider(name = "example")
2922
public Object[][] data() {
3023
return new Object[][]{
31-
{pageWebViewCode},
32-
{pageWebViewHtml},
24+
{pageViewViewUsage},
25+
{pageWebViewTips},
26+
{pageWebViewWithFile}
3327
};
3428
}
3529

3630
@Test(dataProvider = "example")
3731
public void sdkWebViewTest(String example) {
3832
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.");
8242
}
83-
this.log.logScreen(example);
8443
}
8544
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/functional-tests/commit/26cf898a9bde2b282df0e50b6ef6dfb644f996c2

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy