Skip to content

Commit bd3ee04

Browse files
author
Dimitar Todorov
committed
Update tests - add scroll to Post button
1 parent fda383f commit bd3ee04

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
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: 8 additions & 11 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,7 +87,7 @@ 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();
9793
await driver.wait(2000);
@@ -117,7 +113,7 @@ describe("Facebook tests", async function () {
117113
it("should share a link", async function () {
118114
const shareLinkButton = await driver.findElementByText("Open Share dialog", SearchOptions.contains);
119115
await shareLinkButton.click();
120-
if (isAndroid) {
116+
if (driver.isAndroid) {
121117
const allFields = await driver.findElementsByClassName(driver.locators.getElementByName("textfield"));
122118
await allFields[1].sendKeys(PASSWORD);
123119
await allFields[0].sendKeys(USERNAME);
@@ -136,7 +132,8 @@ describe("Facebook tests", async function () {
136132
const logInButton = await driver.findElementByText("Log In");
137133
await logInButton.click();
138134
}
139-
135+
136+
await scrollToElement(driver, "Post", Direction.down);
140137
const postButton = await driver.findElementByText("Post");
141138
expect(postButton).to.exist;
142139
});

0 commit comments

Comments
 (0)