Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
waitFor(element(by.id("UniqueId204"))).whileElement("someID");
waitFor(element(by.id("UniqueId204"))).whileElement(by.id("ScrollView630"));
// $ExpectError
waitFor(element(by.id("UniqueId204"))).withTimeout(false);
waitFor(element(by.id("UniqueId204"))).withTimeout(1000);
// Example tests
const e2e = {
NATIVE_BUTTON: "NATIVE_BUTTON",
WELCOME_VIEW: "WELCOME_VIEW"
};
const welcome = element(by.id(e2e.WELCOME_VIEW));
expect(welcome).toBeVisible();
const welcome_text = "Shake your phone to open the developer menu.";
expect(element(by.text(welcome_text))).toBeVisible();
const btn = element(by.id(e2e.NATIVE_BUTTON));
btn.tap();
async function navigateToRegister() {
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000);
await element(by.id('connect-server-button')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).replaceText(data.server);
await element(by.id('new-server-view-button')).tap();
// we're assuming the server don't have login services and the navigation will jump to login
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(60000);
await element(by.id('login-view-register')).tap();
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
}
// await expect(element(by.id('rooms-list-view-search'))).toBeVisible();
await waitFor(element(by.id('rooms-list-view-search'))).toExist().withTimeout(2000);
await element(by.id('rooms-list-view-search')).replaceText('rocket.cat');
await sleep(2000);
await waitFor(element(by.id('rooms-list-view-item-rocket.cat'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('rooms-list-view-item-rocket.cat'))).toBeVisible();
await element(by.id('rooms-list-view-item-rocket.cat')).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(10000);
await expect(element(by.id('room-view'))).toBeVisible();
await waitFor(element(by.text('rocket.cat'))).toBeVisible().withTimeout(60000);
await expect(element(by.text('rocket.cat'))).toBeVisible();
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
await expect(element(by.id('rooms-list-view'))).toBeVisible();
await element(by.id('rooms-list-view-search')).replaceText('');
await sleep(2000);
await waitFor(element(by.id('rooms-list-view-item-rocket.cat'))).toExist().withTimeout(60000);
await expect(element(by.id('rooms-list-view-item-rocket.cat'))).toExist();
});
it('should create private room', async() => {
const room = `private${ data.random }`;
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
await device.reloadReactNative();
await element(by.id('rooms-list-view-create-channel')).tap();
await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000);
await element(by.id('new-message-view-create-channel')).tap();
await waitFor(element(by.id('select-users-view'))).toBeVisible().withTimeout(2000);
await element(by.id('select-users-view-item-rocket.cat')).tap();
await waitFor(element(by.id('selected-user-rocket.cat'))).toBeVisible().withTimeout(5000);
await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toBeVisible().withTimeout(5000);
await element(by.id('create-channel-name')).replaceText(room);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('room-view'))).toBeVisible();
await waitFor(element(by.text(room))).toExist().withTimeout(60000);
await expect(element(by.text(room))).toExist();
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
await element(by.id('rooms-list-view-search')).replaceText(room);
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeVisible().withTimeout(60000);
await expect(element(by.id(`rooms-list-view-item-${ room }`))).toBeVisible();
});
it('should have legal screen', async() => {
await expect(element(by.id('legal-view'))).toBeVisible();
});
await element(by.id('rooms-list-view-search')).replaceText('rocket.cat');
await sleep(2000);
await waitFor(element(by.id('rooms-list-view-item-rocket.cat'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('rooms-list-view-item-rocket.cat'))).toBeVisible();
await element(by.id('rooms-list-view-item-rocket.cat')).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(10000);
await expect(element(by.id('room-view'))).toBeVisible();
await waitFor(element(by.text('rocket.cat'))).toBeVisible().withTimeout(60000);
await expect(element(by.text('rocket.cat'))).toBeVisible();
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
await expect(element(by.id('rooms-list-view'))).toBeVisible();
await element(by.id('rooms-list-view-search')).replaceText('');
await sleep(2000);
await waitFor(element(by.id('rooms-list-view-item-rocket.cat'))).toExist().withTimeout(60000);
await expect(element(by.id('rooms-list-view-item-rocket.cat'))).toExist();
});
async function backToRoomsList() {
await tapBack();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(2000);
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
}
await waitFor(element(by.id('rooms-list-view-search'))).toExist().withTimeout(2000);
await element(by.id('rooms-list-view-search')).replaceText('rocket.cat');
await sleep(2000);
await waitFor(element(by.id('rooms-list-view-item-rocket.cat'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('rooms-list-view-item-rocket.cat'))).toBeVisible();
await element(by.id('rooms-list-view-item-rocket.cat')).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(10000);
await expect(element(by.id('room-view'))).toBeVisible();
await waitFor(element(by.text('rocket.cat'))).toBeVisible().withTimeout(60000);
await expect(element(by.text('rocket.cat'))).toBeVisible();
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
await expect(element(by.id('rooms-list-view'))).toBeVisible();
await element(by.id('rooms-list-view-search')).replaceText('');
await sleep(2000);
await waitFor(element(by.id('rooms-list-view-item-rocket.cat'))).toExist().withTimeout(60000);
await expect(element(by.id('rooms-list-view-item-rocket.cat'))).toExist();
});
async function navigateToRoom() {
await element(by.id('rooms-list-view-search')).replaceText(`private${ data.random }`);
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-private${ data.random }`))).toBeVisible().withTimeout(60000);
await element(by.id(`rooms-list-view-item-private${ data.random }`)).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
}
async function addServer() {
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000);
await element(by.id('connect-server-button')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('new-server-view'))).toBeVisible();
await element(by.id('new-server-view-input')).replaceText(data.server);
await element(by.id('new-server-view-button')).tap();
}