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


TypeScript AppiumDriver.findElementByClassName方法代碼示例

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


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

示例1: scrollToElement

export async function scrollToElement(driver: AppiumDriver, element: string, direction: Direction = Direction.down) {
    let listView;
    if (isAndroid) {
        listView = await driver.findElementByClassName("android.widget.FrameLayout");
    }
    else {
        listView = await driver.findElementByClassName("XCUIElementTypeCollectionView");
    }
    const listItem = await listView.scrollTo(
        direction,
        () => driver.findElementByText(element, SearchOptions.contains),
        600
    );
    return listItem;
}
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:15,代碼來源:helper.ts

示例2: it

 it("Scroll listview to verify more elements are present", async () => {
     let listView;
     if (isAndroid) {
         listView = await driver.findElementByClassName("android.widget.FrameLayout");
     }
     else {
         listView = await driver.findElementByClassName("XCUIElementTypeCollectionView");
     }
     const listItem = await listView.scrollTo(
         Direction.down,
         () => driver.findElementByText("Creme Caramel", SearchOptions.exact),
         600
     );
     expect(listItem).to.exist;
 });
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:15,代碼來源:tests.e2e.ts

示例3: it

        it("should open 'Switch at runtime' view", async () => {
            await navigateBackToHome(driver);
            const tokenLayoutsButton = await driver.findElementByText(tokenLayoutsText);
            await tokenLayoutsButton.click();
            await driver.wait(1000);
            const tokenLayoutsTitle = await driver.findElementByText(tokenLayoutsText);
            expect(tokenLayoutsTitle).to.exist;

            const runtimeSwitchButton = await driver.findElementByText("Switch at runtime");
            await runtimeSwitchButton.click();
            await driver.wait(1000);
            const textField = await driver.findElementByClassName(driver.locators.getElementByName("textfield"));
            await textField.click();
            const addNextTokenButton = await driver.findElementByText("Add next token");
            for (let i = 0; i < 5; i++) {
                await addNextTokenButton.click();
            }
            const australiaToken = await driver.findElementByText("Australia");
            expect((await australiaToken.location()).x).to.be.least(0);

            const horizontalButton = await driver.findElementByText("Horizontal");
            await horizontalButton.click();
            const australiaTokenHorizontal = await driver.findElementByTextIfExists("Australia");
            expect((await australiaTokenHorizontal.location()).x).to.be.lessThan(0);
        });
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:25,代碼來源:tests.e2e.ts

示例4: swipeToElement

export async function swipeToElement(driver: AppiumDriver, element: string, direction: Direction = Direction.down) {
    let listView;
    if (isAndroid) {
        listView = await driver.findElementByClassName("android.widget.FrameLayout");
    }
    else {
        listView = await driver.findElementByClassName("XCUIElementTypeCollectionView");
    }

    let item = await driver.findElementByTextIfExists(element, SearchOptions.exact);
    while (item === undefined) {
        await listView.swipe(direction);
        await driver.wait(500);
        item = await driver.findElementByTextIfExists(element, SearchOptions.exact);
    }
    return item;
}
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:17,代碼來源:helper.ts

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

示例6: it

    it("should find an element by type", async () => {
        const btnTap = await driver.findElementByClassName(driver.locators.button);
        await btnTap.click();

        const message = " taps left";
        const lblMessage = await driver.findElementByText(message, SearchOptions.contains);
        expect(await lblMessage.text()).toContain("40");
    });
開發者ID:NativeScript,項目名稱:nativescript-dev-appium,代碼行數:8,代碼來源:typescript.jasmine.sample.e2e-spec.ts

示例7: it

 it("Scroll and verify event is fired", async () => {
     const locator = isAndroid ? "android.widget.FrameLayout" : "XCUIElementTypeCollectionView";
     const listView = await driver.findElementByClassName(locator);
     const listItem = await listView.scrollTo(
         Direction.down,
         () => driver.findElementByText("Item 20", SearchOptions.exact),
         700
     );
     const scrollStateLabel = await driver.findElementByText("ended with offset:", SearchOptions.contains);
     expect(scrollStateLabel).to.exist;
 });
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:11,代碼來源:tests3.e2e.ts

示例8: it

 it("Verify on Lost focus mode", async () => {
     const lostFocusTab = await driver.findElementByText("lost focus");
     await lostFocusTab.click();
     const username = await driver.findElementByClassName(driver.locators.getElementByName("textfield"));
     await username.sendKeys(" stark");
     try {
         await driver.driver.hideDeviceKeyboard();
     } catch (error) {
     }
     let result = await driver.findElementByText('"username":"tony"', SearchOptions.contains);
     expect(result).to.exist;
     const pass = await driver.findElementByText("Password");
     await pass.click();
     result = await driver.findElementByText('"username":"tony stark"', SearchOptions.contains);
     expect(result).to.exist;
 });
開發者ID:telerik,項目名稱:nativescript-ui-samples-angular,代碼行數:16,代碼來源:test.e2e.ts


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