How to use page.waitForSelector method in qawolf

Best JavaScript code snippet using qawolf

secfit.test.js

Source:secfit.test.js Github

copy

Full Screen

...33 await page.goto(url);34 });35 // log in36 test("Log in", async () => {37 await page.waitForSelector("#btn-login-nav");38 await page.evaluate((selector) => {39 document.querySelector(selector).click();40 }, "#btn-login-nav");41 await page.waitForNavigation();42 await login(user);43 }, 25000);44});45// Exercises46describe("exercise page", () => {47 beforeAll(async () => {48 await page.goto(url)49 })50 //access exercise page51 test("access exercise page", async () =>{52 await page.waitForSelector("#btn-login-nav");53 await page.evaluate((selector) => {54 document.querySelector(selector).click();55 }, "#btn-login-nav");56 await page.waitForNavigation();57 await login(user);58 await page.waitForSelector("#nav-exercises");59 await page.evaluate((selector) => {60 document.querySelector(selector).click();61 }, "#nav-exercises");62 await page.waitForNavigation();63 await page.waitForSelector("#btn-create-exercise");64 })65 // new exercise66 test("create exercise", async () =>{67 await page.waitForSelector("#btn-create-exercise");68 await page.evaluate((selector) => {69 document.querySelector(selector).click();70 }, "#btn-create-exercise");71 await page.waitForNavigation();72 await page.waitForSelector("#inputName");73 await page.type("#inputName", exercise.name)74 await page.waitForSelector("#inputDescription");75 await page.type("#inputDescription", exercise.description)76 await page.waitForSelector("#inputUnit");77 await page.type("#inputUnit", exercise.unit)78 await page.waitForSelector("#btn-ok-exercise");79 await page.evaluate((selector) => {80 document.querySelector(selector).click();81 }, "#btn-ok-exercise");82 await page.waitForNavigation();83 await page.waitForSelector("#btn-create-exercise");84 85 }, 25000)86 // read exercise87 test("look at exercise", async () =>{88 await page.waitForSelector("#div-content");89 const exercises = await page.$$("a");90 await page.evaluate((field) => field.click(), exercises[exercises.length -1]);91 92 await page.waitForSelector("#inputName");93 const name = await page.evaluate(94 (field) => document.querySelector(field).value,95 "#inputName"96 );97 expect(name).toEqual(exercise.name);98 await page.waitForSelector("#inputDescription");99 const desc = await page.evaluate(100 (field) => document.querySelector(field).value,101 "#inputDescription"102 );103 expect(desc).toEqual(exercise.description);104 await page.waitForSelector("#inputUnit");105 const unit = await page.evaluate(106 (field) => document.querySelector(field).value,107 "#inputUnit"108 );109 expect(unit).toEqual(exercise.unit);110 }, 25000)111 // edit exercise112 test("edit exercise", async () =>{113 await page.evaluate((selector) => {114 document.querySelector(selector).click();115 }, "#btn-edit-exercise");116 117 await page.waitForSelector("#inputName");118 await page.evaluate(119 (field) => document.querySelector(field).value = "sit-ups",120 '#inputName'121 );122 await page.waitForSelector("#inputDescription");123 await page.evaluate(124 (field) => document.querySelector(field).value = "sit up and down",125 '#inputDescription'126 );127 128 await page.waitForSelector("#inputUnit");129 await page.evaluate(130 (field) => document.querySelector(field).value = "num",131 '#inputUnit'132 );133 await page.evaluate((selector) => {134 document.querySelector(selector).click();135 }, "#btn-ok-exercise");136 await page.waitForSelector("#btn-edit-exercise");137 }, 25000)138})139// Workouts140describe("workout page", () => {141 beforeAll(async () => {142 await page.goto(url)143 })144 //access workout page145 test("access workout page", async () =>{146 await page.waitForSelector("#btn-login-nav");147 await page.evaluate((selector) => {148 document.querySelector(selector).click();149 }, "#btn-login-nav");150 await page.waitForNavigation();151 await login(user);152 await page.waitForSelector("#btn-create-workout");153 })154 // new workout155 test("create workout", async () =>{156 await page.waitForSelector("#btn-create-workout");157 await page.evaluate((selector) => {158 document.querySelector(selector).click();159 }, "#btn-create-workout");160 await page.waitForNavigation();161 await page.waitForSelector("#inputName");162 await page.type("#inputName", workout.name)163 await page.waitForSelector("#inputDateTime");164 await page.type("#inputDateTime", String.fromCharCode(32));165 await page.type("#inputDateTime", String.fromCharCode(13));166 await page.evaluate((selector) => {167 document.querySelector(selector).click();168 }, "#btn-add-athelte");169 await page.waitForSelector("#inputSearchForUser");170 await page.type("#inputSearchForUser", "Annika");171 await page.evaluate((selector) => {172 document.querySelector(selector).click();173 }, '[value="Annika"]');174 await page.select('#inputVisibility', 'PU')175 await page.waitForSelector("#inputNotes");176 await page.type("#inputNotes", workout.notes);177 await page.select('select[name=type]', '4')178 179 await page.waitForSelector('input[name=sets]');180 await page.type('input[name=sets]', "1");181 await page.waitForSelector('[name=number]');182 await page.type('input[name=number]', "1");183 await page.waitForSelector("#btn-ok-workout");184 await page.evaluate((selector) => {185 document.querySelector(selector).click();186 }, "#btn-ok-workout");187 await page.waitForNavigation();188 await page.waitForSelector("#btn-create-workout");189 190 }, 25000)191 // read workout192 test("look at workout", async () =>{193 await page.waitForSelector("#div-content");194 const workouts = await page.$$(".workout");195 await page.evaluate((field) => field.click(), workouts[0]);196 197 await page.waitForSelector("#inputName");198 const name = await page.evaluate(199 (field) => document.querySelector(field).value,200 "#inputName"201 );202 expect(name).toEqual(workout.name);203 await page.waitForSelector("#inputNotes");204 const notes = await page.evaluate(205 (field) => document.querySelector(field).value,206 "#inputNotes"207 );208 expect(notes).toEqual(workout.notes);209 await page.waitForSelector("#inputOwner");210 const owner = await page.evaluate(211 (field) => document.querySelector(field).value,212 "#inputOwner"213 );214 expect(owner).toEqual("Anna");215 }, 25000)216 // edit workout217 test("edit workout", async () =>{218 await page.evaluate((selector) => {219 document.querySelector(selector).click();220 }, "#btn-edit-workout");221 222 await page.waitForSelector("#inputName");223 await page.evaluate(224 (field) => document.querySelector(field).value = "lame workout",225 '#inputName'226 );227 await page.waitForSelector("#inputDateTime");228 await page.type("#inputDateTime", String.fromCharCode(32));229 await page.type("#inputDateTime", String.fromCharCode(13));230 await page.select('#inputVisibility', 'PR')231 await page.waitForSelector("#inputNotes");232 await page.evaluate(233 (field) => document.querySelector(field).value = "new notes",234 '#inputNotes'235 );236 await page.evaluate((selector) => {237 document.querySelector(selector).click();238 }, "#btn-ok-workout");239 await page.waitForSelector("#btn-edit-workout");240 }, 25000)241 // delete workout242 test("delete workout", async () =>{243 await page.evaluate((selector) => {244 document.querySelector(selector).click();245 }, "#btn-edit-workout");246 247 await page.evaluate((selector) => {248 document.querySelector(selector).click();249 }, "#btn-delete-workout");250 await page.waitForSelector("#btn-create-workout");251 }, 25000)252})253// Athlete page254describe("athlete page", () => {255 beforeAll(async () => {256 await page.goto(url)257 })258 //access athlete page259 test("access athlete page", async () =>{260 await page.waitForSelector("#btn-login-nav");261 await page.evaluate((selector) => {262 document.querySelector(selector).click();263 }, "#btn-login-nav");264 await page.waitForNavigation();265 await login(user);266 await page.waitForSelector("#nav-myathletes");267 await page.evaluate((selector) => {268 document.querySelector(selector).click();269 }, "#nav-myathletes");270 await page.waitForNavigation();271 await page.waitForSelector("#button-submit-roster");272 })273 // new athlete274 test("add athlete", async () =>{275 await page.waitForSelector("#button-submit-roster");276 await page.waitForSelector("input[name='athlete']");277 await page.type("input[name='athlete']", "Annika")278 await page.evaluate((selector) => {279 document.querySelector(selector).click();280 }, '.btn-success');281 await page.waitForSelector(".btn-danger");282 await page.evaluate((selector) => {283 document.querySelector(selector).click();284 }, '#button-submit-roster');285 await page.waitForSelector("#controls");286 }, 25000)287})288// Coach page289describe("coach page", () => {290 beforeAll(async () => {291 await page.goto(url)292 })293 //access coach page294 test("access coach page", async () =>{295 await page.waitForSelector("#btn-login-nav");296 await page.evaluate((selector) => {297 document.querySelector(selector).click();298 }, "#btn-login-nav");299 await page.waitForNavigation();300 await login(user);301 await page.waitForSelector("#nav-mycoach");302 await page.evaluate((selector) => {303 document.querySelector(selector).click();304 }, "#nav-mycoach");305 await page.waitForNavigation();306 await page.waitForSelector("#button-edit-coach");307 }, 25000)308 // new coach309 test("add coach", async () =>{310 await page.waitForSelector("#button-edit-coach");311 await page.evaluate((selector) => {312 document.querySelector(selector).click();313 }, '#button-edit-coach');314 await page.waitForSelector("input[name='coach']");315 await page.type("input[name='coach']", "Annika")316 await page.evaluate((selector) => {317 document.querySelector(selector).click();318 }, '#button-set-coach');319 await page.waitForSelector("#button-edit-coach");320 const coach = await page.evaluate(321 (field) => document.querySelector(field).value,322 'input[name="coach"]'323 );324 expect(coach).toEqual("Annika");325 }, 25000)326})327describe("Profile functionality", () => {328 beforeAll(async () => {329 await page.goto(url);330 });331 test("access to profile page", async () => {332 await page.waitForSelector("#btn-login-nav");333 await page.evaluate((selector) => {334 document.querySelector(selector).click();335 }, "#btn-login-nav");336 await page.waitForNavigation();337 await login(user);338 await page.waitForSelector("#nav-profile");339 await page.evaluate((selector) => {340 document.querySelector(selector).click();341 }, "#nav-profile");342 await page.waitForNavigation();343 await page.waitForSelector("#form-profile");344 }, 25000);345 // Read profile info346 test("read profile info", async () => {347 await page.waitForSelector('input[name="username"]');348 const username = await page.evaluate(349 (field) => document.querySelector(field).value,350 "#inputUsername"351 );352 expect(username).toEqual(user.username);353 await page.waitForSelector('input[name="email"]');354 const email = await page.evaluate(355 (field) => document.querySelector(field).value,356 'input[name="email"]'357 );358 expect(email).toEqual(user.email);359 await page.waitForSelector('input[name="phone_number"]');360 const phone_number = await page.evaluate(361 (field) => document.querySelector(field).value,362 'input[name="phone_number"]'363 );364 expect(phone_number).toEqual(user.phone_numer);365 await page.waitForSelector('input[name="street_address"]');366 const street_address = await page.evaluate(367 (field) => document.querySelector(field).value,368 'input[name="street_address"]'369 );370 expect(street_address).toEqual(user.street_name);371 await page.waitForSelector('input[name="city"]');372 const city = await page.evaluate(373 (field) => document.querySelector(field).value,374 'input[name="city"]'375 );376 expect(city).toEqual(user.city);377 await page.waitForSelector('input[name="country"]');378 const country = await page.evaluate(379 (field) => document.querySelector(field).value,380 'input[name="country"]'381 );382 expect(country).toEqual(user.country);383 }, 20000);384 // Cancel edit profile385 test("cancel edit email", async () => {386 await page.waitForSelector("#btn-edit-profile");387 await page.evaluate((selector) => {388 document.querySelector(selector).click();389 }, "#btn-edit-profile");390 console.log("clicked edit button")391 await page.waitForSelector("#btn-cancel-edit");392 await page.evaluate((selector) => {393 document.querySelector(selector).click();394 }, "#btn-cancel-edit");395 console.log("clicked cancel edit button")396 await page.waitForSelector("#btn-edit-profile");397 console.log("cancelled edit")398 })399 // Edit profile400 test("edit profile", async () => {401 await page.waitForSelector("#btn-edit-profile");402 await page.evaluate((selector) => {403 document.querySelector(selector).click();404 }, "#btn-edit-profile");405 console.log("clicked edit button")406 await page.waitForSelector('input[name="username"]');407 await page.evaluate(408 (field) => document.querySelector(field).value = "Anita",409 "#inputUsername"410 );411 await page.waitForSelector('input[name="email"]');412 await page.evaluate(413 (field) => document.querySelector(field).value = "new@email.com",414 'input[name="email"]'415 );416 await page.waitForSelector('input[name="phone_number"]');417 await page.evaluate(418 (field) => document.querySelector(field).value = "123",419 'input[name="phone_number"]'420 );421 await page.waitForSelector('input[name="street_address"]');422 await page.evaluate(423 (field) => document.querySelector(field).value = "munkegata 36",424 'input[name="street_address"]'425 );426 await page.waitForSelector('input[name="city"]');427 await page.evaluate(428 (field) => document.querySelector(field).value = "Trondheim",429 'input[name="city"]'430 );431 await page.waitForSelector('input[name="country"]');432 await page.evaluate(433 (field) => document.querySelector(field).value = "Sweden",434 'input[name="country"]'435 );436 await page.evaluate((selector) => {437 document.querySelector(selector).click();438 }, "#btn-confirm-edit");439 console.log("clicked confirm edit button")440 await page.waitForSelector('input[name="username"]');441 const username = await page.evaluate(442 (field) => document.querySelector(field).value,443 "#inputUsername"444 );445 expect(username).toEqual("Anita");446 })447 // cancel delete profile448 test("cancel delete profile", async () => {449 await page.waitForSelector("#btn-edit-profile");450 await page.evaluate((selector) => {451 document.querySelector(selector).click();452 }, "#btn-edit-profile");453 console.log("clicked edit profile button")454 await page.waitForSelector("#btn-initiate-delete");455 await page.evaluate((selector) => {456 document.querySelector(selector).click();457 }, "#btn-initiate-delete");458 console.log("clicked delete profile button")459 await page.waitForSelector("#btn-cancel-delete");460 await page.evaluate((selector) => {461 document.querySelector(selector).click();462 }, "#btn-cancel-delete");463 console.log("clicked cancel delete profile button")464 await page.waitForSelector('input[name="username"]');465 })466 //delete profile467 test("delete profile", async () => {468 await page.waitForSelector("#btn-edit-profile");469 await page.evaluate((selector) => {470 document.querySelector(selector).click();471 }, "#btn-edit-profile");472 console.log("clicked edit profile button")473 await page.waitForSelector("#btn-initiate-delete");474 await page.evaluate((selector) => {475 document.querySelector(selector).click();476 }, "#btn-initiate-delete");477 console.log("clicked delete profile button")478 await page.waitForSelector("#btn-delete-user");479 await page.evaluate((selector) => {480 document.querySelector(selector).click();481 }, "#btn-delete-user");482 console.log("clicked confirm delete profile button")483 await page.waitForNavigation();484 await page.waitForSelector("#btn-login-nav");485 console.log("user deleted")486 })487});488describe("Cleanup", () => {489 beforeAll(async () => {490 await page.goto(url);491 });492 test("access to profile page", async () => {493 await page.waitForSelector("#btn-login-nav");494 await page.evaluate((selector) => {495 document.querySelector(selector).click();496 }, "#btn-login-nav");497 await page.waitForNavigation();498 await login(user2);499 await page.waitForSelector("#nav-profile");500 await page.evaluate((selector) => {501 document.querySelector(selector).click();502 }, "#nav-profile");503 await page.waitForNavigation();504 await page.waitForSelector("#form-profile");505 }, 25000);506 507 //delete profile508 test("delete profile", async () => {509 await page.waitForSelector("#btn-edit-profile");510 await page.evaluate((selector) => {511 document.querySelector(selector).click();512 }, "#btn-edit-profile");513 console.log("clicked edit profile button")514 await page.waitForSelector("#btn-initiate-delete");515 await page.evaluate((selector) => {516 document.querySelector(selector).click();517 }, "#btn-initiate-delete");518 console.log("clicked delete profile button")519 await page.waitForSelector("#btn-delete-user");520 await page.evaluate((selector) => {521 document.querySelector(selector).click();522 }, "#btn-delete-user");523 console.log("clicked confirm delete profile button")524 await page.waitForNavigation();525 await page.waitForSelector("#btn-login-nav");526 console.log("user deleted")527 })...

Full Screen

Full Screen

TripCalendar.test.js

Source:TripCalendar.test.js Github

copy

Full Screen

...31 server.kill();32 });33 test('creating widget', async () => {34 await page.goto(baseURL);35 await page.waitForSelector('.date-input');36 });37 test('waiting input-single-date selector', async () => {38 await page.goto(baseURL);39 await page.waitForSelector('.date-input');40 await page.waitForSelector('.input-single-date');41 });42 test('selectors input-back and input-back no visible', async () => {43 await page.goto(baseURL);44 await page.waitForSelector('.date-input');45 await page.waitForSelector('.input-back', { hidden: true });46 await page.waitForSelector('.input-back', { hidden: true });47 });48 test('test click input sindle date', async () => {49 await page.goto(baseURL);50 await page.waitForSelector('.date-input');51 await page.click('.input-single-date');52 await page.waitForSelector('.calendar');53 });54 test('test hide calendar', async () => {55 await page.goto(baseURL);56 await page.waitForSelector('.date-input');57 await page.click('.input-single-date');58 await page.waitForSelector('.calendar');59 await page.click('.main-title');60 await page.waitForSelector('.calendar', { hidden: true });61 });62 test('test select date', async () => {63 await page.goto(baseURL);64 await page.waitForSelector('.date-input');65 await page.click('.input-single-date');66 await page.waitForSelector('.calendar');67 const selectArrDate = await page.$$('.available');68 const input = await page.$('.input-single-date');69 await selectArrDate[3].click();70 const valueSelectDate = await page.evaluate((item) => item.dataset.date, selectArrDate[3]);71 const valueInput = await page.evaluate((item) => item.value, input);72 expect(valueInput).toBe(valueSelectDate);73 });74 test('test check salected date at calendar', async () => {75 await page.goto(baseURL);76 await page.waitForSelector('.date-input');77 await page.click('.input-single-date');78 await page.waitForSelector('.calendar');79 const selectArrDate = await page.$$('.available');80 const valueSelectDate = await page.evaluate((item) => item.dataset.date, selectArrDate[3]);81 await selectArrDate[3].click();82 await page.click('.input-single-date');83 await page.waitForSelector('.calendar');84 const activeItem = await page.$('.active');85 const activeItemDatasetDate = await page.evaluate((item) => item.dataset.date, activeItem);86 expect(activeItemDatasetDate).toEqual(valueSelectDate);87 });88 test('test input valid date and output correct visual perfomance', async () => {89 await page.goto(baseURL);90 await page.waitForSelector('.date-input');91 await page.click('.input-single-date');92 await page.type('.input-single-date', '12122021');93 await page.click('.main-title');94 const input = await page.$('.input-single-date');95 const valueDateInInput = await page.evaluate((item) => item.value, input);96 expect(valueDateInInput).toBe('12-12-2021');97 });98 test('test input invalid date', async () => {99 await page.goto(baseURL);100 await page.waitForSelector('.date-input');101 await page.click('.input-single-date');102 await page.type('.input-single-date', '666666');103 await page.click('.main-title');104 const input = await page.$('.input-single-date');105 const valueDateInInput = await page.evaluate((item) => item.value, input);106 const currentValue = moment().format('DD-MM-YYYY');107 expect(valueDateInInput).toBe(currentValue);108 });109 test('test input date less then today', async () => {110 await page.goto(baseURL);111 await page.waitForSelector('.date-input');112 await page.click('.input-single-date');113 await page.type('.input-single-date', '12122019');114 await page.click('.main-title');115 const input = await page.$('.input-single-date');116 const valueDateInInput = await page.evaluate((item) => item.value, input);117 const currentValue = moment().format('DD-MM-YYYY');118 expect(valueDateInInput).toBe(currentValue);119 });120 test('selectors input-there and input-back visible but ', async () => {121 await page.goto(baseURL);122 await page.waitForSelector('.date-input');123 await page.click('.input-checkbox');124 await page.waitForSelector('.input-single-date', { hidden: true });125 await page.waitForSelector('.input-there');126 await page.waitForSelector('.input-back');127 });128 test('test click input input-there date', async () => {129 await page.goto(baseURL);130 await page.waitForSelector('.date-input');131 await page.click('.input-checkbox');132 await page.waitForSelector('.input-there');133 await page.click('.input-there');134 await page.waitForSelector('.calendar');135 });136 test('test hide calendar input-there', async () => {137 await page.goto(baseURL);138 await page.waitForSelector('.date-input');139 await page.click('.input-checkbox');140 await page.waitForSelector('.input-there');141 await page.click('.input-there');142 await page.waitForSelector('.calendar');143 await page.click('.main-title');144 await page.waitForSelector('.calendar', { hidden: true });145 });146 test('test select date input-there', async () => {147 await page.goto(baseURL);148 await page.waitForSelector('.date-input');149 await page.click('.input-checkbox');150 await page.waitForSelector('.input-there');151 await page.click('.input-there');152 await page.waitForSelector('.calendar');153 const selectArrDate = await page.$$('.available');154 const input = await page.$('.input-there');155 await selectArrDate[3].click();156 const valueSelectDate = await page.evaluate((item) => item.dataset.date, selectArrDate[3]);157 const valueInput = await page.evaluate((item) => item.value, input);158 expect(valueInput).toBe(valueSelectDate);159 });160 test('test check salected date at calendar input-there', async () => {161 await page.goto(baseURL);162 await page.waitForSelector('.date-input');163 await page.click('.input-checkbox');164 await page.waitForSelector('.input-there');165 await page.click('.input-there');166 await page.waitForSelector('.calendar');167 const selectArrDate = await page.$$('.available');168 const valueSelectDate = await page.evaluate((item) => item.dataset.date, selectArrDate[3]);169 await selectArrDate[3].click();170 await page.click('.input-there');171 await page.waitForSelector('.calendar');172 const activeItem = await page.$('.active');173 const activeItemDatasetDate = await page.evaluate((item) => item.dataset.date, activeItem);174 expect(activeItemDatasetDate).toEqual(valueSelectDate);175 });176 test('test input valid date in input-there and output correct visual perfomance', async () => {177 await page.goto(baseURL);178 await page.waitForSelector('.date-input');179 await page.click('.input-checkbox');180 await page.waitForSelector('.input-there');181 await page.click('.input-there');182 await page.type('.input-there', '12122021');183 await page.click('.main-title');184 const input = await page.$('.input-there');185 const valueDateInInput = await page.evaluate((item) => item.value, input);186 expect(valueDateInInput).toBe('12-12-2021');187 });188 test('test input invalid date in input-there', async () => {189 await page.goto(baseURL);190 await page.waitForSelector('.date-input');191 await page.click('.input-checkbox');192 await page.waitForSelector('.input-there');193 await page.click('.input-there');194 await page.type('.input-there', '666666');195 await page.click('.main-title');196 const input = await page.$('.input-there');197 const valueDateInInput = await page.evaluate((item) => item.value, input);198 const currentValue = moment().format('DD-MM-YYYY');199 expect(valueDateInInput).toBe(currentValue);200 });201 test('test input in input-there date less then today', async () => {202 await page.goto(baseURL);203 await page.waitForSelector('.date-input');204 await page.click('.input-checkbox');205 await page.waitForSelector('.input-there');206 await page.click('.input-there');207 await page.type('.input-there', '12122019');208 await page.click('.main-title');209 const input = await page.$('.input-there');210 const valueDateInInput = await page.evaluate((item) => item.value, input);211 const currentValue = moment().format('DD-MM-YYYY');212 expect(valueDateInInput).toBe(currentValue);213 });214 test('test click input input-back date', async () => {215 await page.goto(baseURL);216 await page.waitForSelector('.date-input');217 await page.click('.input-checkbox');218 await page.waitForSelector('.input-back');219 await page.click('.input-back');220 await page.waitForSelector('.calendar');221 });222 test('test hide calendar input-back', async () => {223 await page.goto(baseURL);224 await page.waitForSelector('.date-input');225 await page.click('.input-checkbox');226 await page.waitForSelector('.input-back');227 await page.click('.input-back');228 await page.waitForSelector('.calendar');229 await page.click('.main-title');230 await page.waitForSelector('.calendar', { hidden: true });231 });232 test('test select date input-back', async () => {233 await page.goto(baseURL);234 await page.waitForSelector('.date-input');235 await page.click('.input-checkbox');236 await page.waitForSelector('.input-back');237 await page.click('.input-there');238 await page.waitForSelector('.calendar');239 const selectArrDateThere = await page.$$('.available');240 await selectArrDateThere[3].click();241 await page.click('.input-back');242 await page.waitForSelector('.calendar');243 const selectArrDate = await page.$$('.available');244 const input = await page.$('.input-back');245 await selectArrDate[3].click();246 const valueSelectDate = await page.evaluate((item) => item.dataset.date, selectArrDate[3]);247 const valueInput = await page.evaluate((item) => item.value, input);248 expect(valueInput).toBe(valueSelectDate);249 });250 test('test check salected date at calendar input-back', async () => {251 await page.goto(baseURL);252 await page.waitForSelector('.date-input');253 await page.click('.input-checkbox');254 await page.waitForSelector('.input-back');255 await page.click('.input-there');256 await page.waitForSelector('.calendar');257 const selectArrDateThere = await page.$$('.available');258 await selectArrDateThere[3].click();259 await page.click('.input-back');260 await page.waitForSelector('.calendar');261 const selectArrDate = await page.$$('.available');262 const valueSelectDate = await page.evaluate((item) => item.dataset.date, selectArrDate[3]);263 await selectArrDate[3].click();264 await page.click('.input-back');265 await page.waitForSelector('.calendar');266 const activeItem = await page.$('.active');267 const activeItemDatasetDate = await page.evaluate((item) => item.dataset.date, activeItem);268 expect(activeItemDatasetDate).toEqual(valueSelectDate);269 });270 test('test input valid date in input-back and output correct visual perfomance', async () => {271 await page.goto(baseURL);272 await page.waitForSelector('.date-input');273 await page.click('.input-checkbox');274 await page.waitForSelector('.input-back');275 await page.click('.input-there');276 await page.waitForSelector('.calendar');277 const selectArrDateThere = await page.$$('.available');278 await selectArrDateThere[3].click();279 await page.click('.input-back');280 await page.type('.input-back', '12122021');281 await page.click('.main-title');282 const input = await page.$('.input-back');283 const valueDateInInput = await page.evaluate((item) => item.value, input);284 expect(valueDateInInput).toBe('12-12-2021');285 });286 test('test input invalid date in input-back and get correct date equal to input-there date', async () => {287 await page.goto(baseURL);288 await page.waitForSelector('.date-input');289 await page.click('.input-checkbox');290 await page.waitForSelector('.input-back');291 await page.click('.input-there');292 await page.waitForSelector('.calendar');293 const selectArrDateThere = await page.$$('.available');294 const valueSelectDateThere = await page.evaluate(295 (item) => item.dataset.date, selectArrDateThere[3],296 );297 await selectArrDateThere[3].click();298 await page.click('.input-back');299 await page.type('.input-back', '666666');300 await page.click('.main-title');301 const input = await page.$('.input-back');302 const valueDateInInput = await page.evaluate((item) => item.value, input);303 expect(valueDateInInput).toBe(valueSelectDateThere);304 });305 test('test input invalid date in input-back, if input-there is empty, get correct date equal to current date', async () => {306 await page.goto(baseURL);307 await page.waitForSelector('.date-input');308 await page.click('.input-checkbox');309 await page.waitForSelector('.input-back');310 await page.click('.input-there');311 await page.waitForSelector('.calendar');312 const selectArrDateThere = await page.$$('.available');313 const valueSelectDateThere = await page.evaluate(314 (item) => item.dataset.date, selectArrDateThere[3],315 );316 await selectArrDateThere[3].click();317 await page.click('.input-back');318 await page.type('.input-back', '666666');319 await page.click('.main-title');320 const input = await page.$('.input-back');321 const valueDateInInput = await page.evaluate((item) => item.value, input);322 expect(valueDateInInput).toBe(valueSelectDateThere);323 });324 test('test input in input-back date less then today with empty input-there', async () => {325 await page.goto(baseURL);326 await page.waitForSelector('.date-input');327 await page.click('.input-checkbox');328 await page.waitForSelector('.input-back');329 await page.click('.input-back');330 await page.type('.input-back', '12122019');331 await page.click('.main-title');332 const input = await page.$('.input-back');333 const valueDateInInput = await page.evaluate((item) => item.value, input);334 const currentValue = moment().format('DD-MM-YYYY');335 expect(valueDateInInput).toBe(currentValue);336 });337 test('test input in input-back date less then input-there', async () => {338 await page.goto(baseURL);339 await page.waitForSelector('.date-input');340 await page.click('.input-checkbox');341 await page.waitForSelector('.input-back');342 await page.click('.input-there');343 await page.waitForSelector('.calendar');344 const selectArrDateThere = await page.$$('.available');345 const valueSelectDateThere = await page.evaluate(346 (item) => item.dataset.date, selectArrDateThere[3],347 );348 await selectArrDateThere[3].click();349 await page.click('.input-back');350 await page.type('.input-back', '12122019');351 await page.click('.main-title');352 const input = await page.$('.input-back');353 const valueDateInInput = await page.evaluate((item) => item.value, input);354 expect(valueDateInInput).toBe(valueSelectDateThere);355 });...

Full Screen

Full Screen

weather-app.js

Source:weather-app.js Github

copy

Full Screen

...23 },24} = require("../constants");25const validateMainWidget = async ({ page }) => {26 try {27 await page.waitForSelector(MAIN_WIDGET);28 await page.waitFor(1500);29 return true;30 } catch (error) {31 console.log("Error", error);32 return false;33 }34};35const validateHeadquarterOnMainWidget = async ({ page }) => {36 await page.waitForSelector(MAIN_WIDGET_HEADQUARTER);37 await page.waitFor(1500);38 const widget = await page.$eval(39 MAIN_WIDGET_HEADQUARTER,40 (el) => el.innerText41 );42 return widget;43};44const validateIconOnMainWidget = async ({ page }) => {45 try {46 await page.waitForSelector(MAIN_WIDGET_ICON);47 await page.waitFor(1500);48 return true;49 } catch (error) {50 console.log("Error", error);51 return false;52 }53};54const validateTemperatureOnMainWidget = async ({ page }) => {55 await page.waitForSelector(MAIN_WIDGET_TEMPERATURE);56 await page.waitFor(1500);57 const widget = await page.$eval(58 MAIN_WIDGET_TEMPERATURE,59 (el) => el.innerText60 );61 return widget;62};63const validateHumidityOnMainWidget = async ({ page }) => {64 await page.waitForSelector(MAIN_WIDGET_HUMIDITY);65 await page.waitFor(1500);66 const widget = await page.$eval(MAIN_WIDGET_HUMIDITY, (el) => el.innerText);67 return widget;68};69const validateWindOnMainWidget = async ({ page }) => {70 await page.waitForSelector(MAIN_WIDGET_WIND);71 await page.waitFor(1500);72 const widget = await page.$eval(MAIN_WIDGET_WIND, (el) => el.innerText);73 return widget;74};75const validateCarouselWidget = async ({ page }) => {76 await page.waitForSelector(CAROUSEL_WIDGET);77 await page.waitFor(1500);78 const widget = await page.$eval(CAROUSEL_WIDGET, (el) => el.textContent);79 return widget;80};81const validateItemsOnWidgetCarousel = async ({ page }) => {82 await page.waitForSelector(CAROUSEL_WIDGET_ITEM);83 await page.waitFor(1500);84 const widget = await page.$eval(CAROUSEL_WIDGET_ITEM, () =>85 Array.from(86 document.querySelectorAll("#widget-carousel .widget-carousel-item"),87 (el) => el.textContent88 )89 );90 return widget;91};92const validateTempItemOnWidgetCarousel = async ({ page }) => {93 await page.waitForSelector(CAROUSEL_WIDGET_ITEM);94 await page.waitFor(1500);95 const widget = await page.$eval(CAROUSEL_WIDGET_ITEM, () =>96 Array.from(97 document.querySelectorAll(98 "#widget-carousel .widget-carousel-item .widget-temperature"99 ),100 (el) => el.textContent101 )102 );103 return widget;104};105const validateHumidityItemOnWidgetCarousel = async ({ page }) => {106 await page.waitForSelector(CAROUSEL_WIDGET_ITEM);107 await page.waitFor(1500);108 const widget = await page.$eval(CAROUSEL_WIDGET_ITEM, () =>109 Array.from(110 document.querySelectorAll(111 "#widget-carousel .widget-carousel-item .widget-humidity"112 ),113 (el) => el.textContent114 )115 );116 return widget;117};118const validateWindItemOnWidgetCarousel = async ({ page }) => {119 await page.waitForSelector(CAROUSEL_WIDGET_ITEM);120 await page.waitFor(1500);121 const widget = await page.$eval(CAROUSEL_WIDGET_ITEM, () =>122 Array.from(123 document.querySelectorAll(124 "#widget-carousel .widget-carousel-item .widget-wind"125 ),126 (el) => el.textContent127 )128 );129 return widget;130};131const validateFavoritesWidget = async ({ page }) => {132 try {133 await page.waitForSelector(FAVORITES_WIDGET);134 await page.waitFor(1500);135 return true;136 } catch (error) {137 console.log(error);138 return false;139 }140};141const validateItemsOnFavoritesWidget = async ({ page }) => {142 await page.waitForSelector(FAVORITES_WIDGET_CARD);143 await page.waitFor(1500);144 const widget = await page.$eval(FAVORITES_WIDGET_CARD, () =>145 Array.from(146 document.querySelectorAll("#widget-favorite .widget-card"),147 (el) => el.textContent148 )149 );150 return widget;151};152const validateItemsByNameOnFavoritesWidget = async ({ page }) => {153 await page.waitForSelector(FAVORITES_WIDGET_CARD_NAME);154 await page.waitFor(1500);155 const widget = await page.$eval(FAVORITES_WIDGET_CARD_NAME, () =>156 Array.from(157 document.querySelectorAll(158 "#widget-favorite .widget-card .widget-headquarter-name"159 ),160 (el) => el.textContent161 )162 );163 return widget;164};165const validateItemsByTempOnFavoritesWidget = async ({ page }) => {166 await page.waitForSelector(FAVORITES_WIDGET_CARD);167 await page.waitFor(1500);168 const widget = await page.$eval(FAVORITES_WIDGET_CARD, () =>169 Array.from(170 document.querySelectorAll(171 "#widget-favorite .widget-card .widget-temperature"172 ),173 (el) => el.textContent174 )175 );176 return widget;177};178const validateItemsByHumidityOnFavoritesWidget = async ({ page }) => {179 await page.waitForSelector(FAVORITES_WIDGET_CARD);180 await page.waitFor(1500);181 const widget = await page.$eval(FAVORITES_WIDGET_CARD, () =>182 Array.from(183 document.querySelectorAll(184 "#widget-favorite .widget-card .widget-humidity"185 ),186 (el) => el.textContent187 )188 );189 return widget;190};191const validateItemsByWindOnFavoritesWidget = async ({ page }) => {192 await page.waitForSelector(FAVORITES_WIDGET_CARD);193 await page.waitFor(1500);194 const widget = await page.$eval(FAVORITES_WIDGET_CARD, () =>195 Array.from(196 document.querySelectorAll("#widget-favorite .widget-card .widget-wind"),197 (el) => el.textContent198 )199 );200 return widget;201};202const validateItemsByIconOnFavoritesWidget = async ({ page }) => {203 await page.waitForSelector(FAVORITES_WIDGET_CARD);204 await page.waitFor(1500);205 const widget = await page.$eval(FAVORITES_WIDGET_CARD, () =>206 Array.from(207 document.querySelectorAll("#widget-favorite .widget-card i.widget-icon"),208 () => true209 )210 );211 return widget;212};213const validateSuggestsWidget = async ({ page }) => {214 try {215 await page.waitForSelector(SUGGESTS_WIDGET);216 await page.waitFor(1500);217 return true;218 } catch (error) {219 console.log(error);220 return false;221 }222};223const validateIconOnSuggestsWidget = async ({ page }) => {224 try {225 await page.waitForSelector(SUGGESTS_WIDGET_ICON);226 await page.waitFor(1500);227 return true;228 } catch (error) {229 console.log(error);230 return false;231 }232};233const validateHeadquarterOnSuggestsWidget = async ({ page }) => {234 await page.waitForSelector(SUGGESTS_WIDGET_NAME);235 await page.waitFor(1500);236 const widget = await page.$eval(SUGGESTS_WIDGET_NAME, (el) => el.innerText);237 return widget;238};239const validateTemperatureOnSuggestsWidget = async ({ page }) => {240 await page.waitForSelector(SUGGESTS_WIDGET_TEMPERATURE);241 await page.waitFor(1500);242 const widget = await page.$eval(243 SUGGESTS_WIDGET_TEMPERATURE,244 (el) => el.innerText245 );246 return widget;247};248const validateHumidityOnSuggestsWidget = async ({ page }) => {249 await page.waitForSelector(SUGGESTS_WIDGET_HUMIDITY);250 await page.waitFor(1500);251 const widget = await page.$eval(252 SUGGESTS_WIDGET_HUMIDITY,253 (el) => el.innerText254 );255 return widget;256};257const validateWindOnSuggestsWidget = async ({ page }) => {258 await page.waitForSelector(SUGGESTS_WIDGET_WIND);259 await page.waitFor(1500);260 const widget = await page.$eval(SUGGESTS_WIDGET_WIND, (el) => el.innerText);261 return widget;262};263const validateDayOnSuggestsWidget = async ({ page }) => {264 await page.waitForSelector(SUGGESTS_WIDGET_DAY);265 await page.waitFor(1500);266 const widget = await page.$eval(SUGGESTS_WIDGET_DAY, (el) => el.innerText);267 return widget;268};269const validateCitiesWidget = async ({ page }) => {270 await page.waitForSelector(CITIES_WIDGET);271 await page.waitFor(1500);272 const widget = await page.$eval(CITIES_WIDGET, (el) => el.textContent);273 return widget;274};275const validateListCitiesWidget = async ({ page }) => {276 await page.waitForSelector(CITIES_WIDGET_CARD);277 await page.waitFor(1500);278 const widget = await page.$eval(CITIES_WIDGET_CARD, () =>279 Array.from(280 document.querySelectorAll("#widget-cities .widget-card"),281 (el) => el.textContent282 )283 );284 return widget;285};286const validateListByNameCitiesWidget = async ({ page }) => {287 await page.waitForSelector(CITIES_WIDGET_CARD);288 await page.waitFor(1500);289 const widget = await page.$eval(CITIES_WIDGET_CARD, () =>290 Array.from(291 document.querySelectorAll(292 "#widget-cities .widget-card .widget-city-name"293 ),294 (el) => el.textContent295 )296 );297 return widget;298};299const validateListByAnchorWidgetCity = async ({ page }) => {300 await page.waitForSelector(CITIES_WIDGET_CARD);301 await page.waitFor(1500);302 const widget = await page.$eval(CITIES_WIDGET_CARD, () =>303 Array.from(304 document.querySelectorAll("#widget-cities .widget-card a"),305 (el) => el.textContent306 )307 );308 return widget;309};310module.exports = {311 validateMainWidget,312 validateHeadquarterOnMainWidget,313 validateIconOnMainWidget,314 validateTemperatureOnMainWidget,...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...77 );78 // Go to the target web79 await page.goto(siteUrl);80 // Login user81 await page.waitForSelector('#login');82 await page.type('#username', userName);83 await page.type('#password', password);84 await page.click('#loginbtn');85 // Open navigation drawer86 const navDrawer = await page.$('.nav-link');87 const expanded = await page.evaluate((obj) => {88 return obj.getAttribute('aria-expanded');89 }, navDrawer);90 if (expanded === 'false') {91 await page.click('.nav-link');92 }93 // Click site administration94 await page.waitForSelector('a[data-key=sitesettings]');95 await clickByText(page, 'Site administration', 'span');96 // Click courses97 await page.waitForSelector('input[name=search');98 await clickByText(page, 'Courses');99 // Open manage courses and categories100 await clickByText(page, 'Manage courses and categories');101 // await page.waitForTimeout(1000);102 // Create new course103 await page.waitForXPath(104 '//*[@class="listing-actions course-listing-actions"]/a'105 );106 let courseActions = await page.$x(107 '//*[@class="listing-actions course-listing-actions"]/a'108 );109 await courseActions[0].click();110 await page.waitForSelector('input[name=saveandreturn]');111 await page.type('input[name=fullname]', courseFullName);112 await page.type('input[name=shortname]', courseShortName);113 await page.click('input[name=saveandreturn]');114 // Go to site home115 await page.waitForSelector('a[data-key=home]');116 await clickByText(page, 'Site home', 'span');117 await page.waitForTimeout(2000);118 // Cick restore to restore a quiz119 await page.waitForSelector('#dropdown-2');120 await page.click('#dropdown-2');121 await clickByText(page, 'Restore');122 // Upload file123 await page.waitForSelector('input[name=backupfilechoose]');124 await page.click('input[name=backupfilechoose]');125 await clickByText(page, 'Upload a file', 'span');126 await page.waitForSelector('input[type=file]');127 // Get the ElementHandle of the selector above128 const restoreQuizInputUploadHandle = await page.$('input[type=file]');129 // Sets the value of the file input to fileToUpload130 restoreQuizInputUploadHandle.uploadFile(restoreQuizFilePath);131 // Upload this file132 await page.waitForSelector('input[name=author]');133 await clickByText(page, 'Upload this file', 'button');134 // Click restore button135 await page.waitForXPath('//*[@id="id_submitbutton"]');136 let restoreButton = await page.$x('//*[@id="id_submitbutton"]');137 await restoreButton[0].click();138 await page.waitForTimeout(2000);139 // Click continue button140 await page.waitForSelector('button[type=submit]');141 await page.click('button[type=submit]');142 // Search a course143 await page.waitForSelector('input[name=search]');144 await page.type('input[name=search]', courseShortName);145 await page.click('input[name=searchcourses]');146 await page.click('input[name=targetid]');147 // Click continue button148 await page.waitForSelector('input[value=Continue]');149 await page.click('input[value=Continue]');150 // Click submit button151 await page.waitForSelector('input[name=submitbutton]');152 await page.click('input[name=submitbutton]');153 // Click submit button154 await page.waitForSelector('input[name=submitbutton]');155 await page.click('input[name=submitbutton]');156 // Click submit button157 await page.waitForSelector('input[name=submitbutton]');158 await page.click('input[name=submitbutton]');159 // Click submit button160 await page.waitForSelector('button[type=submit]');161 await page.click('button[type=submit]');162 // Get a quiz url163 const quizUrl = await page.url();164 console.log(`Quiz URL: ${quizUrl}`);165 // Save in a file166 fs.writeFile(outputQuizURLFilePath, quizUrl, function (err) {167 if (err) return console.log(err);168 console.log(`Quiz URL was written successfully ${moment().format()}`);169 });170 // Go to site administration171 await page.waitForSelector('a[data-key=sitesettings]');172 await clickByText(page, 'Site administration', 'span');173 // Click Users174 await page.waitForSelector('input[name=query]');175 await clickByText(page, 'Users');176 // Click upload users177 let uploadUsers = await page.$x(178 '//*[@id="linkusers"]/div/div[2]/div[2]/ul/li[7]/a'179 );180 await uploadUsers[0].click();181 // Enrol users182 await page.waitForSelector('input[name=userfilechoose]');183 await page.click('input[name=userfilechoose]');184 await page.waitForSelector('input[type=file]');185 // Get the ElementHandle of the selector above186 const uploadUsersInputUploadHandle = await page.$('input[type=file]');187 // Sets the value of the file input to fileToUpload188 uploadUsersInputUploadHandle.uploadFile(outputUsersFilePath);189 // Upload this file190 await page.waitForSelector('input[name=author]');191 await clickByText(page, 'Upload this file', 'button');192 await page.waitForTimeout(2000);193 // Click submit button194 await page.waitForXPath('//*[@id="id_submitbutton"]');195 let submitButton = await page.$x('//*[@id="id_submitbutton"]');196 await submitButton[0].click();197 await page.waitForTimeout(2000);198 // Click continue button199 await page.waitForSelector('#id_uutype');200 await page.select('#id_uutype', '3');201 await page.click('input[name=submitbutton]');202 // Click continue button203 await page.waitForSelector('button[type=submit]');204 await page.click('button[type=submit]');205 //Implicit wait..206 await page.waitForTimeout(20000);207 // Magic ends208 console.log(`Execution completed successfully at ${moment().format()}`);209 // Close the browser210 await browser.close();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2describe("test", () => {3 let browser;4 let page;5 beforeAll(async () => {6 browser = await qawolf.launch();7 page = await qawolf.createPage(browser);8 });9 afterAll(async () => {10 await qawolf.stopVideos();11 await browser.close();12 });13 it("test", async () => {14 await page.waitForSelector("input[name='q']");15 await page.type("input[name='q']", "qawolf");16 await page.keyboard.press("Enter");17 await page.waitForSelector("h3");18 await qawolf.scroll(page, "html", { x: 0, y: 100 });19 });20});21const puppeteer = require("puppeteer");22describe("test", () => {23 let browser;24 let page;25 beforeAll(async () => {26 browser = await puppeteer.launch();27 page = await browser.newPage();28 });29 afterAll(async () => {30 await browser.close();31 });32 it("test", async () => {33 await page.waitForSelector("input[name='q']");34 await page.type("input[name='q']", "puppeteer");35 await page.keyboard.press("Enter");36 await page.waitForSelector("h3");37 await page.evaluate(() => {38 window.scrollBy(0, 100);39 });40 });41});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require('qawolf');2const selectors = require('./selectors/test');3describe('test', () => {4 let browser;5 let page;6 beforeAll(async () => {7 browser = await launch({slowMo: 50});8 });9 beforeEach(async () => {10 page = await browser.newPage();11 });12 afterAll(async () => {13 await browser.close();14 });15 it('test', async () => {16 await page.waitForSelector(selectors[0]);17 await page.click(selectors[0]);18 await page.waitForSelector(selectors[1]);19 await page.click(selectors[1]);20 await page.waitForSelector(selectors[2]);21 await page.click(selectors[2]);22 await page.waitForSelector(selectors[3]);23 await page.click(selectors[3]);24 await page.waitForSelector(selectors[4]);25 await page.click(selectors[4]);26 await page.waitForSelector(selectors[5]);27 await page.click(selectors[5]);28 await page.waitForSelector(selectors[6]);29 await page.click(selectors[6]);30 await page.waitForSelector(selectors[7]);31 await page.click(selectors[7]);32 await page.waitForSelector(selectors[8]);33 await page.click(selectors[8]);34 await page.waitForSelector(selectors[9]);35 await page.click(selectors[9]);36 await page.waitForSelector(selectors[10]);37 await page.click(selectors[10]);38 await page.waitForSelector(selectors[11]);39 await page.click(selectors[11]);40 await page.waitForSelector(selectors[12]);41 await page.click(selectors[12]);42 await page.waitForSelector(selectors[13]);43 await page.click(selectors[13]);44 await page.waitForSelector(selectors[14]);45 await page.click(selectors[14]);46 await page.waitForSelector(selectors[15]);47 await page.click(selectors[15]);48 await page.waitForSelector(selectors[16]);49 await page.click(selectors[16]);50 await page.waitForSelector(selectors[17]);51 await page.click(selectors[17]);52 await page.waitForSelector(selectors[18]);53 await page.click(selectors[18]);54 await page.waitForSelector(selectors[19]);55 await page.click(selectors[19]);56 await page.waitForSelector(selectors[20]);

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const { chromium } = require("playwright");3describe("test", () => {4 let browser;5 let context;6 let page;7 beforeAll(async () => {8 browser = await qawolf.launch(chromium);9 });10 beforeEach(async () => {11 context = await browser.newContext();12 page = await context.newPage();13 await qawolf.register(page);14 });15 afterEach(async () => {16 await qawolf.stopVideos();17 await page.close();18 await context.close();19 });20 afterAll(async () => {21 await browser.close();22 });23 it("test", async () => {24 await qawolf.waitForSelector(page, "input[type='text']");25 await page.fill("input[type='text']", "Hello World!");26 await page.press("input[type='text']", "Enter");27 await qawolf.waitForSelector(page, "text=Hello World!");28 });29});30const { chromium } = require("playwright");31describe("test", () => {32 let browser;33 let context;34 let page;35 beforeAll(async () => {36 browser = await chromium.launch();37 });38 beforeEach(async () => {39 context = await browser.newContext();40 page = await context.newPage();41 });42 afterEach(async () => {43 await page.close();44 await context.close();45 });46 afterAll(async () => {47 await browser.close();48 });49 it("test", async () => {50 await page.waitForSelector("input[type='text']");51 await page.fill("input[type='text']", "Hello World!");52 await page.press("input[type='text']", "Enter");53 await page.waitForSelector("text=Hello World!");54 });55});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require("qawolf");2const selectors = require("./selectors/test.json");3const assert = require("assert");4(async () => {5 const browser = await launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.click(selectors["input[name=\"q\"]"]);9 await page.fill(selectors["input[name=\"q\"]"], "qawolf");10 await page.press(selectors["input[name=\"q\"]"], "Enter");11 await page.click(selectors["text=QAWolf: Browser automation tool for developers"]);12 await page.click(selectors["text=QAWolf: Browser automation tool for developers"]);13 await page.click(selectors["text=QAWolf: Browser automation tool for developers"]);14 await page.click(selectors["text=QAWolf: Browser automation tool for developers"]);15 await page.click(selectors["text=QAWolf: Browser automation tool for developers"]);16 await page.click(selectors["text=QAWolf: Browser automation tool for developers"]);17 await page.click(selectors["text=QAWolf: Browser automation tool for developers"]);18 await page.click(selectors["text=QAWolf: Browser automation tool for developers"]);19 await page.click(selectors["text=QAWolf: Browser automation tool for developers"]);20 await page.click(selectors["text=QAWolf: Browser automation tool for developers"]);

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const selectors = require("./selectors/test.json");3const config = require("./qawolf.config");4describe("test", () => {5 let browser;6 let page;7 beforeAll(async () => {8 browser = await qawolf.launch();9 });10 beforeEach(async () => {11 page = await qawolf.createPage(browser, config);12 });13 afterEach(async () => {14 await qawolf.stopVideos();15 await page.close();16 });17 afterAll(async () => {18 await browser.close();19 });20 test("test", async () => {21 await page.click(selectors["input[name='q']"]);22 await page.type(selectors["input[name='q']"], "test");23 await page.waitForSelector(selectors["input[name='q']"]);24 await page.click(selectors["input[name='q']"]);25 await page.type(selectors["input[name='q']"], "test");26 await page.waitForSelector(selectors["input[name='q']"]);27 await page.click(selectors["input[name='q']"]);28 await page.type(selectors["input[name='q']"], "test");29 await page.waitForSelector(selectors["input[name='q']"]);30 await page.click(selectors["input[name='q']"]);31 await page.type(selectors["input[name='q']"], "test");32 await page.waitForSelector(selectors["input[name='q']"]);33 await page.click(selectors["input[name='q']"]);34 await page.type(selectors["input[name='q']"], "test");35 await page.waitForSelector(selectors["input[name='q']"]);36 await page.click(selectors["input[name='q']"]);37 await page.type(selectors["input[name='q']"], "test");38 await page.waitForSelector(selectors["input[name='q']"]);39 await page.click(selectors["input[name='q']"]);40 await page.type(selectors["input[name='q']"], "test");41 await page.waitForSelector(selectors["input[name='q']"]);42 await page.click(selectors["input[name='q']"]);43 await page.type(selectors["input[name='q']"], "test");44 await page.waitForSelector(selectors["input[name='q']"]);45 await page.click(selectors["input[name='q']"]);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require("qawolf");2const selectors = require("../selectors/test.json");3const config = require("../qawolf.config.js");4(async () => {5 const browser = await launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.click(selectors["input[name=q]"]);9 await page.fill(selectors["input[name=q]"], "Hello World");10 await page.click(selectors["input[name=q]"]);11 await page.click(selectors["input[name=q]"]);12 await page.fill(selectors["input[name=q]"], "Hello World");13 await page.click(selectors["input[name=q]"]);14 await page.press(selectors["input[name=q]"], "Enter");

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require("qawolf");2const selectors = require("./selectors/test.json");3launch({4 onReady: async (page, browser) => {5 await page.waitForSelector(".gLFyf.gsfi");6 await page.type(".gLFyf.gsfi", "qawolf");7 await page.keyboard.press("Enter");8 await page.waitForSelector(".LC20lb.DKV0Md");9 await page.click(".LC20lb.DKV0Md");10 },11});12{13 "gLFyf gsfi": {14 },15 "LC20lb DKV0Md": {16 }17}

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const selectors = require("../selectors/test");3describe("test", () => {4 let browser;5 let page;6 beforeAll(async () => {7 browser = await qawolf.launch();8 page = await qawolf.createPage(browser);9 });10 afterAll(async () => {11 await qawolf.stopVideos();12 await browser.close();13 });14 it("test", async () => {15 await page.click(selectors["search"]);16 await page.type(selectors["search"], "test");17 await page.waitForSelector(selectors["search"]);18 await qawolf.scroll(page, "html", { x: 0, y: 0 });19 await qawolf.scroll(page, "html", { x: 0, y: 0 });20 await qawolf.scroll(page, "html", { x: 0, y: 0 });21 await qawolf.scroll(page, "html", { x: 0, y: 0 });22 await qawolf.scroll(page, "html", { x: 0, y: 0 });23 await page.waitForSelector(selectors["search"]);24 await qawolf.scroll(page, "html", { x: 0, y: 0 });25 await page.waitForSelector(selectors["search"]);26 await qawolf.scroll(page, "html", { x: 0, y: 0 });27 await page.waitForSelector(selectors["search"]);28 await qawolf.scroll(page, "html", { x: 0, y: 0 });29 await page.waitForSelector(selectors["search"]);30 await qawolf.scroll(page, "html", { x: 0, y: 0 });31 await page.waitForSelector(selectors["search"]);32 await qawolf.scroll(page, "html", { x: 0, y: 0 });33 await page.waitForSelector(selectors["search"]);34 await qawolf.scroll(page, "html", { x: 0, y: 0 });35 await page.waitForSelector(selectors["search"]);36 await qawolf.scroll(page, "html", { x: 0, y: 0 });37 await page.waitForSelector(selectors["search"]);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parse } = require('xpath');2const { DOMParser } = require('xmldom');3const xml = `<html><body><div><p>foo</p><p>bar</p></div></body></html>`;4const doc = new DOMParser().parseFromString(xml);5console.log(nodes.map(node => node.toString()));6const selectors = nodes.map(node => node.toString());7console.log(selectors);8const code = selectors.map(selector => `await page.waitForSelector("${selector}");`).join(`9`);10console.log(code);11await page.waitForSelector("<p>foo</p>");12await page.waitForSelector("<p>bar</p>");

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 qawolf 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