Answer the question
In order to leave comments, you need to log in
How to properly work with asynchrony in selenium for javascript?
Killed a lot of time for tests. Either I have a problem with understanding asynchrony, or one of the two.
Please tell me a working pattern in js.
const isVisible = (element) => browser.wait(until.elementIsVisible(element), 20000);
// async function isVisible(element) {
// await browser.wait(until.elementIsVisible(element), 20000);
//}
async function loadingProcess() {
const loading = await browser.wait(until.elementLocated(By.xpath("//div[@id='loading']")), 20000);
await browser.wait(until.elementIsNotVisible(loading), 20000);
}
await browser.get(myURL);
// тарам-парам-пам
const loginBtn = await browser.wait(until.elementLocated(By.id('login')), 20000).then(isVisible);
loginBtn.click();
await loadingProcess();
await browser.wait(until.elementLocated(By.linkText('Websites')), 20000).then(isVisible).then(btn => btn.click());
await browser.wait(until.elementLocated(By.xpath("//input[contains(@class, 'textbox')]/../../td[2]/a")), 20000).then(isVisible).then(btn => btn.click());
await loadingProcess();
await browser.wait(until.elementLocated(By.xpath('//a[text()=" Create directory"]')), 20000).then(isVisible).then(btn => btn.click());
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question