How to use waitForNavigation method in taiko

Best JavaScript code snippet using taiko

Playwright_Wordpress.js

Source:Playwright_Wordpress.js Github

copy

Full Screen

...33 await page.type('#user_pass', req.body.password1);3435 await Promise.all([36 page.click('#wp-submit'),37 page.waitForNavigation({ waitUntil: 'networkidle' }),38 ]);3940 const isLoginfailed = await page.$('#login_error'). then (res =>!! res);41 if (isLoginfailed) {42 throw new Error('Username wordpress and Password wordpress is incorrect.'); 43 }4445 if (options.conten_static_pages == 'on' || options.template_url_and_url == 'on') {46 await Promise.all([47 page.click('#menu-pages'),48 page.waitForNavigation({ waitUntil: 'networkidle' }),49 ]);5051 const tagTr = await page.evaluate(() => {52 const trs = Array.from(document.querySelectorAll('#the-list tr'))53 return trs.map(tr => tr.outerHTML)54 });5556 // 7. Trong các page tĩnh có nội dung html chưa?57 for (const element of tagTr) {58 let myRegex = /^<tr id="(.*?)"/gm;59 let execId = myRegex.exec(element);60 if (execId) {61 await Promise.all([62 page.click(`#${execId[1]} .row-title`),63 page.waitForNavigation({ waitUntil: 'networkidle' }),64 ]);65 66 let contentDetail = await page.$eval('#content', item => {67 return item.textContent;68 });69 70 let title = await page.$eval('#title', item => {71 return item.value || 'not found title';72 });73 74 this.content.push({75 title: title,76 message: contentDetail ? '<span class="badge badge-success">Successfully </span>' : '<span class="badge badge-danger mr-2">error </span>'77 });7879 let img_and_a = contentDetail.match(/<img.*src=".*?">|<a.*?href=".*?">/gm) || [];8081 img_and_a.forEach(element => {82 if (/<img.*src="\[template_url]\/|<a.*href="\[url]\//gm.exec(element)) {83 this.template_url.push({84 item: element,85 message: '<span class="badge badge-success">Successfully </span>'86 });87 } else {88 this.template_url.push({89 item: element,90 message: '<span class="badge badge-danger mr-2">error </span>'91 });92 }93 });94 95 await page.goBack();96 }97 }98 }99 100 // 10. tên công ty trong phần message của contactform và link có khớp với nhau chưa?101 if (options.match_company_contactform == 'on') {102 await Promise.all([103 page.click(`#toplevel_page_wpcf7`),104 page.waitForNavigation({ waitUntil: 'networkidle' }),105 ]);106 107 await Promise.all([108 page.click(`#the-list .row-title`),109 page.waitForNavigation({ waitUntil: 'networkidle' }),110 ]);111 112 await page.click('#mail-panel-tab')113 let from = await page.$eval('#wpcf7-mail-2-sender', item => {114 return item.value || 'not found from';115 });116 117 let regexFrom = /(.*?)</gm;118 let textFrom = regexFrom.exec(from);119 if (textFrom[1]) {120 let mailBody = await page.$eval('#wpcf7-mail-2-body', item => {121 return item.textContent;122 });123 124 if (mailBody.search(textFrom[1].trim()) == -1) {125 this.fromCompany.message = `<span class="badge badge-danger mr-2">error </span>Can"t get seach ${textFrom[1].trim()} in content`;126 fromCompany.item = from;127 } else {128 this.fromCompany.message = `<span class="badge badge-success">Successfully </span>${textFrom[1].trim()}`;129 this.fromCompany.item = from;130 }131 } else {132 this.fromCompany.message = `<span class="badge badge-danger mr-2">error</span>Can't get from mail`;133 this.fromCompany.item = from;134 }135 }136 137 // message của contactform là tiếng Nhật chưa?138 // Thỉnh thoảng vẫn để tiếng Anh nên hãy chú ý."139 if (options.contactform_msg_JP == 'on') {140 await Promise.all([141 page.click(`#toplevel_page_wpcf7`),142 page.waitForNavigation({ waitUntil: 'networkidle' }),143 ]);144 145 await Promise.all([146 page.click(`#the-list .row-title`),147 page.waitForNavigation({ waitUntil: 'networkidle' }),148 ]);149150 await page.click('#messages-panel-tab');151 const messageJapan = await page.evaluate(() => {152 const list = Array.from(document.querySelectorAll('#messages-panel .description input'));153 return list.map(data => data.value);154 });155 156 messageJapan.forEach(element => {157 if (!element.match(/[ぁ-んァ-ン一-龥]/g)) {158 this.message_jp_and_en.push({159 item: element,160 message: '<span class="badge badge-danger mr-2">error </span>'161 });162 } else {163 this.message_jp_and_en.push({164 item: element,165 message: '<span class="badge badge-success">Successfully </span>'166 });167 }168 });169 }170 171 // 12.Tích hợp contactform có "reCAPTCHA" không?172 if (options.contactform_recapchar == 'on') {173 await Promise.all([174 page.click(`#toplevel_page_wpcf7`),175 page.waitForNavigation({ waitUntil: 'networkidle' }),176 ]);177 178 await Promise.all([179 page.click(`#the-list .row-title`),180 page.waitForNavigation({ waitUntil: 'networkidle' }),181 ]);182183 await Promise.all([184 page.click(`#toplevel_page_wpcf7 ul li:nth-child(4)`),185 page.waitForNavigation({ waitUntil: 'networkidle' }),186 ]);187 188 let recaptcha = await page.$eval('#recaptcha', item => {189 return item.textContent || 'not found recapchar';190 });191 192 if (recaptcha.search(/reCAPTCHA/gm)) {193 this.recapchaData.push({194 message: '<span class="badge badge-success">Successfully </span> reCAPTCHA'195 });196 } else {197 this.recapchaData.push({198 message: '<span class="badge badge-danger mr-2">error </span>'199 });200 }201 }202 203 // 9. Không hiển thị các tag chưa đc phân loại trong nội dung bài viết.204 if (options.unclassified_not_displayed == 'on') {205 await Promise.all([206 page.click(`#menu-posts`),207 page.waitForNavigation({ waitUntil: 'networkidle' }),208 ]);209 210 await Promise.all([211 page.click(`#menu-posts ul li:nth-child(4)`),212 page.waitForNavigation({ waitUntil: 'networkidle' }),213 ]);214 215 const tagTrCategories = await page.evaluate(() => {216 const trs = Array.from(document.querySelectorAll('#the-list tr'))217 return trs.map(tr => tr.textContent)218 });219 220 tagTrCategories.forEach(element => {221 if (element.toLowerCase().search('uncategorized') != -1) {222 this.categories_uncategorized.push({223 item: element,224 message: '<span class="badge badge-danger mr-2">error </span>'225 })226 } ...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

...12 height:800,13 })14 await page.waitForSelector('[data-testid="loginBox"]',{timeout:1500});15 await page.click('[data-testid="userTab"]');16 await page.waitForNavigation();17 await page.type('[data-testid="email"]', 'user@iamneo.ai');18 await page.type('[data-testid="password"]', 'neo');19 await page.click('[data-testid="submitButton"]');20 await page.waitForNavigation();21 await page.waitForSelector('[data-testid="userNavbar"]',{timeout:1500});22 await page.click('[data-testid="userLogoutButton"]');23 await page.waitForNavigation();24 await page.waitForSelector('[data-testid="loginBox"]',{timeout:1500});25 await page.click('[data-testid="adminTab"]');26 await page.type('[data-testid="email', 'admin@iamneo.ai"]');27 await page.type('[data-testid="password"]', 'neo');28 await page.click('[data-testid="submitButton"]');29 await page.waitForNavigation();30 await page.waitForSelector('[data-testid="adminNavbar"]',{timeout:1500});31 await page.click('[data-testid="adminLogoutButton"]');32 await page.waitForNavigation();33 await page.waitForSelector('[data-testid="loginBox"]',{timeout:1500});34 console.log('TESTCASE:test_case6:success');35 }36 catch(e){37 console.log('TESTCASE:test_case6:failure');38 }finally{39 await page.close();40 await browser.close();41 }42 })();43//user workflow testcase44 (async () => {45 const browser = await puppeteer.launch();46 const page = await browser.newPage();47 try {48 await page.goto('https://8081-adfaaffabfbbeffacfefaffeafcdbeeafffede.examlyiopb.examly.io/login');49 await page.goto('https://8081-eebeafbcddaeffffacfefaffeafcdbeeafffede.examlyiopb.examly.io/login');50 await page.setViewport({51 width:1200,52 height:800,53 })54 55 await page.waitForSelector('[data-testid="loginBox"]',{timeout:1500});56 await page.click('[data-testid="userTab"]');57 await page.waitForNavigation();58 await page.type('[data-testid="email"]', 'user@iamneo.ai');59 await page.type('[data-testid="password"]', 'neo');60 await page.click('[data-testid="submitButton"]');61 await page.waitForNavigation();62 await page.waitForSelector('[data-testid="userNavbar"]',{timeout:1500});63 await page.click('[data-testid="userDashboardLink"]');64 await page.waitForNavigation();65 await page.waitForSelector('[data-testid="userDashboard"]',{timeout:1500});66 await page.click('[data-testid="userProfileLink"]');67 await page.waitForNavigation();68 await page.waitForSelector('[data-testid="userProfileBody"]',{timeout:1500});69 await page.click('[data-testid="userBookingLink"]');70 await page.waitForSelector('[data-testid="userBookingBody"]');71 await page.click('[data-testid="userLogoutButton"]');72 await page.waitForNavigation();73 await page.waitForSelector('[data-testid="loginBox"]',{timeout:1500});74 console.log('TESTCASE:test_case7:success');75 } catch(e) {76 console.log('TESTCASE:test_case7:failure');77 }finally{78 await page.close();79 await browser.close();80 }81 })();82//admin workflow testcase83 (async () => {84 const browser = await puppeteer.launch();85 const page = await browser.newPage();86 try {87 await page.goto('https://8081-adfaaffabfbbeffacfefaffeafcdbeeafffede.examlyiopb.examly.io/login');88 await page.goto('https://8081-eebeafbcddaeffffacfefaffeafcdbeeafffede.examlyiopb.examly.io/login');89 await page.setViewport({90 width:1200,91 height:800,92 })93 94 await page.waitForSelector('[data-testid="loginBox"]',{timeout:1500});95 await page.click('[data-testid="adminTab"]');96 await page.waitForNavigation();97 await page.type('[data-testid="email"]', 'admin@iamneo.ai');98 await page.type('[data-testid="password"]', 'neo');99 await page.click('[data-testid="submitButton"]');100 await page.waitForNavigation();101 await page.waitForSelector('[data-testid="adminNavbar"]',{timeout:1500});102 await page.click('[data-testid="adminDashboardLink"]');103 await page.waitForNavigation();104 await page.waitForSelector('[data-testid="adminDashboard"]',{timeout:1500});105 await page.click('[data-testid="adminProfileLink"]');106 await page.waitForNavigation();107 await page.waitForSelector('[data-testid="adminProfile"]',{timeout:1500});108 await page.click('[data-testid="adminBookingLink"]');109 await page.waitForSelector('[data-testid="adminBookings"]');110 await page.click('[data-testid="adminLogoutButton"]');111 await page.waitForNavigation();112 await page.waitForSelector('[data-testid="loginBox"]',{timeout:1500});113 console.log('TESTCASE:test_case8:success');114 } catch(e) {115 console.log('TESTCASE:test_case8:failure');116 }finally{117 await page.close();118 await browser.close();119 }120 })();121//super-admin workflow testcase122 (async () => {123 const browser = await puppeteer.launch();124 const page = await browser.newPage();125 try {126 await page.goto('https://8081-adfaaffabfbbeffacfefaffeafcdbeeafffede.examlyiopb.examly.io/superadmin/login');127 await page.goto('https://8081-eebeafbcddaeffffacfefaffeafcdbeeafffede.examlyiopb.examly.io/superadmin/login');128 await page.setViewport({129 width:1200,130 height:800,131 })132 await page.waitForNavigation();133 await page.waitForSelector('[data-testid="superAdminLoginBox"]',{timeout:1500});134 await page.type('[data-testid="email"]', 'superadmin@iamneo.ai');135 await page.type('[data-testid="password"]', 'neo');136 await page.click('[data-testid="submitButton"]');137 await page.waitForNavigation();138 await page.waitForSelector('[data-testid="superAdminNavbar"]',{timeout:1500});139 await page.click('[data-testid="superAdminDashboardLink"]');140 await page.waitForNavigation();141 await page.waitForSelector('[data-testid="allUserDetails"]',{timeout:1500});142 await page.click('[data-testid="superAdminBookingLink"]');143 await page.waitForNavigation();144 await page.waitForSelector('[data-testid="allAdminDetails"]',{timeout:1500});145 await page.click('[data-testid="adminLogoutButton"]');146 await page.waitForNavigation();147 await page.waitForSelector('[data-testid="superAdminLoginBox"]',{timeout:1500});148 console.log('TESTCASE:test_case9:success');149 } catch(e) {150 console.log('TESTCASE:test_case9:failure');151 }finally{152 await page.close();153 await browser.close();154 }155 })();156 157 //checking Authentication158 (async () => {159 const browser = await puppeteer.launch();160 const page = await browser.newPage();161 162 163 try {164 await page.goto('https://8081-adfaaffabfbbeffacfefaffeafcdbeeafffede.examlyiopb.examly.io/user/dashboard');165 await page.goto('https://8081-eebeafbcddaeffffacfefaffeafcdbeeafffede.examlyiopb.examly.io/user/dashboard');166 await page.setViewport({167 width:1200,168 height:800,169 })170 await page.waitForNavigation();171 await page.waitForSelector('[data-testid="loginBox"]',{timeout:1500});172 console.log('TESTCASE:test_case10:success');173 } catch(e) {174 console.log('TESTCASE:test_case10:failure');175 }finally{176 await page.close();177 await browser.close();178 }...

Full Screen

Full Screen

teste_compra_automatica.js

Source:teste_compra_automatica.js Github

copy

Full Screen

...67 await page.goto('https://www.lojadomecanico.com.br');68 69 // Clica no primeiro produto70 console.log('> Selecionando o primeiro produto...');71 let navigationPromise = page.waitForNavigation();72 await page.click('#js-day-offert .latest-deals-product .product-list li:first-child a', {delay: 100});73 await navigationPromise;7475 // Adiciona mais uma unidade e clica em "comprar"76 console.log('> Adicionando mais uma unidade e clicando em comprar...');77 await page.click('#form-comprar-produto button.plus-product', {delay: 100});78 await page.waitForTimeout(100);79 await page.click('#btn-comprar-product', {delay: 100});80 await page.waitForFunction("document.getElementById('cart-popup-count').innerText > 0")81 await page.waitForTimeout(500);8283 // Vai para o carrinho de compras84 console.log('> Direcionando ao carrinho de compras...');85 await page.goto('https://www.lojadomecanico.com.br/carrinho', {waitUntil: 'domcontentloaded'});86 await page.waitForSelector('a.btn-finalizar-pedido');8788 // Clica em "finalizar pedido"89 navigationPromise = page.waitForNavigation();90 await page.click('a.btn-finalizar-pedido', {delay: 100});91 await navigationPromise;92 93 // Clica no botão "criar conta"94 console.log('> Clicando em "criar conta"...');95 navigationPromise = page.waitForNavigation();96 await page.click('#form-flux-login a:last-child');97 await navigationPromise;9899 // Clica em "criar conta pessoal"100 navigationPromise = page.waitForNavigation();101 await page.click('a.standard-select:first-child');102 await navigationPromise;103104 // Preenche o formulário105 console.log('> Preenchendo formulário de cadastro...');106 await page.type('input#nome', cliente.nome, { delay: 100 });107 await page.type('input#telefone', cliente.telefone, { delay: 100 });108 await page.type('input#email', cliente.email, { delay: 100 });109 await page.type('input#password', cliente.senha, { delay: 100 });110 111 // Clica no botão "criar cadastro"112 navigationPromise = page.waitForNavigation();113 await page.click('.btn-create[type=submit]');114 await navigationPromise;115116 // // Preenche os dados do endereço117 console.log('> Preenchendo endereço...');118 await page.type('input#cep', cliente.endereco.cep, { delay: 100 });119 await page.type('input#numero', cliente.endereco.numero, { delay: 100 });120 await page.type('input#complemento', cliente.endereco.complemento, { delay: 100 });121122 // // Clica no botão "continuar" (cadastro de endereço)123 navigationPromise = page.waitForNavigation();124 await page.click('.btn-submit-form[type=submit]');125 await navigationPromise;126127 // Clica no botão "continuar" (confirmação de envio)128 console.log('> Confirmando envio...');129 navigationPromise = page.waitForNavigation();130 await page.click('div.same-day .btn-green[type=submit]');131 await navigationPromise;132133 // Clica no botão "boleto" (confirmação de pagamento)134 console.log('> Clicando em gerar boleto...');135 navigationPromise = page.waitForNavigation();136 await page.click('div.padBoleto input[type=radio]');137 await navigationPromise;138139 // // Preenche CPF para NF e clica em "continuar"140 console.log('> Preenchendo CPF para a nota fiscal...');141 await page.type('input#cpfnota', cliente.cpf, { delay: 100 });142 navigationPromise = page.waitForNavigation();143 await page.click('.btn-submit-form[type=submit]');144 await navigationPromise;145146 // // Clica no botão "finalizar pedido"147 console.log('> Clicando em "finalizar pedido"...');148 navigationPromise = page.waitForNavigation();149 await page.click('#form-save-order .botaoFinalizarBoleto');150 await navigationPromise;151152 // // Fechar popup e-bit153 await page.waitForSelector('span#btFechar');154 await page.click('span#btFechar');155156 // Pega o número do boleto157 console.log('> Extraindo número do boleto...');158 let num_boleto = await page.evaluate(() => {159 return document.getElementById('lindig')160 .innerText161 .trim()162 .replaceAll('.', '') ...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

...25 await page.goto(AMAZON_URL);26 // 検索27 // ----------------------------------28 await Promise.all([29 page.waitForNavigation({ waitUntil: 'load'}),30 await page.type('input[name="field-keywords"]', KEYWORD),31 await page.evaluate(({ }) => {32 document.querySelector("#nav-search-bar-form").submit();33 }, {})34 ]);35 // 検索条件指定36 // ----------------------------------37 // 検索条件指定 > 値段設定38 await Promise.all([39 page.waitForNavigation({ waitUntil: 'load'}),40 await page.evaluate(({ }) => {41 let e = document.querySelector('#priceRefinements > ul');42 let f = e.querySelector('li[aria-label="0-500円"]');43 let aPriceOption = f.querySelector('span > a');44 aPriceOption.click();45 }, {})46 ]);47 // 検索条件指定 > 到着日48 await Promise.all([49 page.waitForNavigation({ waitUntil: 'load'}),50 page.click("li[aria-label=明日までにお届け] > span > a")51 ]);52 // 検索結果取得53 // ----------------------------------54 let url = await page.evaluate(({ }) => {55 let resultList = document.querySelector('.s-main-slot.s-result-list');56 let list = Array.from(resultList.children);57 let items = []58 for ( const elm of list){59 // [note] href属性を持たない要素があるため場合分け60 if ( elm.querySelector('a') && elm.querySelector('a').href ) items.push( elm.querySelector('a').href );61 }62 return items[Math.floor(Math.random() * items.length)];63 }, {});64 return url;65};66const purchase = async ( page, url ) => {67 // 事前処理68 // ----------------------------------69 // ログイン情報を取得70 const loginId = process.env.AMAZON_ID;71 const loginPassword = process.env.AMAZON_PASSWORD;72 // Amazonのサイトを開く73 await page.goto(AMAZON_URL);74 // ログインページへ移動75 await Promise.all([76 page.waitForNavigation({ waitUntil: 'load'}),77 await page.evaluate(() => {78 document.querySelector(".nav-action-button").click();79 })80 ]);81 // ログイン82 // ----------------------------------83 // ID入力84 await Promise.all([85 page.waitForNavigation({ waitUntil: 'load'}),86 await page.type('input[name="email"]', loginId),87 await page.evaluate(({ }) => {88 document.querySelector("form").submit();89 }, {})90 ]);91 // パスワード入力92 await Promise.all([93 page.waitForNavigation({ waitUntil: 'load'}),94 await page.type('input[name="password"]', loginPassword),95 await page.evaluate(({ }) => {96 document.querySelector("form").submit();97 }, {})98 ]);99 // 商品ページへ移動100 // ----------------------------------101 console.log(`[Info] url${url}`);102 await Promise.all([103 page.waitForNavigation({ waitUntil: 'load'}),104 await page.goto(url)105 ]);106 // 購入直前まで107 // ----------------------------------108 // 今すぐ購入109 // await page.waitFor(3000);110 // await page.evaluate(() => {111 // document.querySelector("#buy-now-button").click(); [NOTE] 動作しません112 // });113 // カートに追加114 await page.waitFor(5000); // [note] たまに失敗するので待機する115 await Promise.all([116 page.waitForNavigation({ waitUntil: 'load'}),117 await page.evaluate(({ }) => {118 document.querySelector('#add-to-cart-button').click();119 }, {})120 ]);121 // 続行122 await Promise.all([123 page.waitForNavigation({ waitUntil: 'load'}),124 await page.evaluate(({ }) => {125 document.querySelector('#hlb-ptc-btn-native').click();126 }, {})127 ]);128 // 商品みえなくする129 await Promise.all([130 page.waitForNavigation({ waitUntil: 'load'}),131 await page.evaluate(({ }) => {132 let e = document.querySelector('#revieworder');133 e.style.display='none';134 }, {})135 ]);136 // 注文を確定する 137 // await page.waitFor(5000);138 // await page.evaluate(({ }) => {139 // document.querySelector('#spc-form').submit(); [NOTE] 動作しません140 // }, {}); 141};...

Full Screen

Full Screen

tic.js

Source:tic.js Github

copy

Full Screen

...16 let page = await browser.newPage();17 // Goes to amazon site18 await page.goto("https://www.amazon.in/gp/css/homepage.html?from=hz");19 //sign in 20 await Promise.all([page.click("#nav-link-accountList-nav-line-1"), page.waitForNavigation()]);21 await page.type(".a-input-text.a-span12.auth-autofocus.auth-required-field" , "mahici8394@w3boats.com");22 23 // search click and type password24 await Promise.all([page.click(".a-button-input"), page.waitForNavigation()]);25 await page.waitForSelector(".a-input-text.a-span12.auth-autofocus.auth-required-field");26 await page.type(".a-input-text.a-span12.auth-autofocus.auth-required-field", "mahici8394@w3boats.com");27 await Promise.all([page.click("#signInSubmit"), page.waitForNavigation()]);28 29 //search in search bar 30 await page.type("#twotabsearchtextbox","Tata Salt Lite, Low Sodium, 1kg");31 await Promise.all([page.click("#nav-search-submit-button"), page.waitForNavigation()]);32 // unique selector nhi hai 33 await Promise.all([page.click(".a-size-base-plus.a-color-base.a-text-normal")]);34 // to run in different tab35 let pages = await browser.pages();36 page = await pages[pages.length-1];37 await page.waitForSelector("#freshAddToCartButton .a-button-input",{visible :true});38 await page.evaluate(function(){39 let x = document.querySelector("#freshAddToCartButton .a-button-input");40 x.click();41 })42 43 44 // now clicked on buy again 45 await page.evaluate(function(){46 let a = document.querySelectorAll(".nav-a");47 a[6].click();48 49 })50 /51 await page.waitForNavigation();52 // //type and clicked on Aashirvaad Shudh Atta53 // await page.type("#twotabsearchtextbox","Aashirvaad Shudh Chakki Atta");54 // await Promise.all([page.click("#nav-search-submit-button"), page.waitForNavigation()]);55 // await page.evaluate(function(){56 // let a = document.querySelectorAll(".a-size-base-plus.a-color-base.a-text-normal");57 // a[0].click();58 // })59 // pages = await browser.pages();60 // page = await pages[pages.length-1];61 // await page.waitForSelector("#freshAddToCartButton-announce");62 // await Promise.all([page.click("#freshAddToCartButton-announce"), page.waitForNavigation()]);63 64 65 66 // Type Surf Excel on search bar67 await page.type("#twotabsearchtextbox","Surf Excel");68 await Promise.all([page.click("#nav-search-submit-button"), page.waitForNavigation()]);69 70 await page.waitForSelector(".a-size-base-plus.a-color-base.a-text-normal");71 await page.click(".a-size-base-plus.a-color-base.a-text-normal");72 pages = await browser.pages();73 page = await pages[pages.length-1];74 await page.waitForSelector("#freshAddToCartButton-announce", {visible:true});75 await page.click("#freshAddToCartButton-announce");76 77 78 await page.evaluate(function(){79 let buyagain = document.querySelectorAll(".nav-a");80 buyagain[6].click();81 })82 await page.waitForNavigation();83 await page.type("#twotabsearchtextbox", "Colgate Max Fresh");84 await Promise.all([page.click("#nav-search-submit-button"), page.waitForNavigation()]);85 await page.waitForSelector(".a-size-base-plus.a-color-base.a-text-normal");86 await page.click(".a-size-base-plus.a-color-base.a-text-normal");87 pages = await browser.pages();88 page = await pages[pages.length-1];89 await page.waitForSelector("#a-autoid-0-announce"); 90 91 await page.click("#a-autoid-0-announce"); 92 await page.click("#nav-cart-count");93 94 95 }96 97 catch(err)98 {...

Full Screen

Full Screen

puppeteer.js

Source:puppeteer.js Github

copy

Full Screen

...5 await page.goto('http://12.0.0.2:3000/');6// await page.screenshot({path: './screenshots/accueil.png'});7 await page.type('#searchalbum', 'album_mer');8 await Promise.all([9 page.waitForNavigation(),10 page.click('#btnsearch')11 ]);12// await page.screenshot({path: './screenshots/album_mer.png'});13 await page.click('#img3');14// await page.screenshot({path: './screenshots/img3.png'});15 //l'utilisateur retourne à la page d'accueil16 await page.goto('http://12.0.0.2:3000/');17 //il choisit un autre album18 await page.type('#searchalbum', 'album_montagne');19 await Promise.all([20 page.waitForNavigation(),21 page.click('#btnsearch')22 ]);23// await page.screenshot({path: './screenshots/album_montagne.png'});24 await page.click('#delete');25 await page.type('#searchalbum', 'album_montagne');26 await Promise.all([27 page.waitForNavigation(),28 page.click('#btnsearch')29 ]);30// await page.screenshot({path: './screenshots/album_not_found.png'});31 await page.click('#addalbum');32 await page.type('#id', 'album_montagne');33 await page.type('#titre', 'Montagne Album');34 await page.type('#description', 'The most beautiful mountains on earth');35 await page.type('#photo1', '/images/montagne/montagne1.jpg');36 await page.type('#photo2', '/images/montagne/montagne2.jpg');37 await page.type('#photo3', '/images/montagne/montagne3.jpg');38 await page.type('#photo4', '/images/montagne/montagne4.jpg');39 //await page.screenshot({path: './screenshots/addalbum_desert.png'});40 await Promise.all([41 page.waitForNavigation(),42 page.click('#submit')43 ]);44 await page.type('#searchalbum', 'album_montagne');45 await Promise.all([46 page.waitForNavigation(),47 page.click('#btnsearch')48 ]);49// await page.screenshot({path: './screenshots/album_desert.png'});50/*51 //proba52 function getRandomArbitrary(min, max) { //valeur de max est exclue53 return Math.random() * (max - min) + min;54 }55 // ajoute un album avec une proba 1/1056 if(getRandomArbitrary(1, 11)==1){57 await page.click('#addalbum');58 await page.type('#id', 'album_desert');59 await page.type('#titre', 'Desert Album');60 await page.type('#description', 'The most beautiful deserts on earth');61 await page.type('#photo1', '/images/desert/desert1.jpg');62 await page.type('#photo2', '/images/desert/desert2.jpg');63 await page.type('#photo3', '/images/desert/desert3.jpg');64 await page.type('#photo4', '/images/desert/desert4.jpg');65 await page.screenshot({path: './screenshots/addalbum_desert.png'});66 await Promise.all([67 page.waitForNavigation(),68 page.click('#submit')69 ]);70 await page.type('#searchalbum', 'album_desert');71 await Promise.all([72 page.waitForNavigation(),73 page.click('#btnsearch')74 ]);75 await page.screenshot({path: './screenshots/album_desert.png'});76}77// supprime un album avec une proba 1/1078if(getRandomArbitrary(1, 11)==1){79//l'utilisateur retourne à la page d'accueil80await page.goto('http://12.0.0.2:3000/');81//il choisit un autre album82await page.type('#searchalbum', 'album_montagne');83await Promise.all([84 page.waitForNavigation(),85 page.click('#btnsearch')86]);87await page.screenshot({path: './screenshots/album_montagne.png'});88await page.click('#delete');89await page.type('#searchalbum', 'album_montagne');90await Promise.all([91 page.waitForNavigation(),92 page.click('#btnsearch')93]);94await page.screenshot({path: './screenshots/album_not_found.png'});95}96if(getRandomArbitrary(1, 11)!=1 || getRandomArbitrary(1, 11)!=2){97 await page.goto('http://12.0.0.2:3000/');98 await page.screenshot({path: './screenshots/accueil.png'});99 await page.type('#searchalbum', 'album_mer');100 await Promise.all([101 page.waitForNavigation(),102 page.click('#btnsearch')103 ]);104 await page.screenshot({path: './screenshots/album_mer.png'});105 await page.click('#img3');106 await page.screenshot({path: './screenshots/img3.png'});107}108*/109 await browser.close();...

Full Screen

Full Screen

router_history.test.js

Source:router_history.test.js Github

copy

Full Screen

...15 assert.equal(await page.evaluate(() => document.getElementById('foo').textContent), 'FOO')16 assert.equal(await page.evaluate(() => document.getElementById('bar').textContent), 'BAR')17 await Promise.all([18 page.click('a.about'),19 page.waitForNavigation(),20 ])21 title = await page.evaluate(() => document.title)22 assert.equal(title, 'About | Example App')23 await Promise.all([24 page.click('a.books'),25 page.waitForNavigation(),26 ])27 title = await page.evaluate(() => document.title)28 assert.equal(title, 'BookList | Example App')29 await Promise.all([30 page.click('a.api'),31 page.waitForNavigation(),32 ])33 title = await page.evaluate(() => document.title)34 assert.equal(title, 'API Documents | Example App')35 await Promise.all([36 page.click('a.user'),37 page.waitForNavigation(),38 ])39 title = await page.evaluate(() => document.title)40 assert.equal(title, 'User/someone | Example App')41 await Promise.all([42 page.click('a.book'),43 page.waitForNavigation(),44 ])45 title = await page.evaluate(() => document.title)46 assert.equal(title, 'Book5 | Example App')47 await Promise.all([48 page.click('a.usertimeline'),49 page.waitForNavigation(),50 ])51 title = await page.evaluate(() => document.title)52 assert.equal(title, 'UserTimeline/someone | Example App')53// await sleep(10) // wait redirect54 await Promise.all([55 page.click('a.readers'),56 page.waitForNavigation(),57 ])58 title = await page.evaluate(() => document.title)59 assert.equal(title, 'Book3 | Example App') // books/360 await Promise.all([61 page.click('a.reader'),62 page.waitForNavigation(),63 ])64 title = await page.evaluate(() => document.title)65 assert.equal(title, 'BookReader id:3 reader:tom | Example App')66 await Promise.all([67 page.click('a.docs'),68 page.waitForNavigation(),69 ])70 title = await page.evaluate(() => document.title)71 assert.equal(title, 'Documents | Example App')72 await Promise.all([73 page.click('a.summary'),74 page.waitForNavigation(),75 ])76 title = await page.evaluate(() => document.title)77 assert.equal(title, 'BookSummary 5 | Example App')78 await Promise.all([79 page.click('a.home'),80 page.waitForNavigation(),81 ])82 title = await page.evaluate(() => document.title)83 assert.equal(title, 'Home | Example App')84 assert.equal(await page.evaluate(() => document.getElementById('foo').textContent), 'FOOC')85 assert.equal(await page.evaluate(() => document.getElementById('bar').textContent), 'NULL')86 })...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...7 await page.goto('https://www.instagram.com',{waitUntil:'networkidle2'});8 await page.type("input[name='username']",data.user,{delay:100});9 await page.type("input[name='password']",data.password,{delay:100});10 await Promise.all([11 page.waitForNavigation({waitUntil:"networkidle2"}),12 page.click("button[type='submit']")13 ]);14 await page.type("input[placeholder='Search']","priyavrat17");15 await page.waitForSelector("._01UL2 .fuqBx a",{visible:true});16 await Promise.all([17 page.waitForNavigation({waitUntil:"networkidle2"}),18 page.click("._01UL2 .fuqBx a")19]);20await page.waitForSelector("._9AhH0",{visible:true});21await Promise.all([22 page.waitForNavigation({waitUntil:"networkidle2"}),23 page.click("._9AhH0"),24]);25let i=0;26do{27 await page.waitForSelector(".fr66n button");28 await page.click(".fr66n button");29 await Promise.all([30 page.waitForNavigation({waitUntil:"networkidle2"}),31 page.click("._65Bje.coreSpriteRightPaginationArrow"),32]);33i++;34}while(i<noOfPost){35}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1(async () => {2 try {3 await openBrowser();4 await goto("google.com");5 await click("Gmail");6 await waitForNavigation();7 await closeBrowser();8 } catch (e) {9 console.error(e);10 } finally {11 }12})();13 at Promise.then (/home/username/.nvm/versions/node/v10.15.3/lib/node_modules/taiko/node_modules/puppeteer/lib/NavigatorWatcher.js:70:21)14 at process._tickCallback (internal/process/next_tick.js:189:7)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, click, write, closeBrowser, waitForNavigation } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await write('Taiko');6 await click('Google Search');7 await waitForNavigation({timeout:10000});8 await closeBrowser();9 } catch (e) {10 console.error(e);11 } finally {12 }13})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, click, closeBrowser, waitForNavigation } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await click("Gmail");6 await waitForNavigation();7 await click("Sign in");8 } catch (e) {9 console.error(e);10 } finally {11 await closeBrowser();12 }13})();14waitForNavigation(options)15waitForNavigation({options})16const { openBrowser, goto, click, closeBrowser, waitForNavigation } = require('taiko');17(async () => {18 try {19 await openBrowser();20 await click("Gmail");21 await waitForNavigation({waitForStart: true});22 await click("Sign in");23 } catch (e) {24 console.error(e);25 } finally {26 await closeBrowser();27 }28})();29waitForEvent(event, options)30waitForEvent(event, {options})31const { openBrowser, goto, closeBrowser, waitForEvent, button } = require('taiko');32(async () => {33 try {34 await openBrowser();35 await waitForEvent(button("Sign in"), "exists");36 } catch (e) {37 console.error(e);38 } finally {39 await closeBrowser();40 }41})();42waitForSelector(selector, options)43waitForSelector(selector, {options})

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, waitForNavigation, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await waitForNavigation({timeout:10000});6 await closeBrowser();7 } catch (e) {8 console.error(e);9 } finally {10 }11})();12const { openBrowser, goto, click, waitForNavigation, closeBrowser } = require('taiko');13(async () => {14 try {15 await openBrowser();16 await click("Guide");17 await waitForNavigation({timeout:10000});18 await closeBrowser();19 } catch (e) {20 console.error(e);21 } finally {22 }23})();24const { openBrowser, goto, waitForNavigation, closeBrowser } = require('taiko');25(async () => {26 try {27 await openBrowser();28 await waitForNavigation({timeout:10000});29 await closeBrowser();30 } catch (e) {31 console.error(e);32 } finally {33 }34})();35const { openBrowser, goto, write, press, waitForNavigation,

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, waitForNavigation, write, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await goto("google.com");6 await write("Taiko", into("Search"));7 await waitForNavigation({timeout:10000});8 await closeBrowser();9 } catch (error) {10 console.error(error);11 }12})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, click, closeBrowser, waitForNavigation } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await click("Gmail");6 await waitForNavigation();7 await closeBrowser();8 } catch (e) {9 console.error(e);10 } finally {11 }12})();13const { openBrowser, goto, click, closeBrowser, waitForNavigation } = require('taiko');14(async () => {15 try {16 await openBrowser();17 await click("Gmail");18 await waitForNavigation({timeout:5000});19 await closeBrowser();20 } catch (e) {21 console.error(e);22 } finally {23 }24})();25const { openBrowser, goto, click, closeBrowser, waitForNavigation } = require('taiko');26(async () => {27 try {28 await openBrowser();29 await click("Gmail");30 await waitForNavigation({timeout:5000, navigationTimeout:10000});31 await closeBrowser();32 } catch (e) {33 console.error(e);34 } finally {35 }36})();37const { openBrowser, goto, click, closeBrowser, waitForNavigation } = require('taiko');38(async () => {39 try {40 await openBrowser();41 await click("Gmail");42 await waitForNavigation({timeout:5000, navigationTimeout:10000, waitForEvents:["DOMContentLoaded", "load"]});43 await closeBrowser();44 }

Full Screen

Using AI Code Generation

copy

Full Screen

1(async () => {2 try {3 await openBrowser({ headless: false });4 await write("Taiko", into("Search"));5 await press("Enter");6 await waitForNavigation({ timeout: 10000 });7 await closeBrowser();8 } catch (e) {9 console.error(e);10 } finally {11 }12})();

Full Screen

Using AI Code Generation

copy

Full Screen

1(async () => {2 try {3 await openBrowser();4 await click("Sign in");5 await waitForNavigation();6 await write("abc");7 await press("Enter");8 } catch (e) {9 console.error(e);10 } finally {11 await closeBrowser();12 }13})();14(async () => {15 try {16 const browser = await puppeteer.launch();17 const page = await browser.newPage();18 await page.click("Sign in");19 await page.waitForNavigation();20 await page.type("abc");21 await page.keyboard.press("Enter");22 await browser.close();23 } catch (e) {24 console.error(e);25 }26})();27The waitForNavigation() method takes an object with the following possible properties:28(async () => {29 try {30 await openBrowser();31 await click("Sign in");32 await write("abc");33 await press("Enter");34 } catch (e)

Full Screen

Using AI Code Generation

copy

Full Screen

1(async () => {2 try {3 await openBrowser();4 await click("Sign in");5 await waitForNavigation({timeout: 5000, waitUntil: 'domcontentloaded'});6 await write("taiko");7 await press('Enter');8 await screenshot({path: 'google.png'});9 await closeBrowser();10 } catch (e) {11 console.error(e);12 } finally {13 }14})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, write, click, link, closeBrowser, waitForNavigation, button, text, textBox, toRightOf, toLeftOf } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await write("Taiko", into(textBox(toRightOf("Search"))));6 await click(button("Google Search"));7 await waitForNavigation();8 await click(link("Taiko: Test Automation Framework for ..."));9 await waitForNavigation();10 await closeBrowser();11 } catch (error) {12 console.error(error);13 }14})();15const { openBrowser, goto, write, click, link, closeBrowser, waitFor, button, text, textBox, toRightOf, toLeftOf } = require('taiko');16(async () => {17 try {18 await openBrowser({ headless: false });19 await write("Taiko", into(textBox(toRightOf("Search"))));20 await click(button("Google Search"));21 await waitFor(3000);22 await click(link("Taiko: Test Automation Framework for ..."));23 await waitFor(3000);24 await closeBrowser();25 } catch (error) {26 console.error(error);27 }28})();29const { openBrowser, goto, write, click, link, closeBrowser, waitFor, button, text, textBox, toRightOf, toLeftOf, evaluate } = require('taiko');30(async () => {31 try {32 await openBrowser({ headless: false });33 await write("Taiko", into(textBox(toRightOf("Search"))));34 await click(button

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run taiko automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful