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