1- import {
2- AppiumDriver ,
3- createDriver ,
4- SearchOptions
5- } from "nativescript-dev-appium" ;
1+ import { AppiumDriver , createDriver , SearchOptions , Direction } from "nativescript-dev-appium" ;
62import { isSauceLab , runType } from "nativescript-dev-appium/lib/parser" ;
73import { expect } from "chai" ;
4+ import { scrollToElement } from "./helper"
85import "mocha" ;
96const fs = require ( 'fs' ) ;
107const addContext = require ( 'mochawesome/addContext' ) ;
118const rimraf = require ( 'rimraf' ) ;
129const isSauceRun = isSauceLab ;
13- const isAndroid : boolean = runType . includes ( "android" ) ;
1410
1511describe ( "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