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,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