本文整理匯總了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;
});