1- import { AppiumDriver , createDriver , SearchOptions } from "nativescript-dev-appium" ;
1+ import { AppiumDriver , createDriver , nsCapabilities } from "nativescript-dev-appium" ;
22import { assert } from "chai" ;
33
44describe ( "sample scenario" , async function ( ) {
55 let driver : AppiumDriver ;
66
77 before ( async function ( ) {
8+ nsCapabilities . testReporter . context = this ;
89 driver = await createDriver ( ) ;
910 } ) ;
1011
11- beforeEach ( async function ( ) {
12- try {
13- const items = await getItems ( ) ;
14- } catch ( err ) {
15- try {
16- const lblNinjas = await driver . findElementByText ( "Ninjas!" ) ;
17- }
18- catch ( err ) {
19- console . log ( "Navigating to ninjas page ..." ) ;
20- await driver . navBack ( ) ;
21- }
22- console . log ( "Navigating to main page ..." ) ;
23- await driver . navBack ( ) ;
24- }
25- } ) ;
26-
2712 afterEach ( async function ( ) {
2813 if ( this . currentTest . state === "failed" ) {
2914 await driver . logTestArtifacts ( this . currentTest . title ) ;
@@ -36,7 +21,7 @@ describe("sample scenario", async function () {
3621 } ) ;
3722
3823 it ( "should navigate to a ninja" , async function ( ) {
39- const btnNinjas = await driver . findElementByText ( "Ninjas" ) ;
24+ const btnNinjas = await driver . waitForElement ( "Ninjas" ) ;
4025 await btnNinjas . click ( ) ;
4126
4227 const itemMichaelangelo = await driver . findElementByText ( "Michaelangelo" ) ;
@@ -61,10 +46,10 @@ describe("sample scenario", async function () {
6146 for ( let styleType in styleTypes ) {
6247 it ( `should find an element with ${ styleType } style applied` , async function ( ) {
6348 const element = await driver . findElementByText ( styleTypes [ styleType ] ) ;
49+ driver . imageHelper . options . keepOriginalImageSize = false ;
50+ driver . imageHelper . options . isDeviceSpecific = false ;
6451 const result = await driver . compareElement ( element , "style" ) ;
6552 assert . isTrue ( result ) ;
6653 } ) ;
6754 }
68-
69- const getItems = async function ( ) { return driver . isAndroid ? await driver . findElementsByText ( "(Android)" ) : await driver . findElementsByText ( "(ios)" ) ; }
7055} ) ;
0 commit comments