Best JavaScript code snippet using qawolf
e2e.test.js
Source:e2e.test.js
...54 await page.waitForTimeout(interval);55 await page.click('text=Register');56 await page.waitForTimeout(interval);57 await page.waitForSelector('form');58 await page.fill('[name="email"]', data.email);59 await page.fill('[name="password"]', data.password);60 await page.fill('[name="conf-pass"]', data.password);61 const [request] = await Promise.all([62 onRequest(),63 page.click('[type="submit"]')64 ]);65 const postData = JSON.parse(request.postData());66 expect(postData.email).to.equal(data.email);67 expect(postData.password).to.equal(data.password);68 });69 it('Login makes correct API call [ 5 Points ]', async () => {70 const data = mockData.users[0];71 const { post } = await handle(endpoints.login);72 const { onRequest } = post(data);73 await page.goto(host);74 await page.waitForTimeout(interval);75 await page.click('text=Login');76 await page.waitForTimeout(interval);77 await page.waitForSelector('form');78 await page.fill('[name="email"]', data.email);79 await page.fill('[name="password"]', data.password);80 const [request] = await Promise.all([81 onRequest(),82 page.click('[type="submit"]')83 ]);84 const postData = JSON.parse(request.postData());85 expect(postData.email).to.equal(data.email);86 expect(postData.password).to.equal(data.password);87 });88 it('Logout makes correct API call [ 5 Points ]', async () => {89 const data = mockData.users[0];90 const { post } = await handle(endpoints.login);91 const { get } = await handle(endpoints.logout);92 const { onResponse } = post(data);93 const { onRequest } = get('', { json: false, status: 204 });94 await page.goto(host);95 await page.click('text=Login');96 await page.waitForTimeout(interval);97 await page.waitForSelector('form');98 await page.fill('[name="email"]', data.email);99 await page.fill('[name="password"]', data.password);100 await Promise.all([101 onResponse(),102 page.click('[type="submit"]')103 ]);104 await page.waitForTimeout(interval);105 const [request] = await Promise.all([106 onRequest(),107 page.click('nav >> text=Logout')108 ]);109 const token = request.headers()['x-authorization'];110 expect(request.method()).to.equal('GET');111 expect(token).to.equal(data.accessToken);112 });113 });114 describe('Navigation bar [ 10 Points ]', () => {115 it('Logged user should see correct navigation [ 5 Points ]', async () => {116 // Login user117 const data = mockData.users[0];118 await page.goto(host);119 await page.waitForTimeout(interval);120 await page.click('text=Login');121 await page.waitForTimeout(interval);122 await page.waitForSelector('form');123 await page.fill('[name="email"]', data.email);124 await page.fill('[name="password"]', data.password);125 await page.click('[type="submit"]');126 //Test for navigation127 await page.waitForTimeout(interval);128 expect(await page.isVisible('nav >> text=Home')).to.be.true;129 expect(await page.isVisible('nav >> text=Catalog')).to.be.true;130 expect(await page.isVisible('nav >> text=Search')).to.be.true;131 expect(await page.isVisible('nav >> text=Create Album')).to.be.true;132 expect(await page.isVisible('nav >> text=Logout')).to.be.true;133 expect(await page.isVisible('nav >> text=Login')).to.be.false;134 expect(await page.isVisible('nav >> text=Register')).to.be.false;135 });136 it('Guest user should see correct navigation [ 5 Points ]', async () => {137 await page.goto(host);138 await page.waitForTimeout(interval);139 expect(await page.isVisible('nav >> text=Home')).to.be.true;140 expect(await page.isVisible('nav >> text=Search')).to.be.true;141 expect(await page.isVisible('nav >> text=Catalog')).to.be.true;142 expect(await page.isVisible('nav >> text=Create Album')).to.be.false;143 expect(await page.isVisible('nav >> text=Logout')).to.be.false;144 expect(await page.isVisible('nav >> text=Login')).to.be.true;145 expect(await page.isVisible('nav >> text=Register')).to.be.true;146 });147 });148 describe('Home Page [ 10 Points ]', () => {149 it('Show home page - Welcome [ 5 Points ]', async () => {150 await page.goto(host);151 await page.waitForTimeout(interval);152 expect(await page.isVisible('text=Welcome to')).to.be.true;153 });154 it('Show home page - Name [ 5 Points ]', async () => {155 await page.goto(host);156 await page.waitForTimeout(interval);157 expect(await page.isVisible('text=My Music Application!')).to.be.true;158 });159 });160 describe('CRUD [ 50 Points ]', () => {161 // Login user162 beforeEach(async () => {163 const data = mockData.users[0];164 await page.goto(host);165 await page.waitForTimeout(interval);166 await page.click('text=Login');167 await page.waitForTimeout(interval);168 await page.waitForSelector('form');169 await page.fill('[name="email"]', data.email);170 await page.fill('[name="password"]', data.password);171 await page.click('[type="submit"]');172 await page.waitForTimeout(interval);173 });174 it('Create does NOT work with empty fields [ 5 Points ]', async () => {175 const { post } = await handle(endpoints.create);176 const isCalled = post().isHandled;177 await page.click('text=Create Album');178 await page.waitForTimeout(interval);179 await page.waitForSelector('form');180 page.click('[type="submit"]');181 await page.waitForTimeout(interval);182 expect(isCalled()).to.be.false;183 });184 it('Create makes correct API call for logged in user [ 10 Points ]', async () => {185 const data = mockData.catalog[0];186 const { post } = await handle(endpoints.create);187 const { onRequest } = post();188 await page.click('text=Create Album');189 await page.waitForTimeout(interval);190 await page.waitForSelector('form');191 await page.fill('[name="name"]', data.name);192 await page.fill('[name="imgUrl"]', data.imgUrl);193 await page.fill('[name="price"]', data.price);194 await page.fill('[name="releaseDate"]', data.releaseDate);195 await page.fill('[name="artist"]', data.artist);196 await page.fill('[name="genre"]', data.genre);197 await page.fill('[name="description"]', data.description);198 const [request] = await Promise.all([199 onRequest(),200 page.click('[type="submit"]')201 ]);202 const postData = JSON.parse(request.postData());203 expect(postData.name).to.equal(data.name);204 expect(postData.price).to.equal(data.price);205 expect(postData.artist).to.equal(data.artist);206 expect(postData.genre).to.equal(data.genre);207 expect(postData.description).to.equal(data.description);208 });209 it('Non-author does NOT see delete and edit buttons [ 5 Points ]', async () => {210 const data = mockData.catalog[2];211 const { get } = await handle(endpoints.details(data._id));212 get(data);213 await page.click('text=Catalog');214 await page.waitForTimeout(interval);215 await page.waitForSelector('#catalogPage');216 await page.click(`.card-box:has-text("Name: ${data.name}") >> #details`);217 expect(await page.isVisible('text="Delete"')).to.be.false;218 expect(await page.isVisible('text="Edit"')).to.be.false;219 });220 it('Author see delete and edit buttons [ 5 Points ]', async () => {221 const data = mockData.catalog[0];222 const { get } = await handle(endpoints.delete(data._id));223 get(data);224 await page.click('text=Catalog');225 await page.waitForTimeout(interval);226 await page.waitForSelector('#catalogPage');227 await page.click(`.card-box:has-text("Name: ${data.name}") >> #details`);228 await page.waitForTimeout(interval);229 expect(await page.isVisible('text="Delete"')).to.be.true;230 expect(await page.isVisible('text="Edit"')).to.be.true;231 });232 it('Edit should populate form with correct data [ 5 Points ]', async () => {233 const data = mockData.catalog[0];234 const { get } = await handle(endpoints.delete(data._id));235 get(data);236 await page.click('text=Catalog');237 await page.waitForTimeout(interval);238 await page.waitForSelector('#catalogPage');239 await page.click(`.card-box:has-text("Name: ${data.name}") >> #details`);240 await page.waitForTimeout(interval);241 await page.click('text=Edit');242 await page.waitForTimeout(interval);243 await page.waitForSelector('form');244 const inputs = await page.$$eval('.container input, textarea', t => t.map(i => i.value));245 expect(inputs[0]).to.contains(data.name);246 expect(inputs[1]).to.contains(data.imgUrl);247 expect(inputs[2]).to.contains(data.price);248 expect(inputs[3]).to.contains(data.releaseDate);249 expect(inputs[4]).to.contains(data.artist);250 expect(inputs[5]).to.contains(data.genre);251 expect(inputs[6]).to.contains(data.description);252 });253 it('Edit does NOT work with empty fields [ 5 Points ]', async () => {254 const data = mockData.catalog[0];255 const { get, put } = await handle(endpoints.delete(data._id));256 get(data);257 const { isHandled } = put();258 await page.click('text=Catalog');259 await page.waitForTimeout(interval);260 await page.waitForSelector('#catalogPage');261 await page.click(`.card-box:has-text("Name: ${data.name}") >> #details`);262 await page.waitForTimeout(interval);263 await page.click('text=Edit');264 await page.waitForTimeout(interval);265 await page.waitForSelector('form');266 await page.fill('[name="name"]', '');267 await page.fill('[name="imgUrl"]', '');268 await page.fill('[name="price"]', '');269 await page.fill('[name="releaseDate"]', '');270 await page.fill('[name="artist"]', '');271 await page.fill('[name="genre"]', '');272 await page.fill('[name="description"]', '');273 await page.click('[type="submit"]');274 await page.waitForTimeout(interval);275 expect(isHandled()).to.be.false;276 });277 it('Edit makes correct API call for logged in user [ 5 Points ]', async () => {278 const data = mockData.catalog[0];279 const { get, put } = await handle(endpoints.delete(data._id));280 get(data);281 const { onRequest } = put();282 await page.click('text=Catalog');283 await page.waitForTimeout(interval);284 await page.waitForSelector('#catalogPage');285 await page.click(`.card-box:has-text("Name: ${data.name}") >> #details`);286 await page.waitForTimeout(interval);287 await page.click('text=Edit');288 await page.waitForTimeout(interval);289 await page.waitForSelector('form');290 await page.fill('[name="name"]', data.name + 'edit');291 await page.fill('[name="artist"]', data.artist + 'edit');292 await page.fill('[name="genre"]', data.genre + 'edit');293 const [request] = await Promise.all([294 onRequest(),295 page.click('[type="submit"]')296 ]);297 const postData = JSON.parse(request.postData());298 expect(postData.name).to.contains(data.name + 'edit');299 expect(postData.artist).to.contains(data.artist + 'edit');300 expect(postData.genre).to.contains(data.genre + 'edit');301 });302 it('Delete makes correct API call for logged in user [ 10 Points ]', async () => {303 const data = mockData.catalog[0];304 const { get, del } = await handle(endpoints.delete(data._id));305 get(data);306 const { onResponse, isHandled } = del();307 await page.click('text=Catalog');308 await page.waitForTimeout(interval);309 await page.waitForSelector('#catalogPage');310 await page.click(`.card-box:has-text("Name: ${data.name}") >> #details`);311 await page.waitForTimeout(interval);312 await page.click('text=Delete');313 page.on('dialog', dialog => dialog.accept());314 await Promise.all([315 onResponse(),316 page.click('text="Delete"')317 ]);318 expect(isHandled()).to.be.true;319 });320 });321 describe('Check Catalog Page with User [ 4 Points ]', async () => {322 // Login user323 beforeEach(async () => {324 const data = mockData.users[0];325 await page.goto(host);326 await page.waitForTimeout(interval);327 await page.click('text=Login');328 await page.waitForTimeout(interval);329 await page.waitForSelector('form');330 await page.fill('[name="email"]', data.email);331 await page.fill('[name="password"]', data.password);332 await page.click('[type="submit"]');333 await page.waitForTimeout(interval);334 });335 it('Check Catalog Page with 0 albums [ 2 Points ]', async () => {336 const { get } = await handle(endpoints.catalog);337 get([]);338 await page.click('text=Catalog');339 await page.waitForTimeout(interval);340 const visible = await page.isVisible('text=No Albums in Catalog!');341 expect(visible).to.be.true;342 });343 it('Check Catalog Page with 2 albums [ 2 Points ]', async () => {344 const { get } = await handle(endpoints.catalog);345 get(mockData.catalog.slice(0, 2));346 await page.click('text=Catalog');347 await page.waitForTimeout(interval);348 await page.waitForSelector('#catalogPage');349 const titles = await page.$$eval('.text-center >> .name', t => t.map(s => s.textContent));350 expect(titles.length).to.equal(2);351 expect(titles[0]).to.contains(`Name: ${mockData.catalog[0].name}`);352 expect(titles[1]).to.contains(`Name: ${mockData.catalog[1].name}`);353 });354 });355 describe('Check Catalog Page with Guest [ 6 Points ]', async () => {356 it('Check Catalog Page with 0 albums [ 2 Points ]', async () => {357 const { get } = await handle(endpoints.catalog);358 get([]);359 await page.goto(host);360 await page.waitForTimeout(interval);361 await page.click('text=Catalog');362 await page.waitForTimeout(interval);363 const visible = await page.isVisible('text=No Albums in Catalog!');364 expect(visible).to.be.true;365 });366 it('Check Catalog Page with 2 albums [ 2 Points ]', async () => {367 const { get } = await handle(endpoints.catalog);368 get(mockData.catalog.slice(0, 2));369 await page.goto(host);370 await page.waitForTimeout(interval);371 await page.click('text=Catalog');372 await page.waitForTimeout(interval);373 await page.waitForSelector('#catalogPage');374 const titles = await page.$$eval('.text-center >> .name', t => t.map(s => s.textContent));375 expect(titles.length).to.equal(2);376 expect(titles[0]).to.contains(`${mockData.catalog[0].name}`);377 expect(titles[1]).to.contains(`${mockData.catalog[1].name}`);378 });379 it('Guest does NOT see details buttons [ 2 Points ]', async () => {380 await page.goto(host);381 await page.waitForTimeout(interval);382 await page.click('text=Catalog');383 await page.waitForTimeout(interval);384 expect(await page.isVisible('text="Details"')).to.be.false;385 });386 });387 describe('Search Page [ 10 Points ]', async () => {388 it('Show no matches for Guest [ 1 Points ]', async () => {389 const { get } = await handle(endpoints.search('Queen'));390 get([]);391 await page.goto(host);392 await page.waitForTimeout(interval);393 await page.click('nav >> text=Search');394 await page.waitForTimeout(interval);395 await page.fill('[name="search"]', 'Queen');396 await page.click('button >> text="Search"');397 await page.waitForTimeout(interval);398 expect(await page.isVisible('text=No result.')).to.be.true;399 });400 it('Show results with 2 albums for Guest [ 2 Points ]', async () => {401 const { get } = await handle(endpoints.search('Name'));402 get(mockData.catalog.slice(0, 2));403 404 await page.goto(host);405 await page.waitForTimeout(interval);406 await page.click('nav >> text=Search');407 await page.waitForTimeout(interval);408 await page.fill('[name="search"]', 'Name');409 await page.click('button >> text="Search"');410 await page.waitForTimeout(interval);411 const matches = await page.$$eval('.text-center >> .name', t => t.map(s => s.textContent));412 expect(matches.length).to.equal(2);413 expect(matches[0]).to.contains(`Name: ${mockData.catalog[0].name}`);414 expect(matches[1]).to.contains(`Name: ${mockData.catalog[1].name}`);415 });416 it('No Details button for Guest [ 2 Points ]', async () => {417 const { get } = await handle(endpoints.search('Name'));418 get(mockData.catalog.slice(0, 1));419 420 await page.goto(host);421 await page.waitForTimeout(interval);422 await page.click('nav >> text=Search');423 await page.waitForTimeout(interval);424 await page.fill('[name="search"]', 'Name');425 await page.click('button >> text="Search"');426 await page.waitForTimeout(interval);427 const matches = await page.$$eval('.text-center >> .name', t => t.map(s => s.textContent));428 expect(matches.length).to.equal(1);429 expect(matches[0]).to.contains(`Name: ${mockData.catalog[0].name}`);430 expect(await page.isVisible('text="Details"')).to.be.false;431 });432 433 it('Show no matches for Users [ 1 Points ]', async () => {434 // Login user435 const data = mockData.users[0];436 await page.goto(host);437 await page.waitForTimeout(interval);438 await page.click('text=Login');439 await page.waitForTimeout(interval);440 await page.waitForSelector('form');441 await page.fill('[name="email"]', data.email);442 await page.fill('[name="password"]', data.password);443 await page.click('[type="submit"]');444 const { get } = await handle(endpoints.search('Queen'));445 get([]);446 await page.goto(host);447 await page.waitForTimeout(interval);448 await page.click('nav >> text=Search');449 await page.waitForTimeout(interval);450 await page.fill('[name="search"]', 'Queen');451 await page.click('button >> text="Search"');452 await page.waitForTimeout(interval);453 expect(await page.isVisible('text=No result.')).to.be.true;454 });455 it('Show results with 2 albums for Users [ 2 Points ]', async () => {456 // Login user457 const data = mockData.users[0];458 await page.goto(host);459 await page.waitForTimeout(interval);460 await page.click('text=Login');461 await page.waitForTimeout(interval);462 await page.waitForSelector('form');463 await page.fill('[name="email"]', data.email);464 await page.fill('[name="password"]', data.password);465 await page.click('[type="submit"]');466 const { get } = await handle(endpoints.search('Name'));467 get(mockData.catalog.slice(0, 2));468 await page.goto(host);469 await page.waitForTimeout(interval);470 await page.click('nav >> text=Search');471 await page.waitForTimeout(interval);472 await page.fill('[name="search"]', 'Name');473 await page.click('button >> text="Search"');474 await page.waitForTimeout(interval);475 const matches = await page.$$eval('.text-center >> .name', t => t.map(s => s.textContent));476 expect(matches.length).to.equal(2);477 expect(matches[0]).to.contains(`Name: ${mockData.catalog[0].name}`);478 expect(matches[1]).to.contains(`Name: ${mockData.catalog[1].name}`);479 });480 it('Show Details button for User [ 2 Points ]', async () => {481 // Login user482 const data = mockData.users[0];483 await page.goto(host);484 await page.waitForTimeout(interval);485 await page.click('text=Login');486 await page.waitForTimeout(interval);487 await page.waitForSelector('form');488 await page.fill('[name="email"]', data.email);489 await page.fill('[name="password"]', data.password);490 await page.click('[type="submit"]');491 const { get } = await handle(endpoints.search('Name'));492 get(mockData.catalog.slice(0, 1));493 await page.goto(host);494 await page.waitForTimeout(interval);495 await page.click('nav >> text=Search');496 await page.waitForTimeout(interval);497 await page.fill('[name="search"]', 'Name');498 await page.click('button >> text="Search"');499 await page.waitForTimeout(interval);500 const matches = await page.$$eval('.text-center >> .name', t => t.map(s => s.textContent));501 expect(matches.length).to.equal(1);502 expect(matches[0]).to.contains(`Name: ${mockData.catalog[0].name}`);503 expect(await page.isVisible('text="Details"')).to.be.true;504 });505 });506});507async function setupContext(context) {508 // Authentication509 await handleContext(context, endpoints.login, { post: mockData.users[0] });510 await handleContext(context, endpoints.register, { post: mockData.users[0] });511 await handleContext(context, endpoints.logout, { get: h => h('', { json: false, status: 204 }) });...
single-message.spec.js
Source:single-message.spec.js
...22 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })23 // navigate to page single message24 await page.click('a[href="#send"]');25 // await page.screenshot({ path: `screenshots/single-message/send_2.png` })26 await page.fill('#fiscal_code', ''); 27 await page.fill('#subject', 'AAAAA');28 await page.fill('#markdown', 'AAAAA');29 await page.fill('#amount', '123');30 await page.fill('#notice_number', '123');31 // // await page.screenshot({ path: `screenshots/single-message/send_3.png` })32 const inputSUTClass = await page.getAttribute('#fiscal_code', 'class');33 expect(inputSUTClass).toMatch(/is-invalid/);34 const buttonDisabled = await page.getAttribute('button', 'disabled');35 expect(buttonDisabled).toBe("");36 })37 it("I enter wrong fiscal code format, other field ok, and should set it as invalid and button is disabled", async()=> { 38 // open the io-sdk admin39 await page.goto('http://localhost:3280/app/index.html');40 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })41 // navigate to page single message42 await page.click('a[href="#send"]');43 // await page.screenshot({ path: `screenshots/single-message/send_2.png` })44 await page.fill('#fiscal_code', 'AAAA'); 45 await page.fill('#subject', 'AAAAA');46 await page.fill('#markdown', 'AAAAA');47 await page.fill('#amount', '123');48 await page.fill('#notice_number', '123');49 // // await page.screenshot({ path: `screenshots/single-message/send_3.png` })50 const inputSUTClass = await page.getAttribute('#fiscal_code', 'class');51 expect(inputSUTClass).toMatch(/is-invalid/);52 const buttonDisabled = await page.getAttribute('button', 'disabled');53 expect(buttonDisabled).toBe("");54 })55 it("I enter right fiscal code, other field ok, and should set it as valid and button is enabled", async()=> { 56 // open the io-sdk admin57 await page.goto('http://localhost:3280/app/index.html');58 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })59 // navigate to page single message60 await page.click('a[href="#send"]');61 // // await page.screenshot({ path: `screenshots/single-message/send_2.png` })62 await page.fill('#fiscal_code', 'ABCDEF12G34J456T');63 await page.fill('#subject', 'AAAAA');64 await page.fill('#markdown', 'AAAAA');65 await page.fill('#amount', '123');66 await page.fill('#notice_number', '123');67 // await page.screenshot({ path: `screenshots/single-message/send_3.png` })68 const inputSUTClass = await page.getAttribute('#fiscal_code', 'class');69 expect(inputSUTClass).not.toMatch(/is-invalid/);70 const buttonDisabled = await page.getAttribute('button', 'disabled');71 expect(buttonDisabled).toBe(null);72 })73 })74 describe("test SUBJECT field", () => {75 it("I enter empty in subject, other field ok, and should set it as invalid and button is disabled", async()=> { 76 // open the io-sdk admin77 await page.goto('http://localhost:3280/app/index.html');78 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })79 // navigate to page single message80 await page.click('a[href="#send"]');81 // // await page.screenshot({ path: `screenshots/single-message/send_2.png` })82 await page.fill('#fiscal_code', 'ABCDEF12G34J456T');83 await page.fill('#subject', '');84 await page.fill('#markdown', 'AAAAA');85 await page.fill('#amount', '123');86 await page.fill('#notice_number', '123');87 // await page.screenshot({ path: `screenshots/single-message/send_3.png` })88 const inputSUTClass = await page.getAttribute('#subject', 'class');89 expect(inputSUTClass).toMatch(/is-invalid/);90 const buttonDisabled = await page.getAttribute('button', 'disabled');91 expect(buttonDisabled).toBe("");92 })93 it("I enter more than 255 chars in subject, other field ok, and should set it as invalid and button is disabled", async()=> { 94 // open the io-sdk admin95 await page.goto('http://localhost:3280/app/index.html');96 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })97 // navigate to page single message98 await page.click('a[href="#send"]');99 // // await page.screenshot({ path: `screenshots/single-message/send_2.png` })100 await page.fill('#fiscal_code', 'ABCDEF12G34J456T');101 await page.fill('#subject', 'A'.repeat(256));102 await page.fill('#markdown', 'AAAAA');103 await page.fill('#amount', '123');104 await page.fill('#notice_number', '123');105 // await page.screenshot({ path: `screenshots/single-message/send_3.png` })106 const inputSUTClass = await page.getAttribute('#subject', 'class');107 expect(inputSUTClass).toMatch(/is-invalid/);108 const buttonDisabled = await page.getAttribute('button', 'disabled');109 expect(buttonDisabled).toBe("");110 })111 it("I enter less than 5 chars in subject, other field ok, and should set it as invalid and button is disabled", async()=> { 112 // open the io-sdk admin113 await page.goto('http://localhost:3280/app/index.html');114 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })115 // navigate to page single message116 await page.click('a[href="#send"]');117 // // await page.screenshot({ path: `screenshots/single-message/send_2.png` })118 await page.fill('#fiscal_code', 'ABCDEF12G34J456T');119 await page.fill('#subject', 'AAA');120 await page.fill('#markdown', 'AAAAA');121 await page.fill('#amount', '123');122 await page.fill('#notice_number', '123');123 // await page.screenshot({ path: `screenshots/single-message/send_3.png` })124 const inputSUTClass = await page.getAttribute('#subject', 'class');125 expect(inputSUTClass).toMatch(/is-invalid/);126 const buttonDisabled = await page.getAttribute('button', 'disabled');127 expect(buttonDisabled).toBe("");128 })129 it("I enter right subject, other field ok, and should set it as valid and button is enabled", async()=> { 130 // open the io-sdk admin131 await page.goto('http://localhost:3280/app/index.html');132 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })133 // navigate to page single message134 await page.click('a[href="#send"]');135 // // await page.screenshot({ path: `screenshots/single-message/send_2.png` })136 await page.fill('#fiscal_code', 'ABCDEF12G34J456T');137 await page.fill('#subject', 'AAAAA');138 await page.fill('#markdown', 'AAAAA');139 await page.fill('#amount', '123');140 await page.fill('#notice_number', '123');141 // await page.screenshot({ path: `screenshots/single-message/send_3.png` })142 const inputSUTClass = await page.getAttribute('#subject', 'class');143 expect(inputSUTClass).not.toMatch(/is-invalid/);144 const buttonDisabled = await page.getAttribute('button', 'disabled');145 expect(buttonDisabled).toBe(null);146 })147 })148 describe("test MARKDOWN field", () => {149 it("I enter empty markdown, other field ok, and should set it as invalid and button is disabled", async()=> { 150 // open the io-sdk admin151 await page.goto('http://localhost:3280/app/index.html');152 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })153 // navigate to page single message154 await page.click('a[href="#send"]');155 // await page.screenshot({ path: `screenshots/single-message/send_2.png` })156 await page.fill('#fiscal_code', 'ABCDEF12G34J456T'); 157 await page.fill('#subject', 'AAAAA');158 await page.fill('#markdown', '');159 await page.fill('#amount', '123');160 await page.fill('#notice_number', '123');161 // // await page.screenshot({ path: `screenshots/single-message/send_3.png` })162 const inputSUTClass = await page.getAttribute('#markdown', 'class');163 expect(inputSUTClass).toMatch(/is-invalid/);164 const buttonDisabled = await page.getAttribute('button', 'disabled');165 expect(buttonDisabled).toBe("");166 })167 it("I enter right markdown, other field ok, and should set it as valid and button is enabled", async()=> { 168 // open the io-sdk admin169 await page.goto('http://localhost:3280/app/index.html');170 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })171 // navigate to page single message172 await page.click('a[href="#send"]');173 // // await page.screenshot({ path: `screenshots/single-message/send_2.png` })174 await page.fill('#fiscal_code', 'ABCDEF12G34J456T');175 await page.fill('#subject', 'AAAAA');176 await page.fill('#markdown', 'AAAAA');177 await page.fill('#amount', '123');178 await page.fill('#notice_number', '123');179 // await page.screenshot({ path: `screenshots/single-message/send_3.png` })180 const inputSUTClass = await page.getAttribute('#markdown', 'class');181 expect(inputSUTClass).not.toMatch(/is-invalid/);182 const buttonDisabled = await page.getAttribute('button', 'disabled');183 expect(buttonDisabled).toBe(null);184 })185 })186 describe("test AMOUNT field", () => {187 it("I enter empty amount, other field ok, and should set it as invalid and button is disabled", async()=> { 188 // open the io-sdk admin189 await page.goto('http://localhost:3280/app/index.html');190 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })191 // navigate to page single message192 await page.click('a[href="#send"]');193 // await page.screenshot({ path: `screenshots/single-message/send_2.png` })194 await page.fill('#fiscal_code', 'ABCDEF12G34J456T'); 195 await page.fill('#subject', 'AAAAA');196 await page.fill('#markdown', 'AAAAA');197 await page.fill('#amount', '');198 await page.fill('#notice_number', '123');199 // // await page.screenshot({ path: `screenshots/single-message/send_3.png` })200 const inputSUTClass = await page.getAttribute('#amount', 'class');201 expect(inputSUTClass).toMatch(/is-invalid/);202 const buttonDisabled = await page.getAttribute('button', 'disabled');203 expect(buttonDisabled).toBe("");204 })205 it("I enter not numeric amount, other field ok, and should set it as invalid and button is disabled", async()=> { 206 // open the io-sdk admin207 await page.goto('http://localhost:3280/app/index.html');208 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })209 // navigate to page single message210 await page.click('a[href="#send"]');211 // await page.screenshot({ path: `screenshots/single-message/send_2.png` })212 await page.fill('#fiscal_code', 'ABCDEF12G34J456T'); 213 await page.fill('#subject', 'AAAAA');214 await page.fill('#markdown', 'AAAAA');215 await page.fill('#amount', 'AAA');216 await page.fill('#notice_number', '123');217 // // await page.screenshot({ path: `screenshots/single-message/send_3.png` })218 const inputSUTClass = await page.getAttribute('#amount', 'class');219 expect(inputSUTClass).toMatch(/is-invalid/);220 const buttonDisabled = await page.getAttribute('button', 'disabled');221 expect(buttonDisabled).toBe("");222 })223 it("I enter right amount, other field ok, and should set it as valid and button is enabled", async()=> { 224 // open the io-sdk admin225 await page.goto('http://localhost:3280/app/index.html');226 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })227 // navigate to page single message228 await page.click('a[href="#send"]');229 // // await page.screenshot({ path: `screenshots/single-message/send_2.png` })230 await page.fill('#fiscal_code', 'ABCDEF12G34J456T');231 await page.fill('#subject', 'AAAAA');232 await page.fill('#markdown', 'AAAAA');233 await page.fill('#amount', '123');234 await page.fill('#notice_number', '123');235 // await page.screenshot({ path: `screenshots/single-message/send_3.png` })236 const inputSUTClass = await page.getAttribute('#amount', 'class');237 expect(inputSUTClass).not.toMatch(/is-invalid/);238 const buttonDisabled = await page.getAttribute('button', 'disabled');239 expect(buttonDisabled).toBe(null);240 })241 })242 describe("test NOTICE NUMBER field", () => {243 it("I enter empty notice_number, other field ok, and should set it as invalid and button is disabled", async()=> { 244 // open the io-sdk admin245 await page.goto('http://localhost:3280/app/index.html');246 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })247 // navigate to page single message248 await page.click('a[href="#send"]');249 // await page.screenshot({ path: `screenshots/single-message/send_2.png` })250 await page.fill('#fiscal_code', 'ABCDEF12G34J456T'); 251 await page.fill('#subject', 'AAAAA');252 await page.fill('#markdown', 'AAAAA');253 await page.fill('#amount', '123');254 await page.fill('#notice_number', '');255 // // await page.screenshot({ path: `screenshots/single-message/send_3.png` })256 const inputSUTClass = await page.getAttribute('#notice_number', 'class');257 expect(inputSUTClass).toMatch(/is-invalid/);258 const buttonDisabled = await page.getAttribute('button', 'disabled');259 expect(buttonDisabled).toBe("");260 })261 it("I enter right notice number, other field ok, and should set it as valid and button is enabled", async()=> { 262 // open the io-sdk admin263 await page.goto('http://localhost:3280/app/index.html');264 // await page.screenshot({ path: `screenshots/single-message/send_1.png` })265 // navigate to page single message266 await page.click('a[href="#send"]');267 // // await page.screenshot({ path: `screenshots/single-message/send_2.png` })268 await page.fill('#fiscal_code', 'ABCDEF12G34J456T');269 await page.fill('#subject', 'AAAAA');270 await page.fill('#markdown', 'AAAAA');271 await page.fill('#amount', '123');272 await page.fill('#notice_number', '123');273 // await page.screenshot({ path: `screenshots/single-message/send_3.png` })274 const inputSUTClass = await page.getAttribute('#notice_number', 'class');275 expect(inputSUTClass).not.toMatch(/is-invalid/);276 const buttonDisabled = await page.getAttribute('button', 'disabled');277 expect(buttonDisabled).toBe(null);278 })279 })...
register.spec.js
Source:register.spec.js
1"use strict";2var pageUrlBase = "../";3// Node.js 'requires', which load Page Object modules for use in tests.4var LoginPage = require("../login/login.page.js");5var RegisterPage = require(pageUrlBase + "register/register.page.js");6var RegisterTermsAndConditionsPage = require(pageUrlBase + "register/register-terms-and-conditions.page.js");7var TestDataLoader = require("../load-test-data.js");8// End-to-end test specifications written in Jasmine syntax.9describe("At login", function () {10 //Reset the test database11 var testDataLoader = new TestDataLoader();12 beforeAll(function () {13 testDataLoader.loadTestData();14 })15 // Create a new instance of the "Login" Page Object16 var page = new LoginPage();17 it("should go to the Register page if the Register button is clicked", function () {18 // Start from the Login page19 page.goToPage();20 page.register();21 browser.waitForAngular();22 expect(browser.getCurrentUrl()).toMatch("/register");23 });24});25describe("At register", function () {26 // Create a new instance of the "Register" Page Object27 var page = new RegisterPage();28 // Setup test fixture (analogous to a JUnit '@Before' annotated method)29 beforeEach(function () {30 // Start from the Register page31 page.goToPage();32 });33 it("should go successfully register if the form has no validation errors", function () {34 // No need to select a Title because it defaults to "Mr"35 page.fillFirstName("New");36 page.fillLastName("User");37 page.fillTelephone("01234567890");38 page.fillEmail("newuser@atos.net");39 page.fillConfirmEmail("newuser@atos.net");40 page.fillPassword("password1");41 page.fillConfirmPassword("password1");42 page.clickTermsAndConditionsCheckBox();43 page.register();44 expect(page.isModalDialogDisplayed()).toBe(true);45 expect(page.getModalDialogMessageText()).toEqual("Registration is successful. A validation link has been sent to your email");46 page.modalDialogOkButtonClick();47 expect(browser.getCurrentUrl()).toMatch("/login");48 });49 it("should output an already exists error dialog box if the email already exists", function () {50 // No need to select a Title because it defaults to "Mr"51 page.fillFirstName("Fake");52 page.fillLastName("User");53 page.fillTelephone("01234567890");54 page.fillEmail("fakeuser@atos.net");55 page.fillConfirmEmail("fakeuser@atos.net");56 page.fillPassword("password1");57 page.fillConfirmPassword("password1");58 page.clickTermsAndConditionsCheckBox();59 page.register();60 // Check that an "Error" dialog is displayed61 expect(page.isModalDialogDisplayed()).toBe(true);62 expect(page.getModalDialogMessageText()).toMatch(/User already exists/);63 // Page should go to login page64 page.modalDialogGoToLoginButtonClick();65 browser.waitForAngular();66 expect(browser.getCurrentUrl()).toMatch("/login");67 });68 it("should output an error dialog box if the email domain is not part of the whitelist", function () {69 // No need to select a Title because it defaults to "Mr"70 page.fillFirstName("Origin");71 page.fillLastName("Ator");72 page.fillTelephone("01234567890");73 page.fillEmail("originator@whitelistexample.com");74 page.fillConfirmEmail("originator@whitelistexample.com");75 page.fillPassword("password1");76 page.fillConfirmPassword("password1");77 page.clickTermsAndConditionsCheckBox();78 page.register();79 // Check that an "Error" dialog is displayed80 expect(page.isModalDialogDisplayed()).toBe(true);81 expect(page.getModalDialogMessageText()).toMatch('Your email domain is not allowed at this moment in time. Please check back later');82 // Page should not change83 page.modalDialogOkButtonClick();84 expect(browser.getCurrentUrl()).toMatch("/register");85 });86 it("should show a 'required' error message for every required text field", function () {87 page.register();88 // All "required" text field error messages should be shown89 expect(page.firstNameRequiredError.isDisplayed()).toBe(true);90 expect(page.lastNameRequiredError.isDisplayed()).toBe(true);91 expect(page.telephoneRequiredError.isDisplayed()).toBe(true);92 expect(page.emailRequiredError.isDisplayed()).toBe(true);93 expect(page.confirmEmailRequiredError.isDisplayed()).toBe(true);94 expect(page.passwordRequiredError.isDisplayed()).toBe(true);95 expect(page.confirmPasswordRequiredError.isDisplayed()).toBe(true);96 expect(page.termsAndConditionsUncheckedError.isDisplayed()).toBe(true);97 // Other validation error messages should not be shown98 expect(page.telephonePatternError.isDisplayed()).toBe(false);99 expect(page.emailPatternError.isDisplayed()).toBe(false);100 expect(page.confirmEmailMatchError.isDisplayed()).toBe(false);101 expect(page.passwordPatternError.isDisplayed()).toBe(false);102 expect(page.confirmPasswordMatchError.isDisplayed()).toBe(false);103 });104 it("should show a validation error message for every field requiring a particular pattern", function () {105 page.fillFirstName("Origi");106 page.fillLastName("Nator");107 page.fillTelephone("abcdefghijk");108 page.fillEmail("originator");109 page.fillConfirmEmail("originator");110 page.fillPassword("password");111 page.fillConfirmPassword("password");112 page.clickTermsAndConditionsCheckBox();113 page.register();114 // All "required" text field error messages should not be shown115 expect(page.firstNameRequiredError.isDisplayed()).toBe(false);116 expect(page.lastNameRequiredError.isDisplayed()).toBe(false);117 expect(page.telephoneRequiredError.isDisplayed()).toBe(false);118 expect(page.emailRequiredError.isDisplayed()).toBe(false);119 expect(page.confirmEmailRequiredError.isDisplayed()).toBe(false);120 expect(page.passwordRequiredError.isDisplayed()).toBe(false);121 expect(page.confirmPasswordRequiredError.isDisplayed()).toBe(false);122 expect(page.termsAndConditionsUncheckedError.isDisplayed()).toBe(false);123 // Only pattern validation error messages should be shown124 expect(page.telephonePatternError.isDisplayed()).toBe(true);125 expect(page.emailPatternError.isDisplayed()).toBe(true);126 expect(page.confirmEmailMatchError.isDisplayed()).toBe(false);127 expect(page.passwordPatternError.isDisplayed()).toBe(true);128 expect(page.confirmPasswordMatchError.isDisplayed()).toBe(false);129 });130 it("should show a match error if Email and Confirm Email fields do not match", function () {131 page.fillFirstName("Origi");132 page.fillLastName("Nator");133 page.fillTelephone("01234567890");134 page.fillEmail("originator@example.com");135 page.fillConfirmEmail("approver@example.com");136 page.fillPassword("password1");137 page.fillConfirmPassword("password1");138 page.clickTermsAndConditionsCheckBox();139 page.register();140 // Only the email matching error message should be shown141 expect(page.confirmEmailMatchError.isDisplayed()).toBe(true);142 expect(page.confirmPasswordMatchError.isDisplayed()).toBe(false);143 });144 it("should show a match error if Password and Confirm Password fields do not match", function () {145 page.fillFirstName("Origi");146 page.fillLastName("Nator");147 page.fillTelephone("01234567890");148 page.fillEmail("originator@example.com");149 page.fillConfirmEmail("originator@example.com");150 page.fillPassword("password1");151 page.fillConfirmPassword("password2");152 page.clickTermsAndConditionsCheckBox();153 page.register();154 // Only the password matching error message should be shown155 expect(page.confirmEmailMatchError.isDisplayed()).toBe(false);156 expect(page.confirmPasswordMatchError.isDisplayed()).toBe(true);157 });158});159describe("At terms and conditions", function () {160 // Create a new instance of the "Register" Page Object161 var registerPage = new RegisterPage();162 // Create a new instance of the "Register Terms and Conditions" Page Object163 var registerTermsAndConditionsPage = new RegisterTermsAndConditionsPage();164 // Create a new instance of the test data loader165 var testDataLoader = new TestDataLoader();166 // Call REST service to initialize database with test data167 testDataLoader.loadTestData();168 // Setup test fixture (analogous to a JUnit '@Before' annotated method)169 beforeEach(function () {170 // Populate the registration form (it must be submitted successfully to reach the Terms and Conditions page)171 registerPage.goToPage();172 });173 it("should go to the terms and conditions page", function () {174 registerPage.clickTermsAndConditionsLink();175 expect(browser.getCurrentUrl()).toMatch("/register/terms-and-conditions");176 });177 it("should go to the terms and conditions page and then return", function () {178 registerPage.clickTermsAndConditionsLink();179 browser.waitForAngular();180 // Go back to the registration page181 registerTermsAndConditionsPage.back();182 expect(browser.getCurrentUrl()).toMatch("/register");183 });184 it("should enter user details and save them when the user goes into terms and conditions then back", function () {185 registerPage.fillFirstName("New");186 registerPage.fillLastName("User");187 registerPage.fillTelephone("01234567890");188 registerPage.fillEmail("newfakeuser@atos.net");189 registerPage.fillConfirmEmail("newfakeuser@atos.net");190 registerPage.fillPassword("password1");191 registerPage.fillConfirmPassword("password1");192 registerPage.clickTermsAndConditionsLink();193 browser.waitForAngular();194 registerTermsAndConditionsPage.back();195 expect(registerPage.firstNameField.getAttribute("value")).toEqual("New");196 expect(registerPage.lastNameField.getAttribute("value")).toEqual("User");197 expect(registerPage.telephoneField.getAttribute("value")).toEqual("01234567890");198 expect(registerPage.emailField.getAttribute("value")).toEqual("newfakeuser@atos.net");199 expect(registerPage.confirmEmailField.getAttribute("value")).toEqual("newfakeuser@atos.net");200 expect(registerPage.passwordField.getAttribute("value")).toEqual("password1");201 expect(registerPage.confirmPasswordField.getAttribute("value")).toEqual("password1");202 });...
musician-crud.spec.js
Source:musician-crud.spec.js
1import faker from "faker";2import {3 musicianFormPage,4 musicianIndexPage,5 musicianShowPage,6 signInPage7} from "../support/pages";89describe("Musician CRUD", () => {10 describe("When unauthenticated", () => {11 it("the page should not be accessible.", () => {12 musicianIndexPage.visit();13 14 signInPage.assert();15 signInPage.assertAuthAlert();16 });17 });18 19 describe("When authenticated", () => {20 beforeEach(() => cy.login());2122 const data = Object.freeze({23 name: faker.name.findName(),24 bio: faker.lorem.paragraph(),25 urlPathName: faker.name.firstName(),26 sessionTitle: faker.name.title(),27 sessionDescription: faker.lorem.paragraph(),28 facebookUrl: faker.internet.url(),29 twitterUrl: faker.internet.url(),30 instagramUrl: faker.internet.url(),31 youtubeUrl: faker.internet.url(),32 websiteUrl: faker.internet.url(),33 cashAppUrl: faker.internet.url(),34 venmoUrl: faker.internet.url(),35 paypalUrl: faker.internet.url(),36 })3738 it("should be able to create a new musician", () => {39 musicianIndexPage.visit();40 musicianIndexPage.clickNewMusicianLink();4142 musicianFormPage.assertNew();43 musicianFormPage.fillInNameField(data.name);44 musicianFormPage.fillInBioField(data.bio);45 musicianFormPage.fillInUrlPathNameField(data.urlPathName);46 musicianFormPage.fillInSessionTitleField(data.sessionTitle);47 musicianFormPage.fillInSessionDescriptionField(data.sessionDescription);48 musicianFormPage.fillInFaceBookUrlField(data.facebookUrl);49 musicianFormPage.fillInTwitterUrlField(data.twitterUrl);50 musicianFormPage.fillInInstagramUrlField(data.instagramUrl);51 musicianFormPage.fillInYoutubeUrlField(data.youtubeUrl);52 musicianFormPage.fillInWebsiteUrlField(data.websiteUrl);53 musicianFormPage.fillInCashAppUrlField(data.cashAppUrl);54 musicianFormPage.fillInVenmoUrlField(data.venmoUrl);55 musicianFormPage.fillInPaypalUrlField(data.paypalUrl);5657 musicianFormPage.clickSubmit();5859 musicianIndexPage.assert();60 musicianIndexPage.assertMusician(data.name);61 });6263 it("should be able to update a new musician", () => {64 musicianIndexPage.visit();65 musicianIndexPage.clickEditMusicianLink(data.name);6667 const newName = faker.name.findName();68 musicianFormPage.assertEdit();69 musicianFormPage.fillInNameField(newName);70 musicianFormPage.fillInBioField(data.bio);71 musicianFormPage.fillInUrlPathNameField(data.urlPathName);72 musicianFormPage.fillInSessionTitleField(data.sessionTitle);73 musicianFormPage.fillInSessionDescriptionField(data.sessionDescription);74 musicianFormPage.fillInFaceBookUrlField(data.facebookUrl);75 musicianFormPage.fillInTwitterUrlField(data.twitterUrl);76 musicianFormPage.fillInInstagramUrlField(data.instagramUrl);77 musicianFormPage.fillInYoutubeUrlField(data.youtubeUrl);78 musicianFormPage.fillInWebsiteUrlField(data.websiteUrl);79 musicianFormPage.fillInCashAppUrlField(data.cashAppUrl);80 musicianFormPage.fillInVenmoUrlField(data.venmoUrl);81 musicianFormPage.fillInPaypalUrlField(data.paypalUrl);8283 musicianFormPage.clickSubmit();8485 musicianShowPage.assert(newName);86 musicianShowPage.assertUpdateSuccessAlert();87 });88 });
...
Using AI Code Generation
1const { launch } = require("qawolf");2const selectors = require("../selectors/test");3describe("test", () => {4 let browser;5 let page;6 beforeAll(async () => {7 browser = await launch();8 page = await browser.newPage();9 });10 afterAll(() => browser.close());11 it("test", async () => {12 await page.click(selectors["Search Google or type a URL"]);13 await page.fill(selectors["Search Google or type a URL"], "Hello");14 await page.press(selectors["Search Google or type a URL"], "Enter");15 await page.click(selectors["Hello"]);16 await page.click(selectors["Hello"]);17 });18});19module.exports = {20 "Search Google or type a URL": "#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input",21 "Hello": "#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3",22 "Hello": "#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3",23};
Using AI Code Generation
1const qawolf = require("qawolf");2describe("test", () => {3 let browser;4 let page;5 beforeAll(async () => {6 browser = await qawolf.launch();7 });8 afterAll(async () => {9 await browser.close();10 });11 beforeEach(async () => {12 page = await qawolf.createPage(browser);13 });14 afterEach(async () => {15 await qawolf.stopVideos();16 await page.close();17 });18 it("test", async () => {19 await page.fill("input[name=q]", "Hello World");20 await page.press("input[name=q]", "Enter");21 });22});23Error: Protocol error (Runtime.callFunctionOn): Cannot find context with specified id
Using AI Code Generation
1const { launch } = require("qawolf");2const selectors = require("../selectors/test.json");3describe("test", () => {4 let browser;5 let page;6 beforeAll(async () => {7 browser = await launch();8 page = await browser.newPage();9 });10 afterAll(async () => {11 await browser.close();12 });13 it("test", async () => {14 await page.fill(selectors["search"], "test");15 });16});17{18 "search": "#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input"19}
Using AI Code Generation
1const { launch } = require('qawolf')2const selectors = require('./selectors/test')3describe('test', () => {4 beforeAll(async () => {5 browser = await launch()6 page = await browser.newPage()7 })8 afterAll(async () => {9 await browser.close()10 })11 it('test', async () => {12 await page.fill(selectors[0], 'hello')13 await page.click(selectors[1])14 })15})
Using AI Code Generation
1const { launch } = require('qawolf');2const selectors = require('../selectors/test');3describe('test', () => {4 let browser;5 let page;6 beforeAll(async () => {7 browser = await launch();8 page = await browser.newPage();9 await page.setViewport({ width: 1280, height: 800 });10 });11 afterAll(() => browser.close());12 it('test', async () => {13 await page.fill(selectors[0], 'John');14 await page.fill(selectors[1], '
Using AI Code Generation
1const { launch } = require("qawolf");2const selectors = require("./selectors/test.json");3const assert = require("assert");4describe("test", () => {5 let browser;6 let page;7 before(async () => {8 page = await browser.newPage();9 });10 after(async () => {11 await browser.close();12 });13 it("test", async () => {14 await page.fill(selectors[0], "test");15 await page.click(selectors[1]);16 await page.click(selectors[2]);17 await page.click(selectors[3]);18 await page.click(selectors[4]);19 await page.click(selectors[5]);20 await page.click(selectors[6]);21 await page.click(selectors[7]);22 await page.click(selectors[8]);23 await page.click(selectors[9]);24 await page.click(selectors[10]);25 await page.click(selectors[11]);26 await page.click(selectors[12]);27 await page.click(selectors[13]);28 await page.click(selectors[14]);29 await page.click(selectors[15]);30 await page.click(selectors[16]);31 await page.click(selectors[17]);32 await page.click(selectors[18]);33 await page.click(selectors[19]);34 await page.click(selectors[20]);35 await page.click(selectors[21]);36 await page.click(selectors[22]);37 await page.click(selectors[23]);38 await page.click(selectors[24]);39 await page.click(selectors[25]);40 await page.click(selectors[26]);41 await page.click(selectors[27]);42 await page.click(selectors[28]);43 await page.click(selectors[29]);44 await page.click(selectors[30]);45 await page.click(selectors[31]);46 await page.click(selectors[32]);47 await page.click(selectors[33]);48 await page.click(selectors[34]);49 await page.click(selectors[35]);50 await page.click(selectors[36]);51 await page.click(selectors[37]);52 await page.click(selectors[38]);53 await page.click(selectors[39]);54 await page.click(selectors[40]);55 await page.click(selectors[41]);56 await page.click(selectors[42]);57 await page.click(selectors[43]);
Using AI Code Generation
1const qawolf = require("qawolf");2qawolf.create();3const browser = await qawolf.launch();4const context = await browser.newContext();5const page = await context.newPage();6await page.fill("input[name='q']", "Hello World");7await qawolf.stopVideos();8await browser.close();9await qawolf.teardown();10{11 "scripts": {12 },13 "dependencies": {14 }15}
Using AI Code Generation
1const { launch, page } = require('qawolf');2const selectors = require('./selectors/test');3describe('test', () => {4 let browser;5 let context;6 beforeAll(async () => {7 browser = await launch();8 context = await browser.newContext();9 });10 afterAll(async () => {11 await browser.close();12 });13 it('test', async () => {14 const page = await context.newPage();15 await page.fill(selectors[0], 'test');16 await page.click(selectors[1]);17 });18});19];
Using AI Code Generation
1await page.fill("input[name='q']", "qawolf");2await page.click("button[type='submit']");3await page.waitForNavigation();4await page.type("input[name='q']", "qawolf");5await page.click("button[type='submit']");6await page.waitForNavigation();7await page.click("button[aria-label='Search']");8await page.fill("input[name='q']", "qawolf");9await page.click("button[aria-label='Search']");10await page.fill("input[name='q']", "qawolf");11await page.click("button[aria-label='Search']");12await page.fill("input[name='q']", "qawolf");
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!