Skip to content

Commit 5dec5b6

Browse files
Merge pull request #172 from NativeScript/dtodorov/update-e2e-tests-vue
Add wait step before Continue button on Login
2 parents e91c5ee + bd3ee04 commit 5dec5b6

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

demo-vue/e2e/helper.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { AppiumDriver, SearchOptions, createDriver, Direction, UIElement } from "nativescript-dev-appium";
2+
3+
4+
export async function scrollToElement(driver: AppiumDriver, element: string, direction: Direction = Direction.down) {
5+
let listView: UIElement;
6+
if (driver.isAndroid) {
7+
listView = await driver.findElementByClassName("android.widget.FrameLayout");
8+
}
9+
else {
10+
listView = await driver.findElementByClassName("XCUIElementTypeApplication");
11+
}
12+
const listItem = await listView.scrollTo(
13+
direction,
14+
() => driver.findElementByText(element, SearchOptions.contains),
15+
600
16+
);
17+
return listItem;
18+
}

demo-vue/e2e/test.e2e.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import {
2-
AppiumDriver,
3-
createDriver,
4-
SearchOptions
5-
} from "nativescript-dev-appium";
1+
import { AppiumDriver, createDriver, SearchOptions, Direction } from "nativescript-dev-appium";
62
import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser";
73
import { expect } from "chai";
4+
import { scrollToElement } from "./helper"
85
import "mocha";
96
const fs = require('fs');
107
const addContext = require('mochawesome/addContext');
118
const rimraf = require('rimraf');
129
const isSauceRun = isSauceLab;
13-
const isAndroid: boolean = runType.includes("android");
1410

1511
describe("Facebook tests", async function () {
1612
const FACEBOOK_BUTTON = "fbLogin";
@@ -54,7 +50,7 @@ describe("Facebook tests", async function () {
5450
});
5551

5652
it("should log in via custom button", async function () {
57-
if (isAndroid) {
53+
if (driver.isAndroid) {
5854
var userNameLabelElement = "Nativescript User";
5955
} else {
6056
var userNameLabelElement = "[@name='Nativescript User']";
@@ -63,7 +59,7 @@ describe("Facebook tests", async function () {
6359
const facebookButton = await driver.findElementByText("Custom", SearchOptions.contains);
6460
await facebookButton.click();
6561

66-
if (isAndroid) {
62+
if (driver.isAndroid) {
6763
await driver.wait(1000);
6864
const allFields = await driver.findElementsByClassName("android.widget.EditText");
6965
const wd = driver.wd();
@@ -91,13 +87,14 @@ describe("Facebook tests", async function () {
9187
try {
9288
await driver.driver.hideDeviceKeyboard("Done");
9389
} catch (error) { }
94-
if (isAndroid) {
90+
if (driver.isAndroid) {
9591
const logInButton = await driver.findElementByClassName(driver.locators.button);
9692
await logInButton.click();
97-
await driver.wait(500);
93+
await driver.wait(2000);
9894
} else {
9995
const logInButton = await driver.findElementByText("Log In");
10096
await logInButton.click();
97+
await driver.wait(2000);
10198
}
10299
const continueButton = await driver.findElementByText("Continue", SearchOptions.exact);
103100
await continueButton.click();
@@ -116,7 +113,7 @@ describe("Facebook tests", async function () {
116113
it("should share a link", async function () {
117114
const shareLinkButton = await driver.findElementByText("Open Share dialog", SearchOptions.contains);
118115
await shareLinkButton.click();
119-
if (isAndroid) {
116+
if (driver.isAndroid) {
120117
const allFields = await driver.findElementsByClassName(driver.locators.getElementByName("textfield"));
121118
await allFields[1].sendKeys(PASSWORD);
122119
await allFields[0].sendKeys(USERNAME);
@@ -135,7 +132,8 @@ describe("Facebook tests", async function () {
135132
const logInButton = await driver.findElementByText("Log In");
136133
await logInButton.click();
137134
}
138-
135+
136+
await scrollToElement(driver, "Post", Direction.down);
139137
const postButton = await driver.findElementByText("Post");
140138
expect(postButton).to.exist;
141139
});

0 commit comments

Comments
 (0)