verdnatura-chat/appium/tests/helpers/index.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-04-08 19:43:13 +00:00
const { expect } = require('chai');
export const launchApp = async () => await driver.launchApp();
export const setValue = async (tag, value) => await $(`~${tag}`).setValue(`${value}`);
export const getText = async tag => await $(`~${tag}`).getText();
2022-04-08 21:19:28 +00:00
export const equal = async (value, text) => expect(value).to.equal(prop);
export const click = async tag => await $(`~${tag}`).click();
2022-04-28 20:11:04 +00:00
export const clickById = async tag => await $(`id=${tag}`).click();
2022-04-08 19:43:13 +00:00
2022-05-05 18:11:38 +00:00
export const isAndroid = () => driver.capabilities.platformName === 'Android';
2022-04-28 20:14:46 +00:00
2022-05-05 18:11:38 +00:00
export const openDrawer = async () => {
if (isAndroid()) {
await $('//android.view.ViewGroup[@content-desc="rooms-list-view-sidebar"]/android.widget.TextView').click(); //TEMP
} else {
await $('[name="rooms-list-view-sidebar"]').click();
}
};
export const clickAlert = async tag => {
if (isAndroid()) {
await clickById('android:id/button1');
} else {
await $(`[name="${tag}"]`).click();
}
};
2022-04-28 20:14:46 +00:00
2022-04-08 19:43:13 +00:00
export const setValueAndEnter = async (tag, value) => {
2022-05-05 18:11:38 +00:00
if (isAndroid()) {
2022-04-08 19:43:13 +00:00
await $(`~${tag}`).click();
await $(`~${tag}`).setValue(value);
await $(`~${tag}`).pressKeyCode(66);
} else {
2022-05-05 18:11:38 +00:00
await $(`~${tag}`).setValue(`${value}\n`);
2022-04-08 19:43:13 +00:00
}
};