Best JavaScript code snippet using appium
test3-navigation.js
Source:test3-navigation.js  
1const nsAppium = require("nativescript-dev-appium");2const assert = require("chai").assert;3const expect = require("chai").expect;4const addContext = require('mochawesome/addContext');5describe("3. Start test left menu and navigation screen on GrowERP-restaurant App", () => {6    let driver;7    let isAndroid;8    let password = 'Moqui123!';9    let username = 'test@antwebsystems.com';10    before(async function() {11        nsAppium.nsCapabilities.testReporter.context = this;12        driver = await nsAppium.createDriver();13        isAndroid = driver.isAndroid;14    });15    beforeEach(async function () {16        console.log("Reset App before start new case!");17        await driver.resetApp();18        driver.wait(3000);19    });20    after(async function () {21        await driver.quit();22        console.log("Quit driver!");23    });24    afterEach(async function () {25        if (this.currentTest.state === "failed") {26            await driver.logTestArtifacts(this.currentTest.title);27        }28    });29    /*30       Scenario: Check all menu icons on the Dashboard screen.31       Given I am on the SetUp page32       When I access to the restaurant application.33       When I click the set up icon from the dashboard.34       Then I should see 8 menu icons on the SetUp page.35    */36       it("Check all menu icons on the Dashboard screen.", async function () {37        driver.wait("3000");38        const backToLogin = await driver.findElementByXPath("//*[@text = 'Back to Login']");39        await backToLogin.click();40        const allFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);41        await allFields[1].click().sendKeys(password);42        await allFields[0].click().sendKeys(username);43        await driver.driver.hideDeviceKeyboard("Done");44        const logInButton = await driver.findElementByClassName(driver.locators.button);45        await logInButton.click();46        driver.wait("5000");47        //check buttons menu in dashboard48        const checkDashboardScreens = await driver.findElementByText("Dashboard", "contains");49        assert.isTrue(await checkDashboardScreens.isDisplayed());50        driver.wait("1000");51        const checkOrderbuttons = await driver.findElementByText("Order", "contains");52        assert.isTrue(await checkOrderbuttons.isDisplayed());53        driver.wait("1000");54        const checkPreparebuttons = await driver.findElementByText("Prepare", "contains");55        assert.isTrue(await checkPreparebuttons.isDisplayed());56        driver.wait("1000");57        const checkServebuttons = await driver.findElementByText("Serve", "contains");58        assert.isTrue(await checkServebuttons.isDisplayed());59        driver.wait("1000");60        const checkBillbuttons = await driver.findElementByText("Bill", "contains");61        assert.isTrue(await checkBillbuttons.isDisplayed());62        driver.wait("1000");63        const selectOrdermenu = await driver.findElementByXPath("//*[@text = 'Order']");64        await selectOrdermenu.click();65        driver.wait("2000");66        const checkOrderTitle = await driver.findElementByText("Orders (Take/Serve/Bill)", "contains");67        assert.isTrue(await checkOrderTitle.isDisplayed());68        driver.wait("1000");69        const orderbacktodashboard = await driver.findElementByXPath("//*[@text = 'Orders (Take/Serve/Bill)']");70        await orderbacktodashboard.click();71        driver.wait("1000");72        const selectPreparemenu = await driver.findElementByXPath("//*[@text = 'Prepare']");73        await selectPreparemenu.click();74        driver.wait("2000");75        const checkPrepareTitle = await driver.findElementByText("Preparation Area", "contains");76        assert.isTrue(await checkPrepareTitle.isDisplayed());77        driver.wait("1000");78        const preparebacktodashboard = await driver.findElementByXPath("//*[@text = 'Preparation Area']");79        await preparebacktodashboard.click();80        driver.wait("1000");81        const selectReportsmenu = await driver.findElementByXPath("//*[@text = 'Reports']");82        await selectReportsmenu.click();83        driver.wait("2000");84        const checkReportsTitle = await driver.findElementByText("Reports", "contains");85        assert.isTrue(await checkReportsTitle.isDisplayed());86        driver.wait("1000");87        const reportbacktodashboard = await driver.findElementByXPath("//*[@text = 'Reports']");88        await reportbacktodashboard.click();89        driver.wait("1000");90        const selectTasksmenu = await driver.findElementByXPath("//*[@text = 'Tasks']");91        await selectTasksmenu.click();92        driver.wait("2000");93        const checkTasksTitle = await driver.findElementByText("Tasks for me and given to others", "contains");94        assert.isTrue(await checkTasksTitle.isDisplayed());95        driver.wait("1000");96        const taskbacktodashboard = await driver.findElementByXPath("//*[@text = 'Tasks for me and given to others']");97        await taskbacktodashboard.click();98        driver.wait("1000");99        const selectHelpmenu = await driver.findElementByXPath("//*[@text = 'Help']");100        await selectHelpmenu.click();101        driver.wait("2000");102        const checkHelpTitle = await driver.findElementByText("Help", "contains");103        assert.isTrue(await checkHelpTitle.isDisplayed());104        driver.wait("1000");105        const helptodashboard = await driver.findElementByXPath("//*[@text = 'Help']");106        await helptodashboard.click();107        driver.wait("1000");108    });109    /*110      Scenario: Check all menu items on the left navigation.111      Given I am on the left navigation.112      When I access to the restaurant application.113      When I click the left navigation.114      Then I should see all menu items.115    */116    it("Check all menu items on the left navigation.", async function () {117        driver.wait("2000");118        const backToLogin = await driver.findElementByXPath("//*[@text = 'Back to Login']");119        await backToLogin.click();120        const allFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);121        await allFields[1].click().sendKeys(password);122        await allFields[0].click().sendKeys(username);123        await driver.driver.hideDeviceKeyboard("Done");124        const logInButton = await driver.findElementByClassName(driver.locators.button);125        await logInButton.click();126        driver.wait("5000");127        const imageviewElement = await driver.findElementByClassName("android.widget.ImageView");128        await imageviewElement.click();129        driver.wait("2000");130        const orderButton = await driver.findElementByXPath("//*[@text = 'Orders (Take/Serve/Bill)']");131        await orderButton.click();132        driver.wait("3000");133        await imageviewElement.click();134        driver.wait("3000");135        const preparationButton = await driver.findElementByXPath("//*[@text = 'Preparation Area']");136        await preparationButton.click();137        driver.wait("3000");138        await imageviewElement.click();139        driver.wait("3000");140        const reportButton = await driver.findElementByXPath("//*[@text = 'Reports']");141        await reportButton.click();142        driver.wait("3000");143        await imageviewElement.click();144        driver.wait("3000");145        const tasksButton = await driver.findElementByXPath("//*[@text = 'Tasks']");146        await tasksButton.click();147        driver.wait("3000");148        await imageviewElement.click();149        driver.wait("3000");150        const myInfoButton = await driver.findElementByXPath("//*[@text = 'My Info']");151        await myInfoButton.click();152        driver.wait("3000");153        await imageviewElement.click();154        driver.wait("3000");155        const employeeButton = await driver.findElementByXPath("//*[@text = 'Me, Company, Empl. & Customers.']");156        await employeeButton.click();157        driver.wait("3000");158        await imageviewElement.click();159        driver.wait("3000");160        const locationButton = await driver.findElementByXPath("//*[@text = 'Locations']");161        await locationButton.click();162        driver.wait("3000");163        await imageviewElement.click();164        driver.wait("3000");165        const productButton = await driver.findElementByXPath("//*[@text = 'Products']");166        await productButton.click();167        driver.wait("3000");168        await imageviewElement.click();169        driver.wait("3000");170        const categoriesButton = await driver.findElementByXPath("//*[@text = 'Categories']");171        await categoriesButton.click();172        driver.wait("3000");173        await imageviewElement.click();174        driver.wait("3000");175        const aboutButton = await driver.findElementByXPath("//*[@text = 'About']");176        await aboutButton.click();177        driver.wait("3000");178    });179    /*180       Scenario: Check all menu icons on the SetUp screen.181       Given I am on the SetUp page182       When I access to the restaurant application.183       When I click the SetUp icon from the dashboard.184       Then I should see 8 menu icons on the SetUp page.185    */186    it("Check all menu icons on the SetUp screen.", async function () {187        driver.wait("3000");188        const backToLogin = await driver.findElementByXPath("//*[@text = 'Back to Login']");189        await backToLogin.click();190        const allFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);191        await allFields[1].click().sendKeys(password);192        await allFields[0].click().sendKeys(username);193        await driver.driver.hideDeviceKeyboard("Done");194        const logInButton = await driver.findElementByClassName(driver.locators.button);195        await logInButton.click();196        driver.wait("5000");197        //check buttons menu in dashboard198        const checkDashboardScreens = await driver.findElementByText("Dashboard", "contains");199        assert.isTrue(await checkDashboardScreens.isDisplayed());200        driver.wait("1000");201        const checkSetUpbuttons = await driver.findElementByText("SetUp", "contains");202        assert.isTrue(await checkSetUpbuttons.isDisplayed());203        driver.wait("1000");204        const selectOrdermenu = await driver.findElementByXPath("//*[@text = 'SetUp']");205        await selectOrdermenu.click();206        driver.wait("1000");207        //Prep.Loc button208        const checkLocationButtons = await driver.findElementByText("Prep.Loc", "contains");209        assert.isTrue(await checkLocationButtons.isDisplayed());210        driver.wait("1000");211        const selectLocationmenu = await driver.findElementByXPath("//*[@text = 'Prep.Loc']");212        await selectLocationmenu.click();213        driver.wait("1000");214        const checkLocationTitle = await driver.findElementByText("Locations", "contains");215        assert.isTrue(await checkLocationTitle.isDisplayed());216        driver.wait("1000");217        const checkAreatab = await driver.findElementByText("PREPARATION AREA", "contains");218        assert.isTrue(await checkAreatab.isDisplayed());219        driver.wait("1000");220        const checkTableTitle = await driver.findElementByText("TABLE AREAS", "contains");221        assert.isTrue(await checkTableTitle.isDisplayed());222        driver.wait("1000");223        const locationToDashboard = await driver.findElementByXPath("//*[@text = 'Locations']");224        await locationToDashboard.click();225        driver.wait("1000");226        //Category button227        const checkCategoryButtons = await driver.findElementByText("Category", "contains");228        assert.isTrue(await checkCategoryButtons.isDisplayed());229        driver.wait("1000");230        const selectCategoryMenu = await driver.findElementByXPath("//*[@text = 'Category']");231        await selectCategoryMenu.click();232        driver.wait("1000");233        const checkCategoryTitle = await driver.findElementByText("Categories", "contains");234        assert.isTrue(await checkCategoryTitle.isDisplayed());235        driver.wait("1000");236        const categoryToDashboard = await driver.findElementByXPath("//*[@text = 'Categories']");237        await categoryToDashboard.click();238        driver.wait("1000");239        //Product button240        const checkProductButtons = await driver.findElementByText("Product", "contains");241        assert.isTrue(await checkProductButtons.isDisplayed());242        driver.wait("1000");243        const selectProductmenu = await driver.findElementByXPath("//*[@text = 'Product']");244        await selectProductmenu.click();245        driver.wait("1000");246        const checkProductTitle = await driver.findElementByText("Product", "contains");247        assert.isTrue(await checkProductTitle.isDisplayed());248        driver.wait("1000");249        const productToDashboard = await driver.findElementByXPath("//*[@text = 'Product']");250        await productToDashboard.click();251        driver.wait("1000");252        //Employee button253        const checkEmployeeButtons = await driver.findElementByText("Employee", "contains");254        assert.isTrue(await checkEmployeeButtons.isDisplayed());255        driver.wait("1000");256        const selectEmployeemenu = await driver.findElementByXPath("//*[@text = 'Employee']");257        await selectEmployeemenu.click();258        driver.wait("1000");259        const checkEmployeeTitle = await driver.findElementByText("Me, Company, Empl. & Customers.", "contains");260        assert.isTrue(await checkEmployeeTitle.isDisplayed());261        driver.wait("1000");262        const checkCustomerTab = await driver.findElementByText("CUSTOMER", "contains");263        assert.isTrue(await checkCustomerTab.isDisplayed());264        driver.wait("1000");265        const customerTab = await driver.findElementByXPath("//*[@text = 'CUSTOMER']");266        await customerTab.click();267        driver.wait("1000");268        const employeeToDashboard = await driver.findElementByXPath("//*[@text = 'Me, Company, Empl. & Customers.']");269        await employeeToDashboard.click();270        driver.wait("1000");271        //Upgrade button272        const checkUpgradeButtons = await driver.findElementByText("Upgrade", "contains");273        assert.isTrue(await checkUpgradeButtons.isDisplayed());274        driver.wait("1000");275        const selectUpgrademenu = await driver.findElementByXPath("//*[@text = 'Upgrade']");276        await selectUpgrademenu.click();277        driver.wait("1000");278        const checkUpgradeTitle = await driver.findElementByText("Upgrade", "contains");279        assert.isTrue(await checkUpgradeTitle.isDisplayed());280        driver.wait("1000");281        const upgradeToDashboard = await driver.findElementByXPath("//*[@text = 'Upgrade']");282        await upgradeToDashboard.click();283        driver.wait("1000");284    });...test2-order.js
Source:test2-order.js  
1const nsAppium = require("nativescript-dev-appium");2const assert = require("chai").assert;3const expect = require("chai").expect;4const addContext = require('mochawesome/addContext');5describe("2. Start test create order on GrowERP-restaurant App", () => {6    let driver;7    let isAndroid;8    let password = 'Moqui123!';9    let username = 'test@antwebsystems.com';10    before(async function() {11        nsAppium.nsCapabilities.testReporter.context = this;12        driver = await nsAppium.createDriver();13        isAndroid = driver.isAndroid;14    });15    beforeEach(async function () {16        await driver.resetApp();17        driver.wait(3000);18        /* Login to the restaurant app19        const backToLogin = await driver.findElementByXPath("//*[@text = 'Back to Login']");20        await backToLogin.click();21        var userNameLabelElement = "[@text='User Name/Email']";22        const allFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);23        await allFields[1].click().sendKeys(password);24        await allFields[0].click().sendKeys(username);25        const logInButton = await driver.findElementByClassName(driver.locators.button);26        await logInButton.click();27        driver.wait(3000);*/28    });29    after(async function () {30        await driver.quit();31        console.log("Quit driver!");32    });33    afterEach(async function () {34        if (this.currentTest.state === "failed") {35            await driver.logTestArtifacts(this.currentTest.title);36        }37    });38    /*39       Scenario: Check all order menu icons on the Dashboard screen.40       Given I am on the Dashboard page41       When I access to the restaurant application.42       When I click the Order, Prepare, Server and Bill icon from the dashboard.43       Then I should go to the selected page.44    */45    it("Check all order menu icons on the Dashboard screen.", async function () {46        driver.wait("3000");47        const backToLogin = await driver.findElementByXPath("//*[@text = 'Back to Login']");48        await backToLogin.click();49        const allFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);50        await allFields[1].click().sendKeys(password);51        await allFields[0].click().sendKeys(username);52        await driver.driver.hideDeviceKeyboard("Done");53        const logInButton = await driver.findElementByClassName(driver.locators.button);54        await logInButton.click();55        driver.wait("5000");56        //check buttons menu in dashboard57        const checkDashboardScreens = await driver.findElementByText("Dashboard", "contains");58        assert.isTrue(await checkDashboardScreens.isDisplayed());59        driver.wait("1000");60        const checkOrderbuttons = await driver.findElementByText("Order", "contains");61        assert.isTrue(await checkOrderbuttons.isDisplayed());62        driver.wait("1000");63        const checkPreparebuttons = await driver.findElementByText("Prepare", "contains");64        assert.isTrue(await checkPreparebuttons.isDisplayed());65        driver.wait("1000");66        const checkServebuttons = await driver.findElementByText("Serve", "contains");67        assert.isTrue(await checkServebuttons.isDisplayed());68        driver.wait("1000");69        const checkBillbuttons = await driver.findElementByText("Bill", "contains");70        assert.isTrue(await checkBillbuttons.isDisplayed());71        driver.wait("1000");72        const selectOrdermenu = await driver.findElementByXPath("//*[@text = 'Order']");73        await selectOrdermenu.click();74        driver.wait("2000");75        const checkOrderTitle = await driver.findElementByText("Orders (Take/Serve/Bill)", "contains");76        assert.isTrue(await checkOrderTitle.isDisplayed());77        driver.wait("1000");78        const orderbacktodashboard = await driver.findElementByXPath("//*[@text = 'Orders (Take/Serve/Bill)']");79        await orderbacktodashboard.click();80        driver.wait("1000");81        const selectPreparemenu = await driver.findElementByXPath("//*[@text = 'Prepare']");82        await selectPreparemenu.click();83        driver.wait("2000");84        const checkPrepareTitle = await driver.findElementByText("Preparation Area", "contains");85        assert.isTrue(await checkPrepareTitle.isDisplayed());86        driver.wait("1000");87        const preparebacktodashboard = await driver.findElementByXPath("//*[@text = 'Preparation Area']");88        await preparebacktodashboard.click();89        driver.wait("1000");90    });91    //Feature: As an employee, I want to create new order to new customer by enter telephone number.92    it("Employee can place an order for new customer.", async function () {93        let TELEPHONE = '0903012010NewCustomer';94        let NUMGUEST = '2';95        let TABLESCLECT = '2';96        driver.wait("3000");97        const backToLogin = await driver.findElementByXPath("//*[@text = 'Back to Login']");98        await backToLogin.click();99        const allFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);100        await allFields[1].click().sendKeys(password);101        await allFields[0].click().sendKeys(username);102        await driver.driver.hideDeviceKeyboard("Done");103        const logInButton = await driver.findElementByClassName(driver.locators.button);104        await logInButton.click();105        driver.wait("5000");106        const imageviewElement = await driver.findElementByClassName("android.widget.ImageView");107        await imageviewElement.click();108        driver.wait("2000");109        const orderMenuElement = await driver.findElementsByXPath("//android.widget.TextView");110        await orderMenuElement[2].click();111        driver.wait("2000");112        const selectTabTakeorder = await driver.findElementByXPath("//*[@text = 'TAKE ORDER']");113        await selectTabTakeorder.click();114        driver.wait("2000");115        const selectTable = await driver.findElementByXPath("//*[@text = '"+TABLESCLECT+"']");116        await selectTable.click();117        driver.wait("10000");118        const allOrderFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);119        await allOrderFields[0].click().sendKeys(TELEPHONE);120        await allOrderFields[2].click().sendKeys(NUMGUEST);121        await driver.driver.hideDeviceKeyboard("Done");122        const continueButton = await driver.findElementByClassName(driver.locators.button);123        await continueButton.click();124        const orderTableLabel = await driver.findElementByText("Order for Table: Inside-"+TABLESCLECT, "contains");125        assert.isTrue(await orderTableLabel.isDisplayed());126        const selectDrinksButtons = await driver.findElementByXPath("//*[@text = 'Drinks']");127        await selectDrinksButtons.click();128        driver.wait("1000");129        const checkDrinks = await driver.findElementByXPath("//*[@text = 'Cola']");130        await checkDrinks.click();131        driver.wait("1000");132        await checkDrinks.click();133        driver.wait("2000");134        const continueOrderButton = await driver.findElementByXPath("//*[@text = 'CONTINUE']");135        await continueOrderButton.click();136        driver.wait("1000");137        const checkPrepareTitle = await driver.findElementByText("Cola", "contains");138        assert.isTrue(await checkPrepareTitle.isDisplayed());139        driver.wait("1000");140        const saveOrder = await driver.findElementByXPath("//*[@text = 'SAVE ORDER']");141        await saveOrder.click();142        /*143        Scenario: Create new order for new customer144        Given I am on the order page145        When I access to the restaurant application.146        When I click the order icon from the dashboard.147        When I provide customer information.148        When I click on the "Continue" button149        Then I should see the page to select the food menu.150         */151    });152    /*153        Comment out for now: No need to go deep to do the actions since it take some times to do the process.154       Scenario: Create new order.155       Given I am on the order page156       When I access to the restaurant application.157       When I click the order icon from the dashboard.158       When I provide customer information and add food/drink to an order.159       When I click on the "Save Order" button.160       When I click on the "Prepare" button.161       Then I should see my order list.162    it("Admin can place an order.", async function () {163    });164        Scenario: Create new order.165        Given I am on the order page166        When I access to the restaurant application.167        When I click the order icon from the dashboard.168        When I provide customer information and add food/drink to an order.169        When I click on the "Save Order" button.170        When I click on the "Prepare" button.171        Then I should see my order list.172    it("Employee can place an order.", async function () {173    });174        Feature: As an employee, I want to create new order to existing customer by enter telephone number.175        Scenario: Create new order for new customer176        Given I am on the order page177        When I access to the restaurant application.178        When I click the order icon from the dashboard.179        When I provide existing customer information with telephone number.180        When I click on the "Continue" button181        Then I should see the page to select the food menu.182    it("Employee can place an order for existing customer(using the telephone number).", async function () {183    });184    */185    // Feature: As an employee, I want to create new order to existing customer by enter the member ID.186    /*187        Scenario: Create new order for new customer188        Given I am on the order page189        When I access to the restaurant application.190        When I click the order icon from the dashboard.191        When I provide existing customer information with telephone number.192        When I click on the "Continue" button193        Then I should see the page to select the food menu.194    it("Employee can place an order for existing customer(using the member ID).", async function () {195    });196    */197    // Feature: As an employee, I want to view the menu that ready to serve.198    /*199        Scenario: Be able to view the menu that ready to serve.200        Given I am on the order preparation page201        When I access to the restaurant application.202        When I click the preparation icon from the dashboard.203        When I click the "Done" button from the order prepare list.204        Then I should not see that order item on the order prepare list and I should see this order in the "Serve" page.205    it("Employee can view the menu that ready to serve).", async function () {206    });207     */...test1-register.js
Source:test1-register.js  
1const nsAppium = require("nativescript-dev-appium");2const assert = require("chai").assert;3const expect = require("chai").expect;4const addContext = require('mochawesome/addContext');5describe("1. Start test register, login and forgot your password functions on GrowERP-restaurant App", () => {6    let driver;7    let isAndroid;8    let password = '!awstest12';9    let username = 'testapp'+ Math.floor(Math.random()*100000) + '@gmail.com';10    before(async function() {11        nsAppium.nsCapabilities.testReporter.context = this;12        driver = await nsAppium.createDriver();13        isAndroid = driver.isAndroid;14    });15    beforeEach(async function () {16        await driver.resetApp();17        driver.wait(3000);18    });19    after(async function () {20        await driver.quit();21        console.log("Quit driver!");22    });23    afterEach(async function () {24        if (this.currentTest.state === "failed") {25            await driver.logTestArtifacts(this.currentTest.title);26        }27    });28    it("Register with the new email.", async function () {29        console.log('========= Register username : ', username)30        console.log('========= Register password : ', password)31        let firstName = 'Test user';32        let lastName = 'Doe';33        let restaurantName = 'Test Restaurant';34        // var signUpbotton = "[@name = 'Not have an account Sign Up now!']";35        var currencyLabelElement = "Australian Dollar [AUD]";36        var checkDisplayDashboard = "[@text = 'Dashboard']";37        //Check regsiter screens38        if(!driver.findElementByXPathIfExists("//*[@text = 'Not have an account Sign Up now!']")){39            const regsiterButton = await (driver.findElementByXPath("//*[@text = 'Not have an account Sign Up now!']"));40            await regsiterButton.click();41        }42        // Regsiter43        const registerFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);44        await registerFields[0].click().sendKeys(restaurantName);45        await driver.driver.hideDeviceKeyboard("Done");46        const dropdown = await driver.findElementByXPath("//android.widget.TextView[@index=0]");47        await dropdown.click();48        const currencyLabel = await driver.findElementByText(currencyLabelElement);49        await currencyLabel.click();50        await registerFields[1].click().sendKeys(firstName);51        await registerFields[2].click().sendKeys(lastName);52        await registerFields[3].click().sendKeys(username);53        await registerFields[4].click().sendKeys(password);54        await driver.driver.hideDeviceKeyboard("Done");55        await registerFields[5].click().sendKeys(password);56        await driver.driver.hideDeviceKeyboard("Done");57        const registButton = await driver.findElementByClassName(driver.locators.button);58        await registButton.click();59        const alertOkButton = await driver.findElementByXPath("//*[@text = 'OK']");60        await alertOkButton.click();61        //Re Login62        const loginFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);63        await loginFields[1].click().sendKeys(password);64        await loginFields[0].click().sendKeys(username);65        await driver.driver.hideDeviceKeyboard("Done");66        const logInButton = await driver.findElementByClassName(driver.locators.button);67        await logInButton.click();68        // Check if launch dashboard page.69        const dashBoardLabel = await driver.findElementByText("Dashboard", "exact");70        // expect(dashBoardLabelText).to.equal("Dashboard", "Unable to login with this user #"+username);71        assert.isTrue(await dashBoardLabel.isDisplayed(), 'Unable to login with this user :'+username);72    });73    it("Register with the existing email.", async function () {74        console.log('********** Register with the existing email.')75        let firstName = 'Test existing user';76        let lastName = 'Doe';77        let restaurantName = 'Test Existing Restaurant';78        var currencyLabelElement = "Australian Dollar [AUD]";79        // var checkDisplayDashboard = "[@text = 'Dashboard']";80        //Check regsiter screens81        if(!driver.findElementByXPathIfExists("//*[@text = 'Not have an account Sign Up now!']")){82            const regsiterButton = await (driver.findElementByXPath("//*[@text = 'Not have an account Sign Up now!']"));83            await regsiterButton.click();84        }85        // Regsiter86        const registerFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);87        await registerFields[0].click().sendKeys(restaurantName);88        await driver.driver.hideDeviceKeyboard("Done");89        const dropdown = await driver.findElementByXPath("//android.widget.TextView[@index=0]");90        await dropdown.click();91        const currencyLabel = await driver.findElementByText(currencyLabelElement);92        await currencyLabel.click();93        await registerFields[1].click().sendKeys(firstName);94        await registerFields[2].click().sendKeys(lastName);95        await registerFields[3].click().sendKeys(username);96        await registerFields[4].click().sendKeys(password);97        await driver.driver.hideDeviceKeyboard("Done");98        await registerFields[5].click().sendKeys(password);99        await driver.driver.hideDeviceKeyboard("Done");100        const registButton = await driver.findElementByClassName(driver.locators.button);101        await registButton.click();102        driver.wait("3000");103        const errorMessage = await driver.findElementByClassName(driver.locators.getElementByName("htmlview"));104        assert.isTrue(await errorMessage.exists());105    });106    it("Check login to the restaurant app with valid data.", async function () {107        console.log('========= Log-in username : ', username)108        console.log('========= Log-in password : ', password)109        const backToLogin = await driver.findElementByXPath("//*[@text = 'Back to Login']");110        await backToLogin.click();111        if (isAndroid) {112            var userNameLabelElement = "[@text='User Name/Email']";113        } else {114            var loginButtonElement = "[@name='LOGIN']";115            var userNameLabelElement = "[@name='User Name/Email']";116        }117        if (isAndroid) {118            const allFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);119            await allFields[1].click().sendKeys(password);120            await allFields[0].click().sendKeys(username);121        } else {122            const passField = await driver.driver.waitForElementByClassName(driver.locators.getElementByName("securetextfield"), 10000);123            await passField.click().sendKeys(password);124            const usernameField = await driver.driver.waitForElementByClassName(driver.locators.getElementByName("textfield"), 10000);125            await usernameField.click().sendKeys(username);126        }127        await driver.driver.hideDeviceKeyboard("Done");128        if (isAndroid) {129            const logInButton = await driver.findElementByClassName(driver.locators.button);130            await logInButton.click();131        } else {132            const logInButton = await driver.findElementByXPath("//" + driver.locators.button + loginButtonElement);133            await logInButton.click();134        }135        driver.wait(3000);136        const menuImage = await driver.findElementByClassName("android.widget.ImageView");137        await menuImage.click();138        const myInfo = await driver.findElementByXPath("//" + driver.locators.getElementByName("label") + "[@text='My Info']");139        await myInfo.click();140        const usernameLabel = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);141        const usernameText = await usernameLabel[2].text();142        expect(usernameText).to.equal(username, "Not logged with the same user");143    });144    it("Check login to the restaurant app with invalid data.", async function () {145        // console.log('========= Log-in username : ', username)146        // console.log('========= Log-in password : ', password)147        const backToLogin = await driver.findElementByXPath("//*[@text = 'Back to Login']");148        await backToLogin.click();149        const testPassword = '!qazxsw2';150        const testUsername = 'ofbiztest02@gmail.com';151        if (isAndroid) {152            var userNameLabelElement = "[@text='User Name/Email']";153        } else {154            var loginButtonElement = "[@name='LOGIN']";155            var userNameLabelElement = "[@name='User Name/Email']";156        }157        if (isAndroid) {158            const allFields = await driver.driver.waitForElementsByClassName(driver.locators.getElementByName("textfield"), 10000);159            await allFields[1].click().sendKeys(testPassword);160            await allFields[0].click().sendKeys(testUsername);161        } else {162            const passField = await driver.driver.waitForElementByClassName(driver.locators.getElementByName("securetextfield"), 10000);163            await passField.click().sendKeys(testPassword);164            const usernameField = await driver.driver.waitForElementByClassName(driver.locators.getElementByName("textfield"), 10000);165            await usernameField.click().sendKeys(testUsername);166        }167        await driver.driver.hideDeviceKeyboard("Done");168        if (isAndroid) {169            const logInButton = await driver.findElementByClassName(driver.locators.button);170            await logInButton.click();171        } else {172            const logInButton = await driver.findElementByXPath("//" + driver.locators.button + loginButtonElement);173            await logInButton.click();174        }175        /* Fix me : Check with note176        const errorDialog = await driver.findElementByText("Login Error", "contains");177        assert.isTrue(await errorDialog.isDisplayed());*/178    });179    it("Forgot your password function", async function () {180        const forgotPassword = await driver.findElementByXPath("//*[@text = 'Forgot your password?']");181        await forgotPassword.click();182        // Check if dialog is present183        const errorDialog = await driver.findElementByText("Enter the email address you used to register for GrowERP-restaurant to reset your password.", "contains");184        assert.isTrue(await errorDialog.isDisplayed());185    });...app.e2e-spec.js
Source:app.e2e-spec.js  
1const nsAppium = require('nativescript-dev-appium')2const {3  clickOnSaveWallet,4  clickOnAddWalletFromHomePage,5  clickToMarketFromHomePage,6  setInvestmentInput,7  clickOnBackButton,8  setBalanceOrAddressInput,9  clickOnCoinItem,10  clickOnDeleteButtonFormFormPage,11  clickOnCloseAd12} = require('./utils.js')13const EMPTY_WALLET_LIST_MESSAGE = 'Empty wallet list'14describe('MVP scenarios', () => {15  let driver16  beforeAll(async () => {17    jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000018    driver = await nsAppium.createDriver()19  })20  afterAll(async () => {21    await driver.quit()22    console.log('Quit driver!')23  })24  afterEach(async function() {25    await driver.logTestArtifacts('failure')26  })27  it('changes USD to EUR', async () => {28    await driver.sleep(2000)29    const usdLabel = await driver.findElementByText('USD', 'contains')30    await usdLabel.click()31    const applyButton = (32      await driver.findElementsByClassName('android.widget.Button')33    )[1]34    await applyButton.click()35    await driver.sleep(2000)36    const label = await driver.findElementByText('EUR', 'contains')37    expect(label.isDisplayed()).toBeTruthy()38  })39  it('shows market view when the user clicks on the market tab', async () => {40    await clickToMarketFromHomePage(driver)41    const labelName = await driver.findElementByText('24h', 'contains')42    expect(labelName.isDisplayed()).toBeTruthy()43  })44  it('shows wallets view when the user clicks on the wallet tab', async () => {45    await clickToMarketFromHomePage(driver)46    const walletsTab = await driver.findElementByAutomationText('Wallets')47    await walletsTab.click()48    await driver.sleep(1000)49    const label = await driver.findElementByText(50      EMPTY_WALLET_LIST_MESSAGE,51      'contains'52    )53    expect(label.isDisplayed()).toBeTruthy()54  })55  it('shows coins page when the user click on add button', async () => {56    await clickOnAddWalletFromHomePage(driver)57    const label = await driver.findElementByText('Select your coin', 'contains')58    expect(label.isDisplayed()).toBeTruthy()59  })60  it('shows wallet page with the bitcoin coin', async () => {61    await clickOnCoinItem(driver, 'Bitcoin')62    const title = await driver.findElementByText('Edit Wallet', 'contains')63    expect(title.isDisplayed()).toBeTruthy()64    const bitcoinLabel = await driver.findElementByText('Bitcoin', 'contains')65    expect(bitcoinLabel.isDisplayed()).toBeTruthy()66  })67  it('goes to home page when the user clicks two times on back button', async () => {68    await clickOnBackButton(driver)69    await clickOnBackButton(driver)70    const label = await driver.findElementByText(71      EMPTY_WALLET_LIST_MESSAGE,72      'contains'73    )74    expect(label.isDisplayed()).toBeTruthy()75  })76  it('adds a bitcoin wallet', async () => {77    await clickOnAddWalletFromHomePage(driver)78    await clickOnCoinItem(driver, 'Bitcoin')79    await setBalanceOrAddressInput(driver, 7.4)80    await clickOnSaveWallet(driver)81    const label = await driver.findElementByText('7.4 BTC', 'contains')82    expect(label.isDisplayed()).toBeTruthy()83  })84  it('updates a bitcoin wallet', async () => {85    await driver.sleep(1000)86    await clickOnCoinItem(driver, 'Bitcoin')87    await setBalanceOrAddressInput(driver, 3.4)88    await clickOnSaveWallet(driver)89    const label = await driver.findElementByText('3.4 BTC', 'contains')90    expect(label.isDisplayed()).toBeTruthy()91  })92  it('add EOS wallet by connecting it', async () => {93    await driver.sleep(1000)94    await clickOnAddWalletFromHomePage(driver)95    const searchInput = await driver.findElementByClassName(96      'android.widget.EditText'97    )98    await searchInput.type('EO')99    await clickOnCoinItem(driver, 'EOS')100    const connectedWalletButton = await driver.findElementByAutomationText(101      'tappable-label'102    )103    await connectedWalletButton.click()104    // without sleeping, sometimes balanceInput does not fond105    await driver.sleep(1000)106    await setBalanceOrAddressInput(driver, 'gi3tmnzsgqge')107    await clickOnSaveWallet(driver)108    // without sleeping, sometimes EOS text is not found109    await driver.sleep(1000)110    const label = await driver.findElementByText('EOS', 'contains')111    expect(label.isDisplayed()).toBeTruthy()112  })113  it('updates EOS wallet by adding investment', async () => {114    await clickOnCoinItem(driver, 'EOS')115    await setInvestmentInput(driver, 986)116    await clickOnSaveWallet(driver)117    // without sleeping, sometimes EOS text is not found118    await driver.sleep(1000)119    const label = await driver.findElementByText('986', 'contains')120    expect(label.isDisplayed()).toBeTruthy()121  })122  it('navigates to analyses pages', async () => {123    const analysisButton = await driver.findElementByAutomationText(124      'analysis-button'125    )126    await analysisButton.click()127    const walletsTab = await driver.findElementByAutomationText(128      'Wallet Profits'129    )130    await walletsTab.click()131    await clickOnBackButton(driver)132    await driver.sleep(1000)133    const label = await driver.findElementByText('986', 'contains')134    expect(label.isDisplayed()).toBeTruthy()135  })136  it('removes EOS wallet when user clicked on delete', async () => {137    await clickOnCoinItem(driver, 'EOS')138    await clickOnDeleteButtonFormFormPage(driver)139    const wallets = await driver.findElementsByAutomationText(140      'wallet-item',141      'contains'142    )143    const btcLabel = await driver.findElementByText('3.4 BTC', 'contains')144    expect(wallets.length).toEqual(1)145    expect(btcLabel.isDisplayed()).toBeTruthy()146  })147  it('does not navigate to home page when user adds a negative balance and negative investment', async () => {148    await clickOnAddWalletFromHomePage(driver)149    const searchInput = await driver.findElementByClassName(150      'android.widget.EditText'151    )152    await searchInput.type('XR')153    await clickOnCoinItem(driver, 'XRP')154    await setBalanceOrAddressInput(driver, -7.4)155    await setInvestmentInput(driver, -100)156    await clickOnSaveWallet(driver)157    await driver.sleep(1000)158    const label = await driver.findElementByText('Save Wallet', 'contains')159    expect(label.isDisplayed()).toBeTruthy()160  })...utils.js
Source:utils.js  
1async function clickOnAddWalletFromHomePage(driver) {2  const addWalletButton = await driver.findElementByAutomationText(3    'add-wallet-button'4  )5  await addWalletButton.click()6}7async function clickToMarketFromHomePage(driver) {8  const marketTab = await driver.findElementByAutomationText('Market')9  await marketTab.click()10}11async function clickOnBackButton(driver) {12  // automation text does not work13  //let backButton = await driver.findElementByAutomationText('back-button')14  const backButton = await driver.findElementByClassName(15    'android.widget.ImageButton'16  )17  await backButton.click()18}19async function clickOnCoinItem(driver, coinName) {20  const bitcoinLabel = await driver.findElementByText(coinName, 'contains')21  await bitcoinLabel.click()22}23async function clickOnDeleteButtonFormFormPage(driver) {24  const moreOptions = await driver.findElementByAutomationText('More options')25  await moreOptions.click()26  const deleteButton = await driver.findElementByText('Delete', 'contains')27  await deleteButton.click()28}29async function setBalanceOrAddressInput(driver, value) {30  const balanceInput = (31    await driver.findElementsByAutomationText('text-field')32  )[1]33  await balanceInput.click()34  await balanceInput.type(value)35  await driver.hideDeviceKeyboard()36}37async function setInvestmentInput(driver, value) {38  const balanceInput = (39    await driver.findElementsByAutomationText('text-field')40  )[0]41  await balanceInput.click()42  await balanceInput.type(value)43  await driver.hideDeviceKeyboard()44}45async function setTargetPriceInput(driver, value) {46  const targetPrice = (47    await driver.findElementsByAutomationText('text-field')48  )[0]49  await targetPrice.click()50  await targetPrice.type(value)51  await driver.hideDeviceKeyboard()52}53async function setNotePriceInput(driver, value) {54  const targetPrice = (55    await driver.findElementsByAutomationText('text-field')56  )[1]57  await targetPrice.click()58  await targetPrice.type(value)59  await driver.hideDeviceKeyboard()60}61async function clickOnSaveWallet(driver) {62  const saveButton = await driver.findElementByAutomationText('save-button')63  await saveButton.click()64}65async function clickOnCloseAd(driver) {66  const closeAdButton = await driver.findElementByClassName(67    'android.widget.ImageButton'68  )69  await closeAdButton.click()70}71exports.clickOnSaveWallet = clickOnSaveWallet72exports.clickOnAddWalletFromHomePage = clickOnAddWalletFromHomePage73exports.clickToMarketFromHomePage = clickToMarketFromHomePage74exports.setInvestmentInput = setInvestmentInput75exports.clickOnBackButton = clickOnBackButton76exports.setBalanceOrAddressInput = setBalanceOrAddressInput77exports.clickOnCoinItem = clickOnCoinItem78exports.clickOnCloseAd = clickOnCloseAd79exports.setTargetPriceInput = setTargetPriceInput80exports.setNotePriceInput = setNotePriceInput...button.js
Source:button.js  
1const chai = require("chai");2const nsAppium = require("nativescript-dev-appium");3const examples = require("./examples");4describe("button scenarios", () => {5    const button = examples.examples.button;6    let driver;7    let index = 0;8    let example;9    before(async () => {10        driver = await nsAppium.createDriver();11        const mainPageBtn = await driver.findElementByText(button.baseExampleName);12        await mainPageBtn.click();13    });14    beforeEach(async () => {15        example = button.examples[index];16        const btnTap = await driver.findElementByText(example);17        await btnTap.click();18        index++;19    });20    afterEach(async function () {21        if (this.currentTest.state === "failed") {22            await driver.logTestArtifacts(this.currentTest.title);23        }24        await driver.navBack();25    });26    after(async () => {27        await driver.navBack();28    })29    const findButton = async () => {30        const btn = await driver.findElementByClassName(driver.locators.button);31        return btn;32    }33    it(`Basics`, async () => {34        const btn = await findButton();35        await btn.click();36        await btn.click();37        await btn.click();38        const text = 'TAPPED 3 TIMES';39        const btnText = await btn.text();40        chai.assert.isTrue(text === btnText);41    });42    it(`Code-Behind`, async () => {43        const btn = await findButton();44        await btn.click();45        const text = 'My newly created button';46        const dialog = await driver.findElementByText(text, "contains");47        chai.assert.isTrue(await dialog.isDisplayed());48        await (await driver.findElementByText("OK", "contains")).tapCenter();49        50    });51    it(`Styling`, async () => {52        const btn = await findButton();53        await btn.click();54        await btn.click();55        const text = 'TAP ME!';56        const btnText = await btn.text();57        chai.assert.isTrue(btnText.includes(text));58    });...activity-indicator.js
Source:activity-indicator.js  
1const chai = require("chai");2const nsAppium = require("nativescript-dev-appium");3const examples = require("./examples");4describe("activity indicator scenarios", () => {5    const activityIndicator = examples.examples.activityIndicator;6    let driver;7    let index = 0;8    let example;9    before(async () => {10        driver = await nsAppium.createDriver();11        const mainPageBtn = await driver.findElementByText(activityIndicator.baseExampleName);12        await mainPageBtn.click();13    });14    beforeEach(async () => {15        example = activityIndicator.examples[index];16        const btnTap = await driver.findElementByText(example);17        await btnTap.click();18        index++;19    });20    afterEach(async function () {21        if (this.currentTest.state === "failed") {22            await driver.logTestArtifacts(this.currentTest.title);23        }24        await driver.navBack();25    });26    after(async () => {27        await driver.navBack();28    })29    const findActivityIndicator = async () => {30        const test = driver.locators.activityIndicator || driver.locators.activityindicator;31        const act = await driver.findElementByClassName(test);32        return act;33    }34    it(`Basics`, async () => {35        const activityIndicatorElement = await findActivityIndicator();36        chai.assert.isTrue(await activityIndicatorElement.isDisplayed(), `ActivitiIndicator is not visible!`);37    });38    it(`Code-Behind`, async () => {39        const activityIndicatorElement = await findActivityIndicator();40        chai.assert.isTrue(await activityIndicatorElement.isDisplayed(), `ActivitiIndicator is not visible!`);41    });42    it(`Styling`, async () => {43        const activityIndicatorElement = await findActivityIndicator();44        chai.assert.isTrue(await activityIndicatorElement.isDisplayed(), `ActivitiIndicator is not visible!`);45    });...smoke-tests.js
Source:smoke-tests.js  
1const nsAppium = require("nativescript-dev-appium");2const assert = require("chai").assert;3describe("smoke tests", async function () {4    let driver;5    before(async function () {6        nsAppium.nsCapabilities.testReporter.context = this;7        driver = await nsAppium.createDriver();8    });9    after(async function () {10        await driver.quit();11        console.log("Quit driver!");12    });13    afterEach(async function () {14        if (this.currentTest.state === "failed") {15            await driver.logTestArtifacts(this.currentTest.title);16        }17    });18    it("assert console log", async function () {19        const btnTap = await driver.findElementByClassName(driver.locators.button);20        assert.isTrue(await btnTap.isDisplayed(), "App is not running");21        await btnTap.tap();22        await driver.sleep(2000);23        const logs = await driver.getlog("logcat");24        let containsJobExecutions = false;25        let containsJobScheduled = false;26        logs.forEach(log => {27            if (/Job Scheduled: 1/mig.test(log.message)) {28                containsJobScheduled = true;29            }30            if (/Job Execution/igm.test(log.message)) {31                containsJobExecutions = true;32            }33        });34        assert.isTrue(containsJobScheduled, "Not found: Job Scheduled: 1");35        assert.isTrue(containsJobExecutions, "Not found: Job execution");36    });...Using AI Code Generation
1var webdriver = require('selenium-webdriver'),2    until = webdriver.until;3var driver = new webdriver.Builder()4    .forBrowser('chrome')5    .build();6driver.findElement(By.name('q')).sendKeys('webdriver');7driver.findElement(By.name('btnG')).click();8driver.wait(until.titleIs('webdriver - Google Search'), 1000);9driver.quit();10var webdriver = require('selenium-webdriver'),11    until = webdriver.until;12var driver = new webdriver.Builder()13    .forBrowser('chrome')14    .build();15driver.findElement(By.name('q')).sendKeys('webdriver');16driver.findElement(By.name('btnG')).click();17driver.wait(until.titleIs('webdriver - Google Search'), 1000);18driver.quit();19var webdriver = require('selenium-webdriver'),20    until = webdriver.until;21var driver = new webdriver.Builder()22    .forBrowser('chrome')23    .build();24driver.findElement(By.name('q')).sendKeys('webdriver');25driver.findElement(By.name('btnG')).click();26driver.wait(until.titleIs('webdriver - Google Search'), 1000);27driver.quit();28var webdriver = require('selenium-webdriver'),29    until = webdriver.until;30var driver = new webdriver.Builder()31    .forBrowser('chrome')32    .build();33driver.findElement(By.name('q')).sendKeys('webdriver');34driver.findElement(By.name('btnG')).click();35driver.wait(until.titleIs('webdriver - Google Search'), 1000);36driver.quit();37var webdriver = require('selenium-webdriver'),38    until = webdriver.until;39var driver = new webdriver.Builder()40    .forBrowser('chrome')41    .build();42driver.findElement(By.name('q')).sendKeys('webdriver');43driver.findElement(By.nameUsing AI Code Generation
1var webdriver = require('selenium-webdriver');2   build();3driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');4driver.findElement(webdriver.By.name('btnG')).click();5driver.wait(function() {6   return driver.getTitle().then(function(title) {7     return title === 'webdriver - Google Search';8   });9}, 1000);10driver.quit();11var webdriver = require('selenium-webdriver');12   build();13driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');14driver.findElement(webdriver.By.name('btnG')).click();15driver.wait(function() {16   return driver.getTitle().then(function(title) {17     return title === 'webdriver - Google Search';18   });19}, 1000);20driver.quit();21var webdriver = require('selenium-webdriver');22   build();23driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');24driver.findElement(webdriver.By.name('btnG')).click();25driver.wait(function() {26   return driver.getTitle().then(function(title) {27     return title === 'webdriver - Google Search';28   });29}, 1000);30driver.quit();31var webdriver = require('selenium-webdriver');32   build();33driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');34driver.findElement(webdriver.By.name('btnG')).click();35driver.wait(function() {36   return driver.getTitle().then(function(title) {37     return title === 'webdriver - Google Search';38   });39}, 1000);40driver.quit();41var webdriver = require('selenium-webdriver');Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var By = webdriver.By;3var driver = new webdriver.Builder()4   .forBrowser('chrome')5   .build();6driver.findElement(By.className('Using AI Code Generation
1var driver = require('./driver.js');2var webdriver = require('selenium-webdriver');3var By = webdriver.By;4var until = webdriver.until;5var driver = new webdriver.Builder()6   .forBrowser('chrome')7   .build();8driver.findElement(By.name('q')).sendKeys('webdriver');9driver.findElement(By.name('btnG')).click();10driver.wait(until.titleIs('webdriver - Google Search'), 1000);11driver.quit();12var webdriver = require('selenium-webdriver');13var By = webdriver.By;14var until = webdriver.until;15var driver = new webdriver.Builder()16   .forBrowser('chrome')17   .build();18driver.findElement(By.name('q')).sendKeys('webdriver');19driver.findElement(By.name('btnG')).click();20driver.wait(until.titleIs('webdriver - Google Search'), 1000);21driver.quit();22var driver = require('./driver.js');23let driver = new webdriver.Builder()24SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode25Your name to display (optional):26Your name to display (optional):Using AI Code Generation
1var wd = require('wd'),2    assert = require('assert'),3    _ = require('underscore'),4    fs = require('fs'),5    path = require('path');6var desiredCaps = {7    app: path.resolve(__dirname, "app-debug.apk"),8};9var driver = wd.promiseChainRemote("localhost", 4723);10    .init(desiredCaps)11    .then(function() {12        return driver.sleep(10000);13    })14    .then(function() {15        return driver.findElementByClassName("android.widget.Button");16    })17    .then(function(element) {18        return element.click();19    })20    .then(function() {21        return driver.sleep(10000);22    })23    .fin(function() {24        return driver.quit();25    })26    .done();Using AI Code Generation
1package test;2import io.appium.java_client.android.AndroidDriver;3import io.appium.java_client.android.AndroidElement;4import java.net.MalformedURLException;5import java.net.URL;6import org.openqa.selenium.remote.DesiredCapabilities;7public class Test {8	public static void main(String[] args) throws MalformedURLException, InterruptedException {9		DesiredCapabilities cap = new DesiredCapabilities();10		cap.setCapability("deviceName", "Android");11		cap.setCapability("platformName", "Android");12		cap.setCapability("platformVersion", "5.0.2");13		cap.setCapability("appPackage", "com.android.calculator2");14		cap.setCapability("appActivity", "com.android.calculator2.Calculator");Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
