本文整理汇总了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;
}
示例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;
});
示例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);
});
示例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;
}
示例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;
});
示例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");
});
示例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;
});
示例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;
});