当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript AppiumDriver.wd方法代码示例

本文整理汇总了TypeScript中nativescript-dev-appium.AppiumDriver.wd方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AppiumDriver.wd方法的具体用法?TypeScript AppiumDriver.wd怎么用?TypeScript AppiumDriver.wd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nativescript-dev-appium.AppiumDriver的用法示例。


在下文中一共展示了AppiumDriver.wd方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: swipe

export async function swipe(driver: AppiumDriver, item: any, direction: Direction) {
    const rectangle = await item.getRectangle();
    const centerX = rectangle.x + rectangle.width / 2;
    const centerY = rectangle.y + rectangle.height / 2;
    let swipeX;
    if (direction === Direction.right) {
        const windowSize = await driver.driver.getWindowSize();
        swipeX = windowSize.width - 10;
    } else if (direction === Direction.left) {
        swipeX = 10;
    }

    if (isAndroid) {
        const wd = driver.wd();
        const action = new wd.TouchAction(driver.driver);
        action.press({ x: centerX, y: centerY })
            .wait(200)
            .moveTo({ x: swipeX, y: centerY })
            .release();
        await action.perform();
    }
    else {
        await driver.driver.execute('mobile: dragFromToForDuration', {
            duration: 2.0,
            fromX: centerX,
            fromY: centerY,
            toX: swipeX,
            toY: centerY
        });
    }
}
开发者ID:telerik,项目名称:nativescript-ui-samples-angular,代码行数:31,代码来源:helper.ts

示例2: it

 it("Tap disable btn and verify swipe is disabled", async () => {
     const disableBtn = await driver.findElementByText("DISABLE", SearchOptions.exact);
     await disableBtn.click();
     let item = await driver.findElementByText("Joel Robertson", SearchOptions.exact);
     expect(item).to.exist;
     if (isAndroid) {
         const rectangle = await item.getRectangle();
         const centerX = rectangle.x + rectangle.width / 2;
         const centerY = rectangle.y + rectangle.height / 2;
         const wd = driver.wd();
         const action = new wd.TouchAction(driver.driver);
         action.press({ x: centerX, y: centerY })
             .wait(100)
             .moveTo({ x: 10, y: centerY })
             .release();
         await action.perform();
         const selection = await driver.compareElement(item, "item");
         expect(selection).to.equal(true);
     }
     else {
         await driver.driver.execute('mobile: dragFromToForDuration', {
             duration: 2.0,
             fromX: 150,
             fromY: 150,
             toX: 50,
             toY: 150
         });
         const del = await driver.findElementByTextIfExists("delete", SearchOptions.exact);
         expect(del).to.be.undefined;
     }
 });
开发者ID:telerik,项目名称:nativescript-ui-samples-angular,代码行数:31,代码来源:tests3.e2e.ts

示例3: 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

示例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.wd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。