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