當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript AppiumDriver.findElementsByClassName方法代碼示例

本文整理匯總了TypeScript中nativescript-dev-appium.AppiumDriver.findElementsByClassName方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AppiumDriver.findElementsByClassName方法的具體用法?TypeScript AppiumDriver.findElementsByClassName怎麽用?TypeScript AppiumDriver.findElementsByClassName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nativescript-dev-appium.AppiumDriver的用法示例。


在下文中一共展示了AppiumDriver.findElementsByClassName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

        it("Reorder items and verify listview", async () => {
            let listView;
            let value;
            const listItem = await driver.findElementByText("Gwen Peters", SearchOptions.exact);
            expect(listItem).to.exist;
            // await listItem.drag(Direction.down, 600, 0);
            if (isAndroid) {
                const wd = driver.wd();
                const action = new wd.TouchAction(driver.driver);
                action.longPress({ x: 200, y: 200 })
                    .wait(2000)
                    .moveTo({ x: 200, y: 400 })
                    .release();
                await action.perform();
                listView = await driver.findElementsByClassName("android.widget.TextView");
                value = await listView[1].text();
                expect(value).to.equal("George Cook");
            }
            else {
                await driver.driver.execute('mobile: dragFromToForDuration', {
                    duration: 2.0,
                    fromX: 100,
                    fromY: 105,
                    toX: 100,
                    toY: 242
                });
                listView = await driver.findElementsByClassName("XCUIElementTypeStaticText");
                value = await listView[1].getAttribute("value");
                let element = await driver.findElementByText("George Cook");
                expect(element).to.exist;
                // TODO: Add assertion for listview items
            }

        });
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:34,代碼來源:tests2.e2e.ts

示例2: it

 it("should add element in the list", async () => {
     const addField = await driver.findElementByClassName(driver.locators.getElementByName("textfield"));
     await addField.sendKeys(fruit);
     const allImages = await driver.findElementsByClassName(driver.locators.image); // First image is the menu, second is the cross adding to the list.
     await allImages[1].click(); // Cross image button to add the item.
     const appleItem = await driver.findElementByText(fruit);
     expect(appleItem).to.exist;
 });
開發者ID:tjvantoll,項目名稱:sample-Groceries,代碼行數:8,代碼來源:groceries.e2e.ts

示例3: async

 const clickOnCrossOrCheckboxBtn = async () => {
     if (isAndroid) {
         // First image is the menu, second is the cross button. The rest are pairs checkbox/bin per list item.
         const allImages = await driver.findElementsByClassName(driver.locators.image);
         await allImages[2].click(); // Checkbox button
     } else {
         await driver.clickPoint(26, 160); // Checkbox button
     }
 };
開發者ID:tjvantoll,項目名稱:sample-Groceries,代碼行數:9,代碼來源:groceries.e2e.ts

示例4: it

        it("Verify validation of components", async () => {
            let fields;
            let username;
            let password;
            let email;
            let phone;
            let pin;
            if (isAndroid) {
                fields = await driver.findElementsByClassName("android.widget.EditText");
                username = fields[0];
                password = fields[1];
                email = fields[2];
                phone = fields[4];
                pin = fields[5];
            }
            else {
                fields = await driver.findElementsByClassName("TextField");
                password = await driver.findElementByClassName("SecureTextField");
                username = fields[0];
                email = fields[1];
                phone = fields[3];
                pin = fields[4];
            }

            await username.click();
            await username.sendKeys("usernamevalidation");
            if (isAndroid) {
                await driver.driver.hideDeviceKeyboard("Done");
            }
            const userNameValidation = await driver.findElementByText("Username can be at most 12 characters.", SearchOptions.exact);
            expect(userNameValidation).to.exist;

            await password.click();
            await password.sendKeys("pass");
            if (isAndroid) {
                await driver.driver.hideDeviceKeyboard("Done");
            }
            const passwordValidation = await driver.findElementByText("Password must be at least 6 characters long.", SearchOptions.exact);
            expect(passwordValidation).to.exist;

            await email.click();
            await email.sendKeys("email");
            let emailValidation;
            if (isAndroid) {
                await driver.driver.hideDeviceKeyboard("Done");
                emailValidation = await driver.findElementByText("This email is invalid.", SearchOptions.exact);
            }
            else {
                emailValidation = await driver.findElementByText("Incorrect e-mail!", SearchOptions.exact);
            }
            expect(emailValidation).to.exist;

            if (!isAndroid) {
                await phone.sendKeys("08");
                const phoneValidation = await driver.findElementByText("Incorrect phone number", SearchOptions.exact);
                expect(phoneValidation).to.exist;


                await pin.sendKeys("00");
                const pinValidation = await driver.findElementByText("PIN number should contain 4 digits.", SearchOptions.exact);
                expect(pinValidation).to.exist;
            }

            let switchButton;
            let switchValidation;

            if (isAndroid) {
                switchButton = await driver.findElementByClassName("android.widget.Switch");
                await switchButton.click();
                await switchButton.click();
                const wd = driver.wd();
                const action = new wd.TouchAction(driver.driver);
                action.press({ x: 52, y: 700 })
                    .moveTo({ x: 52, y: 100 })
                    .release();
                await action.perform();
                switchValidation = await driver.findElementByText("You must agree with the terms.", SearchOptions.exact);
            }
            else {
                switchButton = await driver.findElementByClassName("Switch");
                await switchButton.click();
                await switchButton.click();
                switchValidation = await driver.findElementByText("You must agree with the terms.", SearchOptions.exact);
                expect(switchValidation).to.exist;
            }
        });
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:86,代碼來源:test.e2e.ts


注:本文中的nativescript-dev-appium.AppiumDriver.findElementsByClassName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。