How to use waitForTimeout method in Playwright Internal

Best JavaScript code snippet using playwright-internal

e2e.test.js

Source:e2e.test.js Github

copy

Full Screen

...65 let called = false;66 page.route(endpoint, route => called = true);67 await page.goto(host);68 await page.click('text=Register');69 await page.waitForTimeout(300);70 await page.waitForSelector('form');71 await page.click('[type="submit"]');72 await page.waitForTimeout(300);73 expect(called).to.be.false;74 });75 it('register makes correct API call [ 5 Points ]', async () => {76 const endpoint = '**' + endpoints.register;77 const username = 'Ivan';78 const email = 'ivan@mail.bg';79 const password = '345321';80 page.route(endpoint, route => route.fulfill(json({ _id: '0001', email, accessToken: 'AAAA' })));81 await page.goto(host);82 await page.click('text=Register');83 await page.waitForTimeout(300);84 await page.waitForSelector('form');85 await page.fill('[name="username"]', username);86 await page.fill('[name="email"]', email);87 await page.fill('[name="password"]', password);88 await page.fill('[name="repeatPass"]', password);89 await page.check('#male');90 await page.waitForTimeout(300);91 const [response] = await Promise.all([92 page.waitForResponse(endpoint),93 page.click('[type="submit"]')94 ]);95 const postData = JSON.parse(response.request().postData());96 expect(postData.email).to.equal(email);97 expect(postData.password).to.equal(password);98 });99 it('login makes correct API call [ 5 Points ]', async () => {100 const endpoint = '**' + endpoints.login;101 const email = 'ivan@mail.bg';102 const password = '345321';103 page.route(endpoint, route => route.fulfill(json({ _id: '0001', email, accessToken: 'AAAA' })));104 await page.goto(host);105 await page.click('#button-div >> text="Login"');106 await page.waitForTimeout(300);107 await page.waitForSelector('form');108 await page.fill('[name="email"]', email);109 await page.fill('[name="password"]', password);110 await page.waitForTimeout(300);111 const [response] = await Promise.all([112 page.waitForResponse(endpoint),113 page.click('[type="submit"]')114 ]);115 const postData = JSON.parse(response.request().postData());116 expect(postData.email).to.equal(email);117 expect(postData.password).to.equal(password);118 });119 it('logout makes correct API call [ 5 Points ]', async () => {120 const loginEndpoint = '**' + endpoints.login;121 const email = 'ivan@mail.bg';122 const password = '345321';123 page.route(loginEndpoint, route => route.fulfill(json({ _id: '0001', email, accessToken: 'AAAA' })));124 await page.goto(host);125 await page.click('#button-div >> text="Login"');126 await page.waitForTimeout(300);127 await page.waitForSelector('form');128 await page.fill('[name="email"]', email);129 await page.fill('[name="password"]', password);130 await page.waitForTimeout(300);131 await Promise.all([132 page.waitForResponse(loginEndpoint),133 page.click('[type="submit"]')134 ]);135 const endpoint = '**' + endpoints.logout;136 await page.waitForTimeout(300);137 const [request] = await Promise.all([138 page.waitForRequest(endpoint),139 page.click('nav >> text="Logout"')140 ]);141 const token = request.headers()['x-authorization'];142 expect(request.method()).to.equal('GET');143 expect(token).to.equal('AAAA');144 });145 });146 describe('Navigation bar [ 5 Points ]', () => {147 const email = 'ivan@mail.bg';148 const password = '345321';149 it('logged user should see correct navigation [ 2.5 Points ]', async () => {150 // Login user151 const endpoint = '**' + endpoints.login;152 page.route(endpoint, route => route.fulfill(json({ _id: '0001', email, accessToken: 'AAAA' })));153 await page.goto(host);154 await page.click('#button-div >> text="Login"');155 await page.waitForTimeout(300);156 await page.waitForSelector('form');157 await page.fill('[name="email"]', email);158 await page.fill('[name="password"]', password);159 await page.waitForTimeout(300);160 await Promise.all([161 page.waitForResponse(endpoint),162 page.click('[type="submit"]')163 ]);164 //Test for navigation165 await page.waitForTimeout(300);166 expect(await page.isVisible('nav >> text="All Memes"')).to.be.true;167 expect(await page.isVisible('nav >> text="Create Meme"')).to.be.true;168 expect(await page.isVisible('nav >> text="My Profile"')).to.be.true;169 expect(await page.isVisible('nav >> text="Logout"')).to.be.true;170 expect(await page.isVisible('nav >> text="Login"')).to.be.false;171 expect(await page.isVisible('nav >> text="Register"')).to.be.false;172 expect(await page.isVisible('nav >> text="Home Page"')).to.be.false;173 });174 it('guest user should see correct navigation [ 2.5 Points ]', async () => {175 await page.goto(host);176 await page.waitForTimeout(300);177 expect(await page.isVisible('text="All Memes"')).to.be.true;178 expect(await page.isVisible('text="Create Meme"')).to.be.false;179 expect(await page.isVisible('text="My Profile"')).to.be.false;180 expect(await page.isVisible('text="Logout"')).to.be.false;181 expect(await page.isVisible('text="Login"')).to.be.true;182 expect(await page.isVisible('text="Register"')).to.be.true;183 expect(await page.isVisible('text="Home Page"')).to.be.true;184 });185 });186 describe('Catalog [ 25 Points ]', () => {187 it('loads static home page [ 5 Points ]', async () => {188 await page.goto(host);189 await page.waitForSelector('text=Welcome to Meme Lounge');190 await page.waitForTimeout(300);191 expect(await page.isVisible('text=Login to see our memes')).to.be.true;192 expect(await page.isVisible('#button-div >> text=Login')).to.be.true;193 expect(await page.isVisible('#button-div >> text=Register')).to.be.true;194 });195 it('show most recent memes [ 10 Points ]', async () => {196 await page.goto(host);197 await page.click('text=All Memes');198 await page.waitForTimeout(300);199 const titles = await page.$$eval('#memes .meme-title', t => t.map(s => s.textContent));200 await page.waitForTimeout(300);201 expect(titles.length).to.equal(6);202 expect(titles[0]).to.contains('test');203 expect(titles[1]).to.contains('meme 2');204 expect(titles[2]).to.contains('test 3');205 expect(titles[3]).to.contains('meme 4');206 expect(titles[4]).to.contains('test 5');207 });208 it('show meme details [ 5 Points ]', async () => {209 await page.goto(host);210 await page.click('text=All Memes');211 await page.waitForTimeout(300);212 await page.route('**' + endpoints.details + '*', route => route.fulfill(json(mockData[3])));213 await page.click('.meme:has-text("meme 4") >> text="Details"');214 await page.waitForTimeout(300);215 await page.waitForSelector('#meme-details > h1:has-text("meme 4")');216 await page.waitForSelector('.meme-description >p:has-text("description 4")');217 const title = await page.textContent('h1');218 const desc = await page.textContent('.meme-description >p');219 const img = await page.getAttribute('.meme-img >img', 'src');220 await page.waitForTimeout(300);221 expect(title).to.contains(mockData[3].title);222 expect(desc).to.contains(mockData[3].description);223 expect(img).to.contains(mockData[3].imageUrl);224 });225 it('guest does NOT see delete button [ 5 Points ]', async () => {226 await page.goto(host);227 await page.click('text=All Memes');228 await page.waitForTimeout(300);229 await page.click('.meme:first-child >> text="Details"');230 await page.waitForTimeout(300);231 expect(await page.isVisible('text="Delete"')).to.be.false;232 expect(await page.isVisible('text="Edit"')).to.be.false;233 });234 });235 describe('CRUD [ 40 Points ]', () => {236 const email = 'ivan@mail.bg';237 const password = '345321';238 // Login user239 beforeEach(async () => {240 const loginEndpoint = '**' + endpoints.login;241 page.route(loginEndpoint, route => route.fulfill(json({ _id: '0001', email, accessToken: 'AAAA' })));242 await page.goto(host);243 await page.click('#button-div >> text="Login"');244 await page.waitForSelector('form');245 await page.fill('[name="email"]', email);246 await page.fill('[name="password"]', password);247 await Promise.all([248 page.waitForResponse(loginEndpoint),249 page.click('[type="submit"]')250 ]);251 });252 it('create does NOT work with empty fields [ 5 Points ]', async () => {253 const endpoint = '**' + endpoints.create;254 let called = false;255 await page.waitForTimeout(300);256 await page.click('text="Create Meme"');257 await page.waitForSelector('form');258 page.route(endpoint, route => called = true);259 page.click('[type="submit"]');260 await page.waitForTimeout(300);261 expect(called).to.be.false;262 });263 it('create makes correct API call for logged in user [ 10 Points ]', async () => {264 const endpoint = '**' + endpoints.create;265 const mock = mockData[5];266 page.route(endpoint, route => route.fulfill(json(mock)));267 await page.waitForTimeout(300);268 await page.click('text=Create Meme');269 await page.waitForSelector('form');270 await page.fill('[name="title"]', mock.title);271 await page.fill('[name="description"]', mock.description);272 await page.fill('[name="imageUrl"]', mock.imageUrl);273 await page.waitForTimeout(300);274 const [response] = await Promise.all([275 page.waitForResponse(endpoint),276 page.click('[type="submit"]')277 ]);278 const postData = JSON.parse(response.request().postData());279 expect(postData.title).to.equal(mock.title);280 expect(postData.description).to.equal(mock.description);281 expect(postData.imageUrl).to.equal(mock.imageUrl);282 });283 it('non-author does NOT see delete and edit buttons [ 2.5 Points ]', async () => {284 const mock = Object.assign({}, mockData[4], { _ownerId: '0002' }); // Replace mock with non-owned object285 await page.goto(host);286 await page.click('text=All Memes');287 await page.waitForTimeout(300);288 await page.route('**' + endpoints.details + '*', route => route.fulfill(json(mock)));289 await page.click('.meme:has-text("meme 4") >> text="Details"');290 await page.waitForTimeout(300);291 await page.waitForSelector('h2:has-text("Meme Description")');292 expect(await page.isVisible('text="Delete"')).to.be.false;293 expect(await page.isVisible('text="Edit"')).to.be.false;294 });295 it('author sees delete and edit buttons [ 2.5 Points ]', async () => {296 const mock = mockData[5];297 await page.waitForTimeout(300);298 await page.click('text=All Memes');299 await page.waitForTimeout(300);300 await page.route('**' + endpoints.details + '*', route => route.fulfill(json(mock)));301 await page.click('.meme:has-text("My New Meme") >> text="Details"');302 await page.waitForTimeout(300);303 await page.waitForSelector('#meme-details > h1:has-text("Meme Title: My New Meme")');304 await page.waitForSelector('.meme-description >p:has-text("some description about this Meme")');305 expect(await page.isVisible('text="Delete"')).to.be.true;306 expect(await page.isEnabled('text="Delete"')).to.be.true;307 expect(await page.isVisible('text="Edit"')).to.be.true;308 expect(await page.isEnabled('text="Edit"')).to.be.true;309 });310 it('delete makes correct API call for logged in user [ 5 Points ]', async () => {311 const mock = mockData[5];312 await page.waitForTimeout(300);313 await page.click('text=All Memes');314 await page.waitForTimeout(300);315 await page.route('**' + endpoints.details + '*', route => route.fulfill(json(mock)));316 await page.click('.meme:has-text("My New Meme") >> text="Details"');317 await page.waitForSelector('#meme-details > h1:has-text("Meme Title: My New Meme")');318 page.on('dialog', dialog => dialog.accept());319 await page.waitForTimeout(300);320 const [request] = await Promise.all([321 page.waitForRequest('**' + endpoints.delete + '74463e5b-b893-44e8-bd14-5fc8feeddb94'),322 page.click('text="Delete"')323 ]);324 expect(request.method()).to.equal('DELETE');325 });326 it('edit does NOT work with empty fields [ 5 Points ]', async () => {327 const endpoint = endpoints.details;328 await page.waitForTimeout(300);329 await page.click('text=All Memes');330 await page.waitForTimeout(300);331 await page.route('**' + endpoints.details + '*', route => route.fulfill(json(mockData[5])));332 await page.click('.meme:has-text("test 5") >> text="Details"');333 await page.waitForTimeout(300);334 await page.click('text="Edit"');335 await page.waitForTimeout(300);336 let called = false;337 page.route(endpoint, route => called = true);338 await page.fill('[name="title"]', '');339 await page.fill('[name="description"]', '');340 await page.fill('[name="imageUrl"]', '');341 page.click('[type="submit"]');342 await page.waitForTimeout(300);343 expect(called).to.be.false;344 });345 it('edit should populate form with correct data [ 5 Points ]', async () => {346 const endpoint = endpoints.details;347 await page.waitForTimeout(300);348 await page.click('text=All Memes');349 await page.waitForTimeout(300);350 await page.route('**' + endpoints.details + '*', route => route.fulfill(json(mockData[5])));351 await page.click('.meme:has-text("test 5") >> text="Details"');352 await page.waitForTimeout(300);353 await page.click('text="Edit"');354 await page.waitForTimeout(300);355 const inputs = await page.$$eval('.container input', t => t.map(i => i.value));356 const textArea = await page.$eval('.container textarea', i => i.value);357 await page.waitForTimeout(300);358 expect(inputs[0]).to.contains(mockData[5].title);359 expect(inputs[1]).to.contains(mockData[5].imageUrl);360 expect(textArea).to.contains(mockData[5].description);361 });362 it.only('edit makes correct API call for logged in user [ 5 Points ]', async () => {363 const endpoint = endpoints.details;364 await page.waitForTimeout(300);365 await page.click('text=All Memes');366 await page.waitForTimeout(300);367 await page.route('**' + endpoint + '*', route => route.fulfill(json(mockData[5])));368 await page.click('.meme:has-text("test 5") >> text="Details"');369 await page.waitForTimeout(300);370 await page.click('text="Edit"');371 await page.waitForTimeout(300);372 await page.fill('[name="title"]', mockData[0].title);373 await page.fill('[name="description"]', mockData[0].description);374 await page.fill('[name="imageUrl"]', mockData[0].imageUrl);375 await page.waitForTimeout(300);376 const [request] = await Promise.all([377 page.waitForRequest('**' + endpoint + '74463e5b-b893-44e8-bd14-5fc8feeddb94'),378 page.click('[type="submit"]')379 ]);380 const postData = JSON.parse(request.postData());381 expect(request.method()).to.equal('PUT');382 expect(postData.title).to.contains(mockData[0].title);383 expect(postData.description).to.contains(mockData[0].description);384 expect(postData.imageUrl).to.equal(mockData[0].imageUrl);385 });386 });387 describe('User Profile Page [ 10 Points ]', async () => {388 const email = 'merry@mail.bg';389 const username = 'Merry';390 const password = '123456';391 const loginEndpoint = '**' + endpoints.login;392 // Login user393 beforeEach(async () => {394 page.route(loginEndpoint, route => route.fulfill(json({ _id: '0002', gender: 'female', username, email, accessToken: 'AAAA' })));395 await page.goto(host);396 await page.click('#button-div >> text="Login"');397 await page.waitForSelector('form');398 await page.waitForTimeout(300);399 await page.fill('[name="email"]', email);400 await page.fill('[name="password"]', password);401 await page.waitForTimeout(300);402 await Promise.all([403 page.waitForResponse(loginEndpoint),404 page.click('[type="submit"]')405 ]);406 });407 it('check profile page information - with 0 memes [ 5 Points ]', async () => {408 await page.route('**' + endpoints.profile, route => route.fulfill(json([])));409 await page.waitForTimeout(300);410 await page.click('text="My Profile"');411 await page.waitForTimeout(300);412 const values = await page.$$eval('.user-info p', p => p.map(p => p.textContent));413 const img = await page.getAttribute('#user-avatar-url', 'src');414 expect(values[0]).to.contains(username);415 expect(values[1]).to.contains(email);416 expect(values[2]).to.equal('My memes count: 0');417 expect(img).to.contains('/images/female.png');418 });419 it('check profile page for "No memes in database." - with 0 memes [ 2.5 Points ]', async () => {420 await page.waitForTimeout(300);421 await page.route('**' + endpoints.profile, route => route.fulfill(json([])));422 await page.click('text="My Profile"');423 await page.waitForTimeout(300);424 const userMemes = await page.textContent('.no-memes');425 await page.waitForTimeout(300);426 expect(userMemes).to.contains('No memes in database.');427 });428 it('check profile page information - with 2 memes [ 2.5 Points ]', async () => {429 await page.route('**' + endpoints.profile, route => route.fulfill(json([mockData[0], mockData[1]])));430 await page.waitForTimeout(300);431 await page.click('text="My Profile"');432 await page.waitForTimeout(300);433 const memes = await page.$$eval('.user-meme-listings .user-meme', p => p.map(p => p.textContent));434 await page.waitForTimeout(300);435 expect(memes.length).to.equal(2);436 expect(memes[0]).to.contains('test');437 expect(memes[1]).to.contains('meme 2');438 });439 });440 describe('BONUS: Notifications [ 5 Points ]', () => {441 it('Login notification with invalid data', async () => {442 const endpoint = '**' + endpoints.login;443 let called = false;444 page.route(endpoint, route => called = true);445 await page.goto(host);446 await page.click('#button-div >> text="Login"');447 await page.waitForTimeout(300);448 await page.waitForSelector('form');449 const preClickNotification = await page.isVisible('#errorBox');450 expect(preClickNotification).to.be.false;451 await page.click('[type="submit"]');452 await page.waitForTimeout(300);453 const notification = await page.isVisible('#errorBox');454 expect(notification).to.be.true;455 });456 it('Register notification with invalid data', async () => {457 const endpoint = '**' + endpoints.register;458 let called = false;459 page.route(endpoint, route => called = true);460 await page.goto(host);461 await page.click('#button-div >> text="Register"');462 await page.waitForTimeout(300);463 await page.waitForSelector('form');464 const preClickNotification = await page.isVisible('#errorBox');465 expect(preClickNotification).to.be.false;466 await page.click('[type="submit"]');467 await page.waitForTimeout(300);468 const notification = await page.isVisible('#errorBox');469 expect(notification).to.be.true;470 });471 it('Create notification with invalid data', async () => {472 // Login user473 const email = 'peter@abv.bg';474 const password = '123456';475 const longEndpoint = '**' + endpoints.login;476 page.route(longEndpoint, route => route.fulfill(json({ _id: '0001', email, accessToken: 'AAAA' })));477 await page.goto(host);478 await page.click('#button-div >> text="Login"');479 await page.waitForTimeout(300);480 await page.waitForSelector('form');481 await page.fill('[name="email"]', email);482 await page.fill('[name="password"]', password);483 await page.waitForTimeout(300);484 await Promise.all([485 page.waitForResponse(longEndpoint),486 page.click('[type="submit"]')487 ]);488 //Test489 await page.waitForTimeout(300);490 const endpoint = '**' + endpoints.details;491 let called = false;492 page.route(endpoint, route => called = true);493 await page.click('nav >> text="Create Meme"');494 await page.waitForTimeout(300);495 const preClickNotification = await page.isVisible('#errorBox');496 expect(preClickNotification).to.be.false;497 await page.click('[type="submit"]');498 await page.waitForTimeout(300);499 const notification = await page.isVisible('#errorBox');500 expect(notification).to.be.true;501 });502 it('Edit notification with invalid data', async () => {503 // Login user504 const email = 'peter@abv.bg';505 const password = '123456';506 const longEndpoint = '**' + endpoints.login;507 page.route(longEndpoint, route => route.fulfill(json({ _id: '0001', email, accessToken: 'AAAA' })));508 await page.goto(host);509 await page.click('#button-div >> text="Login"');510 await page.waitForTimeout(300);511 await page.waitForSelector('form');512 await page.fill('[name="email"]', email);513 await page.fill('[name="password"]', password);514 await page.waitForTimeout(300);515 await Promise.all([516 page.waitForResponse(longEndpoint),517 page.click('[type="submit"]')518 ]);519 //Test520 const endpoint = endpoints.details;521 await page.waitForTimeout(300);522 await page.click('text=All Memes');523 await page.waitForTimeout(300);524 await page.route('**' + endpoints.details + '*', route => route.fulfill(json(mockData[5])));525 await page.click('.meme:has-text("My New Meme") >> text="Details"');526 await page.waitForTimeout(300);527 await page.click('text="Edit"');528 await page.waitForTimeout(300);529 const preClickNotification = await page.isVisible('#errorBox');530 expect(preClickNotification).to.be.false;531 await page.fill('[name="title"]', '');532 await page.fill('[name="description"]', '');533 await page.fill('[name="imageUrl"]', '');534 await page.waitForTimeout(300);535 page.click('[type="submit"]');536 await page.waitForTimeout(300);537 const notification = await page.isVisible('#errorBox');538 expect(notification).to.be.true;539 });540 });...

Full Screen

Full Screen

PuppeteerService.js

Source:PuppeteerService.js Github

copy

Full Screen

...34}35async function inputSection2(page, title, author) {36 //section237 await page.click('#wWGgfe > div > div.GxjTuf > div:nth-child(1) > div > span > span > span')38 await page.waitForTimeout(500)39 await boldFont(page)40 await page.keyboard.type('Read ')41 await boldFont(page)42 await page.keyboard.type('and ')43 await italicFont(page)44 await page.keyboard.type('download ')45 await italicFont(page)46 await boldFont(page)47 await page.keyboard.type(title) 48 await boldFont(page)49 await page.keyboard.type(' in PDF, EPub, Mobi, Kindle online. Free book ')50 await italicFont(page)51 await page.keyboard.type('Behind Your Smiles: Eternity Publishing by '+ author)52 await italicFont(page)53 await alignCenter(page)54 await page.keyboard.press('Enter')55 await boldFont(page)56 await page.keyboard.type(title +' PDF')57 await boldFont(page)58 await page.keyboard.press('Enter')59 await page.keyboard.type('By - '+ author)60}61async function insertImg(page, link) {62 // image63 await page.waitForSelector('.d6wWde', {visible: true})64 await page.waitForTimeout(500)65 await page.click('.d6wWde')66 await page.waitForTimeout(500)67 await page.waitForSelector('span.Ix4kpb:nth-child(2) > div:nth-child(2) > div:nth-child(1)', {visible: true})68 await page.click('span.Ix4kpb:nth-child(2) > div:nth-child(2) > div:nth-child(1)')69 70 await page.waitForSelector('.OGNeob > iframe', {visible: true})71 const elementHandle = await page.$('.OGNeob > iframe');72 const frame = await elementHandle.contentFrame()73 await frame.waitForSelector('div.ThdJC:nth-child(2) > span:nth-child(2)', {visible: true})74 await frame.click('div.ThdJC:nth-child(2) > span:nth-child(2)')75 await frame.waitForSelector('.whsOnd', {visible: true})76 await frame.type('.whsOnd', link)77 await frame.waitForSelector('#yDmH0d > div.Q6HCU.IzuY1c.tJJJGe > div.H0U9m > div.WY4Fyb > div > div > div > div > div.hSF15e > div:nth-child(2)', {visible: true})78 await frame.click('div.U26fgb:nth-child(2) > span:nth-child(3) > span:nth-child(1)')79 // await page.waitForTimeout(1000)80 await page.waitForSelector('.cQgVbe > div:nth-child(2) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1)',{visible: true})81 await page.click('.cQgVbe > div:nth-child(2) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1)')82 await page.waitForTimeout(500)83 84 for (let j = 0; j<4; j++ ){85 await page.waitForTimeout(100)86 await page.keyboard.press('ArrowRight') 87 }88 await page.waitForTimeout(500)89}90async function headingLink(page, text) {91 await page.waitForTimeout(500)92 await page.waitForSelector('.zgFouf > svg:nth-child(1) > path:nth-child(1)', {visible: true})93 await page.click('.zgFouf > svg:nth-child(1) > path:nth-child(1)')94 await page.waitForTimeout(500);95 await page.keyboard.type(text)96 await page.keyboard.down('Control');97 await page.keyboard.press('A');98 await page.keyboard.up('Control');99 await page.waitForTimeout(300);100 await page.waitForSelector('.vuEmub', {visible: true})101 await page.click('.vuEmub')102 await page.waitForTimeout(500);103 await page.waitForSelector('.nK92pf > div:nth-child(2) > div:nth-child(3)', {visible: true})104 await page.click('.nK92pf > div:nth-child(2) > div:nth-child(3)')105 await page.waitForSelector('div.W9wDc:nth-child(2) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible: true})106 await page.click('div.W9wDc:nth-child(2) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)')107 await page.waitForTimeout(500)108 await page.type('div.W9wDc:nth-child(2) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)','18', { delay: 10})109 await page.waitForTimeout(500)110}111async function downloadButton(page, text, link) {112 await page.waitForTimeout(500)113 await page.click('.zgFouf > svg:nth-child(1) > path:nth-child(1)')114 await page.waitForTimeout(500)115 await underlineFont(page)116 await page.waitForTimeout(200)117 await boldFont(page)118 await page.waitForTimeout(200)119 await page.keyboard.sendCharacter('⇒')120 await page.waitForTimeout(200) 121 await page.keyboard.type(' '+text+' ')122 await page.waitForTimeout(200)123 await page.keyboard.sendCharacter('⇐')124 await page.waitForTimeout(200) 125 await underlineFont(page)126 await page.waitForTimeout(200) 127 await boldFont(page)128 await page.waitForTimeout(200)129 await alignCenter(page)130 await page.waitForTimeout(200) 131 await page.keyboard.down('Control');132 await page.keyboard.press('A');133 await page.keyboard.up('Control');134 await page.waitForTimeout(300);135 // await page.waitForSelector('.GJYBjd', {visible: true})136 // await page.click('.GJYBjd')137 // await page.waitForTimeout(300)138 139 // await page.waitForSelector('span.z80M1:nth-child(3) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1)', {visible: true})140 // await page.click('span.z80M1:nth-child(3) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1)')141 // await page.waitForTimeout(500)142 await page.waitForSelector('div.W9wDc:nth-child(2) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible: true})143 await page.click('div.W9wDc:nth-child(2) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)')144 await page.waitForTimeout(500)145 await page.type('div.W9wDc:nth-child(2) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', '18', { delay: 200})146 await page.waitForTimeout(200)147 await page.waitForSelector('.bFhy9b > div:nth-child(12) > div:nth-child(1) > span:nth-child(2) > span:nth-child(1) > span:nth-child(1)', { visible:true })148 await page.click('.bFhy9b > div:nth-child(12) > div:nth-child(1) > span:nth-child(2) > span:nth-child(1) > span:nth-child(1)')149 await page.waitForTimeout(200)150 await page.keyboard.type(link)151 await page.waitForTimeout(200)152 await page.click('.Sd2wDb > div:nth-child(1) > span:nth-child(3)')153 await page.waitForTimeout(200)154}155async function main(content) {156 157 const browser = await puppeteer.launch({ 158 executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe',159 userDataDir: 'C:/Users/User/AppData/Local/Google/Chrome/User Data',160 headless: false,161 defaultViewport: null,162 })163 const linkdata = [];164 let header1165 let header2 166 let title 167 let author 168 let pages 169 let publisher 170 let language 171 let isbn_10 172 let isbn_13 173 let linkimg 174 let linkDownBt 175 let textDownBt 176 let imgDownBt 177 let description 178 let tags179 const page = await browser.newPage();180 await page.goto('https://sites.google.com');181 // Open new Site182 await page.waitForSelector('div.docs-homescreen-templates-templateview-preview.docs-homescreen-templates-templateview-preview-showcase > img');183 await page.click('div.docs-homescreen-templates-templateview-preview.docs-homescreen-templates-templateview-preview-showcase > img');184 185 //header setting186 await page.waitForTimeout(500)187 await page.waitForSelector('#yDmH0d > div.MUd2qe.gJ9tsd > div.y3IDJd.CatYBe.Fx3kmc.fmzcZd > span > div > div > div.bWTzgc > div > div > span > div > div.rZHESd > div > div > article > section > div.LS81yb.TZTnI.IKVHqc.aVXSwc.yaqOZd.LB7kq.O13XJf.nyKByd > div.zXDYWd.guoAab.mYVXT > group > div.JNdkSc-SmKAyb > div > row > div > div.oKdM2c.guoAab.row_Default > tile > div.jXK9ad-SmKAyb.v7v1sb > div');188 await page.click('#yDmH0d > div.MUd2qe.gJ9tsd > div.y3IDJd.CatYBe.Fx3kmc.fmzcZd > span > div > div > div.bWTzgc > div > div > span > div > div.rZHESd > div > div > article > section > div.LS81yb.TZTnI.IKVHqc.aVXSwc.yaqOZd.LB7kq.O13XJf.nyKByd > div.zXDYWd.guoAab.mYVXT > group > div.JNdkSc-SmKAyb > div > row > div > div.oKdM2c.guoAab.row_Default > tile > div.jXK9ad-SmKAyb.v7v1sb > div');189 await page.waitForSelector('#yDmH0d > div.MUd2qe.gJ9tsd > div.y3IDJd.CatYBe.Fx3kmc.fmzcZd > span > div > div > div.bWTzgc > div > div > span > div > div.rZHESd > div > div > article > section > div.LS81yb.TZTnI.IKVHqc.aVXSwc.yaqOZd.LB7kq.O13XJf.nyKByd > div:nth-child(3) > div.Av8pHf.siiXfe > div.U26fgb.O0WRkf.oG5Srb.C0oVfc.YYHIke.i65P1d.Keh7oc.null.M9Bg4d > span > span > span.LrArxf', { visible: true });190 await page.click('#yDmH0d > div.MUd2qe.gJ9tsd > div.y3IDJd.CatYBe.Fx3kmc.fmzcZd > span > div > div > div.bWTzgc > div > div > span > div > div.rZHESd > div > div > article > section > div.LS81yb.TZTnI.IKVHqc.aVXSwc.yaqOZd.LB7kq.O13XJf.nyKByd > div:nth-child(3) > div.Av8pHf.siiXfe > div.U26fgb.O0WRkf.oG5Srb.C0oVfc.YYHIke.i65P1d.Keh7oc.null.M9Bg4d > span > span > span.LrArxf');191 await page.waitForSelector('#yDmH0d > div.MUd2qe.gJ9tsd > div.y3IDJd.CatYBe.Fx3kmc.fmzcZd > span > div > div > div.bWTzgc > div > div > span > div > div.rZHESd > div > div > article > section > div.LS81yb.TZTnI.IKVHqc.aVXSwc.yaqOZd.LB7kq.O13XJf.nyKByd > div:nth-child(3) > div:nth-child(3) > div:nth-child(5) > span > span > span.DPvwYc.rvGaTc', { visible: true });192 await page.click('#yDmH0d > div.MUd2qe.gJ9tsd > div.y3IDJd.CatYBe.Fx3kmc.fmzcZd > span > div > div > div.bWTzgc > div > div > span > div > div.rZHESd > div > div > article > section > div.LS81yb.TZTnI.IKVHqc.aVXSwc.yaqOZd.LB7kq.O13XJf.nyKByd > div:nth-child(3) > div:nth-child(3) > div:nth-child(5) > span > span > span.DPvwYc.rvGaTc');193 //atur format194 await page.waitForTimeout(500);195 await page.waitForSelector('div.ThdJC:nth-child(3)', {visible: true})196 await page.click('div.ThdJC:nth-child(3)')197 await page.waitForTimeout(500);198 await page.mouse.wheel({deltaY: 1000})199 await page.waitForSelector('div.m6xOQ:nth-child(6)', {visible: true})200 await page.click('div.m6xOQ:nth-child(6)')201 //click publish for websitename202 await page.waitForTimeout(200)203 await page.waitForSelector('.UQuaGc', {visible: true})204 await page.click('.UQuaGc')205 const weblink = `${nanoid(16)}`.replace(/[^a-zA-Z0-9 ]/g, "").toLowerCase()206 console.log(weblink)207 await page.waitForTimeout(200)208 await page.waitForSelector('.rXTzdc > div:nth-child(1) > input:nth-child(1)', {visible: true})209 await page.click('.rXTzdc > div:nth-child(1) > input:nth-child(1)')210 await page.type('.rXTzdc > div:nth-child(1) > input:nth-child(1)', weblink)211 await page.waitForSelector('.yfzDSb > svg:nth-child(1)', {visible: true})212 await page.waitForSelector('.OE6hId > div:nth-child(2)', {visible: true})213 await page.click('.OE6hId > div:nth-child(2)') 214 215 await page.waitForTimeout(2000)216 await page.waitForSelector('div.ThdJC:nth-child(1) > span:nth-child(2) > div:nth-child(1)', {visible: true})217 await page.click('div.ThdJC:nth-child(1) > span:nth-child(2) > div:nth-child(1)')218 await page.waitForTimeout(200)219 console.log(content)220 for (let i = 0; i<content.length; i++) {221 header1 = content[i].header222 header2 = header1.replace(/[^a-zA-Z0-9 ]/g, "").replace(/\s\s+/g, ' ');223 console.log(header2)224 title = content[i].title225 author = content[i].author226 pages = content[i].pages227 publisher = content[i].publisher228 language = content[i].language229 isbn_10 = content[i]['ISBN-10']230 isbn_13 = content[i]['ISBN-13'].replace(/[^a-zA-Z0-9 ]/g, "")231 linkimg = content[i]['Front Cover']232 linkDownBt = content[i]['read online link']233 textDownBt = content[i]['read online text']234 imgDownBt = content[i]['read online img'];235 description = content[i].description236 tags = content[i].tags237 238 if (i<1) {239 await page.waitForTimeout(200)240 await page.waitForSelector('div.ThdJC:nth-child(2) > span:nth-child(2) > div:nth-child(1)', {visible: true})241 await page.click('div.ThdJC:nth-child(2) > span:nth-child(2) > div:nth-child(1)')242 await page.waitForTimeout(200)243 await page.waitForSelector('.xmAgjb > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible: true})244 await page.hover('.xmAgjb > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)')245 await page.waitForTimeout(200)246 await page.waitForSelector('div.JRtysb:nth-child(3) > span:nth-child(2) > span:nth-child(1) > svg:nth-child(1)', {visible: true})247 await page.click('div.JRtysb:nth-child(3) > span:nth-child(2) > span:nth-child(1) > svg:nth-child(1)')248 await page.waitForTimeout(500)249 await page.waitForSelector('span.tHuOYd:nth-child(2) > div:nth-child(2) > div:nth-child(1)', {visible: true})250 await page.click('span.tHuOYd:nth-child(2) > div:nth-child(2) > div:nth-child(1)')251 252 await page.waitForTimeout(200)253 await page.waitForSelector('.WnONLb > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible: true})254 await page.click('.WnONLb > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)')255 await page.waitForTimeout(200)256 await page.waitForSelector('.WnONLb > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible: true})257 await page.keyboard.down('Control');258 await page.keyboard.press('A');259 await page.keyboard.up('Control');260 await page.keyboard.press('Backspace');261 await page.type('.WnONLb > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', header1)262 await page.waitForTimeout(200)263 await page.waitForSelector('div.HQ8yf:nth-child(1)', {visible: true})264 await page.click('div.HQ8yf:nth-child(1)')265 await page.waitForTimeout(200)266 await page.$eval('.RRvhed > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', (el) => {267 el.setAttribute('maxlength', '1000')268 })269 await page.waitForSelector('.RRvhed > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible:true})270 await page.type('.RRvhed > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', header2)271 await page.waitForTimeout(200)272 await page.waitForSelector('div.HQ8yf:nth-child(2)', {visible: true})273 await page.click('div.HQ8yf:nth-child(2)')274 await page.waitForTimeout(200)275 await page.waitForSelector('div.ThdJC:nth-child(1) > span:nth-child(2) > div:nth-child(1)', {visible: true})276 await page.click('div.ThdJC:nth-child(1) > span:nth-child(2) > div:nth-child(1)')277 await page.waitForTimeout(200)278 } else {279 //jika bukan homepage280 await page.waitForTimeout(200)281 await page.waitForSelector('div.ThdJC:nth-child(2) > span:nth-child(2) > div:nth-child(1)', {visible: true})282 await page.click('div.ThdJC:nth-child(2) > span:nth-child(2) > div:nth-child(1)')283 await page.waitForTimeout(200)284 await page.waitForSelector('span.Ip8zfc > span:nth-child(1)', {visible: true})285 await page.hover('span.Ip8zfc > span:nth-child(1)')286 await page.waitForTimeout(200)287 await page.waitForSelector('.es0ex', {visible: true})288 await page.click('.es0ex')289 290 await page.waitForTimeout(200)291 292 await page.waitForSelector('.WnONLb > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible: true})293 await page.click('.WnONLb > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)')294 await page.waitForTimeout(200)295 await page.waitForSelector('.WnONLb > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible: true})296 await page.type('.WnONLb > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', header1)297 await page.waitForTimeout(200)298 await page.waitForSelector('div.HQ8yf:nth-child(1)', {visible: true})299 await page.click('div.HQ8yf:nth-child(1)')300 await page.waitForTimeout(200)301 await page.$eval('.RRvhed > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', (el) => {302 el.setAttribute('maxlength', '1000')303 })304 await page.waitForSelector('.RRvhed > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible:true})305 await page.type('.RRvhed > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', header2)306 await page.waitForTimeout(200)307 308 await page.waitForSelector('div.HQ8yf:nth-child(2)', {visible: true})309 await page.click('div.HQ8yf:nth-child(2)')310 await page.waitForTimeout(800)311 }312 //back to insert submenu313 await page.waitForSelector('#yDmH0d > div.MUd2qe.gJ9tsd > div.vW7mGd.XM6wle.mkDbPd.M3Aaxc.NVNv2d.Y3eu4c > span > div > div.BFsh9 > div.mrslJ.ZjAUM.q21cab.H3UEIb > div:nth-child(1) > span > div', {visible: true})314 await page.click('#yDmH0d > div.MUd2qe.gJ9tsd > div.vW7mGd.XM6wle.mkDbPd.M3Aaxc.NVNv2d.Y3eu4c > span > div > div.BFsh9 > div.mrslJ.ZjAUM.q21cab.H3UEIb > div:nth-child(1) > span > div')315 await page.waitForTimeout(200)316 317 await header(page, header1);318 await inputSection2(page, title, author);319 await insertImg(page, linkimg);320 321 322 //section3323 await page.mouse.wheel({deltaY: 300})324 await page.waitForTimeout(500)325 await page.mouse.wheel({deltaY: 200})326 await page.click('.zgFouf > svg:nth-child(1) > path:nth-child(1)')327 await page.waitForTimeout(500)328 await page.keyboard.type('√')329 await page.waitForTimeout(200)330 await page.keyboard.type('PDF | ')331 await page.waitForTimeout(200)332 await page.keyboard.sendCharacter('√')333 await page.waitForTimeout(200)334 await page.keyboard.type('KINDLE | ')335 await page.waitForTimeout(200)336 await page.keyboard.sendCharacter('√')337 await page.waitForTimeout(200)338 await page.keyboard.type('EPUB')339 await alignCenter(page)340 341 await page.click('.zgFouf > svg:nth-child(1) > path:nth-child(1)')342 await page.waitForTimeout(500)343 await boldFont(page)344 await page.waitForTimeout(100)345 await page.keyboard.type('⇓⇓⇓')346 await page.waitForTimeout(100)347 await boldFont(page)348 await page.waitForTimeout(100)349 await alignCenter(page)350 //download button upper351 await downloadButton(page, textDownBt, linkDownBt)352 353 await headingLink(page, 'BOOK DETAILS:')354 //Book details355 await page.mouse.wheel({deltaY: 250})356 await page.waitForSelector('.cQgVbe > div:nth-child(2) > div:nth-child(1) > div:nth-child(4)', {visible: true})357 await page.waitForTimeout(500)358 await page.waitForSelector('.zgFouf > svg:nth-child(1) > path:nth-child(1)', {visible: true})359 await page.click('.zgFouf > svg:nth-child(1) > path:nth-child(1)')360 await page.waitForTimeout(500);361 await page.keyboard.type('Title : ')362 await boldFont(page)363 await page.keyboard.type(title)364 await boldFont(page)365 await page.keyboard.press('Enter')366 367 await page.keyboard.type('Author : ')368 await page.keyboard.type(author)369 await page.keyboard.press('Enter')370 371 await page.keyboard.type('Pages : ')372 await page.keyboard.type(pages)373 await page.keyboard.type(' pages')374 await page.keyboard.press('Enter')375 376 await page.keyboard.type('Publisher : ')377 await page.keyboard.type(publisher)378 await page.keyboard.press('Enter')379 await page.mouse.wheel({deltaY: 200})380 await page.keyboard.type('Language : ')381 await page.keyboard.type(language)382 await page.keyboard.press('Enter')383 384 await page.keyboard.type('ISBN-10 : ')385 await page.keyboard.type(isbn_10)386 await page.keyboard.press('Enter')387 await page.mouse.wheel({deltaY: 300})388 await page.keyboard.type('ISBN-13 : ')389 await page.keyboard.type(isbn_13)390 await page.keyboard.press('Enter')391 await page.mouse.wheel({deltaY: 300})392 await page.waitForTimeout(200)393 394 await page.mouse.wheel({deltaY: 300})395 await page.click('.zgFouf > svg:nth-child(1) > path:nth-child(1)')396 await page.waitForTimeout(200)397 await boldFont(page)398 await page.waitForTimeout(100)399 await page.keyboard.type('⇓⇓⇓')400 await page.waitForTimeout(100)401 await boldFont(page)402 await page.waitForTimeout(100)403 await alignCenter(page)404 await insertImg(page, imgDownBt);405 await page.waitForTimeout(200)406 await page.waitForSelector('.bFhy9b > div:nth-child(3) > div:nth-child(1)', { visible: true })407 await page.click('.bFhy9b > div:nth-child(3) > div:nth-child(1)')408 await page.waitForTimeout(500)409 await page.waitForSelector('.YTWiWc > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible: true})410 await page.click('.YTWiWc > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)')411 await page.waitForTimeout(200)412 await page.keyboard.type(linkDownBt)413 await page.waitForTimeout(200)414 await page.click('.Sd2wDb > div:nth-child(1)')415 await page.waitForTimeout(200)416 //heading link2417 await headingLink(page, title +' BY '+ author)418 419 //keterangan2420 await page.waitForTimeout(200)421 await page.waitForSelector('.zgFouf > svg:nth-child(1) > path:nth-child(1)', {visible: true})422 await page.click('.zgFouf > svg:nth-child(1) > path:nth-child(1)')423 await page.waitForTimeout(200);424 await page.keyboard.type(description)425 await page.waitForTimeout(200);426 //subheading427 await page.waitForTimeout(200)428 await page.waitForSelector('.zgFouf > svg:nth-child(1) > path:nth-child(1)', {visible: true})429 await page.click('.zgFouf > svg:nth-child(1) > path:nth-child(1)')430 await page.waitForTimeout(200);431 await page.keyboard.type(title +' by '+ author)432 await page.keyboard.down('Control');433 await page.keyboard.press('A');434 await page.keyboard.up('Control');435 await page.waitForTimeout(300);436 await page.waitForSelector('.vuEmub', {visible: true})437 await page.click('.vuEmub')438 await page.waitForTimeout(200);439 await page.waitForSelector('.nK92pf > div:nth-child(2) > div:nth-child(4)', {visible: true})440 await page.click('.nK92pf > div:nth-child(2) > div:nth-child(4)')441 await page.waitForTimeout(500)442 //Tags443 await page.waitForTimeout(200)444 await page.waitForSelector('.zgFouf > svg:nth-child(1) > path:nth-child(1)', {visible: true})445 await page.click('.zgFouf > svg:nth-child(1) > path:nth-child(1)')446 await page.waitForTimeout(200);447 await page.keyboard.type('Tags: '+ tags)448 //click publish449 await page.waitForTimeout(200)450 await page.waitForSelector('.UQuaGc', {visible: true})451 await page.click('.UQuaGc')452 await page.waitForSelector('.jNgCIc > iframe:nth-child(2)', {visible: true})453 await page.click('.jzUkrb > div:nth-child(2)')454 //copy link455 await page.waitForTimeout(200)456 await page.waitForSelector('.odraff > svg:nth-child(1)',{visible: true})457 await page.click('.odraff > svg:nth-child(1)')458 await page.waitForSelector('.ocNfZ > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', {visible:true})459 let weblink1 = await page.$eval('.ocNfZ > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)', el => {return el.getAttribute('value')})460 let weblink2 = {link: weblink1}461 console.log(weblink2)462 linkdata.push(weblink2)463 console.log(linkdata)464 await page.waitForTimeout(200)465 await page.waitForSelector('.VY7JQd > div:nth-child(1) > span:nth-child(2) > span:nth-child(1) > svg:nth-child(1)', {visible: true})466 await page.click('.VY7JQd > div:nth-child(1) > span:nth-child(2) > span:nth-child(1) > svg:nth-child(1)')467 }468 return linkdata;469};470module.exports = {471 main...

Full Screen

Full Screen

main.e2e.js

Source:main.e2e.js Github

copy

Full Screen

...24 let lastname = "trump";25 let password = "ditiseenwachtwoord";26 let password2 = "ditishettweedewachtwoord";27 await thePage.goto("http://localhost:3000/register");28 await thePage.waitForTimeout(1000);29 await thePage.waitForTimeout("input[name=register]");30 await thePage.type("input[name=email]", email);31 await thePage.type("input[name=firstname]", firstname);32 await thePage.type("input[name=lastname]", lastname);33 await thePage.type("input[name=password]", password);34 await thePage.type("input[name=confirmpassword]", password2);35 await thePage.click('input[name="register"]');36 });37 test("User registers a new account that already exists", async () => {38 const password = "ditiseenwachtwoord";39 await thePage.waitForTimeout(1500);40 await thePage.$eval(41 "input[name=password]",42 (input, value) => (input.value = value),43 ""44 );45 await thePage.$eval(46 "input[name=confirmpassword]",47 (input, value) => (input.value = value),48 ""49 );50 await thePage.type("input[name=password]", password);51 await thePage.type("input[name=confirmpassword]", password);52 await thePage.click('input[name="register"]');53 });54 test("User registers a new account that does not exist yet", async () => {55 let email = "joebiden@usa.com";56 await thePage.waitForTimeout(1500);57 await thePage.waitForTimeout("input[name=register]");58 await thePage.$eval(59 "input[name=email]",60 (input, value) => (input.value = value),61 ""62 );63 await thePage.type("input[name=email]", email);64 await thePage.click('input[name="register"]');65 });66 test("User clicks the hamburger menu and selects the option to save an article", async () => {67 let url =68 "https://www.nu.nl/politiek/6102049/wilders-gaf-donatie-van-175000-euro-voor-rechtszaak-niet-door-aan-kamer.html";69 let title = "horeca krijgt wellicht extra steun";70 let title2 =71 "Kamer laakt vaccinatiechaos, oppositie wil meer betrokkenheid van Rutte";72 let title3 =73 "Rutte: Theaters, bioscopen en musea mogen donderdag weer open";74 let url2 =75 "https://www.nu.nl/politiek/6100271/kamer-laakt-vaccinatiechaos-oppositie-wil-meer-betrokkenheid-van-rutte.html";76 let url3 =77 "https://www.nu.nl/cultuur-overig/6090311/rutte-theaters-bioscopen-en-musea-mogen-donderdag-weer-open.html?redirect=1";78 await thePage.waitForTimeout(1500);79 await thePage.click('a[id="hamburger"]');80 await thePage.waitForTimeout(1000);81 await thePage.click('i[id="saveArticle"]');82 await thePage.waitForTimeout(1500);83 await thePage.type('input[id="url"]', url);84 await thePage.type('input[id="title"]', title);85 await thePage.waitForTimeout(2500);86 await thePage.click('#chipsDiv [class="input"]');87 await thePage.type('#chipsDiv [class="input"]', "Horeca");88 await thePage.keyboard.press("Enter");89 await thePage.click('#chipsDiv [class="input"]');90 await thePage.type('#chipsDiv [class="input"]', "Steun");91 await thePage.keyboard.press("Enter");92 await thePage.waitForTimeout(3000);93 await thePage.click('button[id="addTag"]');94 await thePage.click('button[id="saveArticle"]');95 await thePage.waitForTimeout(5000);96 await thePage.$eval(97 "input[id=url]",98 (input, value) => (input.value = value),99 ""100 );101 await thePage.type('input[id="url"]', url2);102 await thePage.$eval(103 "input[id=title]",104 (input, value) => (input.value = value),105 ""106 );107 await thePage.type('input[id="title"]', title2);108 await thePage.click('i[id="deleteTag"]');109 await thePage.click('#chipsDiv [class="input"]');110 await thePage.type('#chipsDiv [class="input"]', "Rutte");111 await thePage.keyboard.press("Enter");112 await thePage.click('#chipsDiv [class="input"]');113 await thePage.type('#chipsDiv [class="input"]', "Vaccinatiechaos");114 await thePage.keyboard.press("Enter");115 await thePage.waitForTimeout(3000);116 await thePage.click('button[id="addTag"]');117 await thePage.click('button[id="saveArticle"]');118 await thePage.waitForTimeout(5000);119 await thePage.$eval(120 "input[id=url]",121 (input, value) => (input.value = value),122 ""123 );124 await thePage.type('input[id="url"]', url3);125 await thePage.$eval(126 "input[id=title]",127 (input, value) => (input.value = value),128 ""129 );130 await thePage.type('input[id="title"]', title3);131 await thePage.click('i[id="deleteTag"]');132 await thePage.click('#chipsDiv [class="input"]');133 await thePage.type('#chipsDiv [class="input"]', "Rutte");134 await thePage.keyboard.press("Enter");135 await thePage.click('#chipsDiv [class="input"]');136 await thePage.type('#chipsDiv [class="input"]', "bioscopen");137 await thePage.keyboard.press("Enter");138 await thePage.type('#chipsDiv [class="input"]', "musea");139 await thePage.keyboard.press("Enter");140 await thePage.waitForTimeout(3000);141 await thePage.click('button[id="addTag"]');142 await thePage.click('button[id="saveArticle"]');143 await thePage.waitForTimeout(5000);144 await thePage.click('a[id="hamburger"]');145 await thePage.waitForTimeout(1500);146 await thePage.click('i[id="dashboard"]');147 await thePage.waitForTimeout(3000);148 });149 test("user clicks an article to read", async () => {150 let title = "Horeca wordt gered door het parlement";151 let source = "www.nu.nl";152 let author = "Jan Kooiman";153 let description =154 "2020. Het jaar waarin corona alles veranderde. We hebben met elkaar veel bereikt, maar zijn er nog lang niet. We moeten samen nog veel meer voor elkaar krijgen, dus we blijven ons hard maken voor het herstel van de horeca";155 for (let i = 0; i < 12; i++) {156 await thePage.keyboard.press("ArrowDown");157 }158 await thePage.click('a[id="seeArticle"]');159 await thePage.waitForTimeout(2500);160 await thePage.waitForTimeout(1500);161 await thePage.click('i[id="editArticle"]');162 await thePage.waitForTimeout(1500);163 await thePage.$eval(164 "input[id=title-input]",165 (input, value) => (input.value = value),166 ""167 );168 await thePage.waitForTimeout(1500);169 await thePage.type('input[id="title-input"]', "");170 await thePage.waitForTimeout(5000);171 await thePage.click('i[id="editArticle"]');172 await thePage.waitForTimeout(1500);173 await thePage.type('input[id="title-input"]', title);174 await thePage.$eval(175 "input[id=author-input]",176 (input, value) => (input.value = value),177 ""178 );179 await thePage.type('input[id="author-input"]', author);180 await thePage.$eval(181 "input[id=source-input]",182 (input, value) => (input.value = value),183 ""184 );185 await thePage.type('input[id="source-input"]', source);186 await thePage.$eval(187 "textarea[id=description-input]",188 (input, value) => (input.value = value),189 ""190 );191 await thePage.type('textarea[id="description-input"]', description);192 await thePage.click('#chipsDiv [class="input"]');193 await thePage.type('#chipsDiv [class="input"]', "Amsterdam");194 await thePage.keyboard.press("Enter");195 await thePage.click('#chipsDiv [class="input"]');196 await thePage.type('#chipsDiv [class="input"]', "klanten");197 await thePage.keyboard.press("Enter");198 await thePage.click('#chipsDiv [class="input"]');199 await thePage.type('#chipsDiv [class="input"]', "hebberig");200 await thePage.keyboard.press("Enter");201 await thePage.waitForTimeout(3500);202 await thePage.click('button[id="addTag"]');203 await thePage.waitForTimeout(1500);204 await thePage.click('i[id="editArticle"]');205 await thePage.waitForTimeout(1500);206 for (let i = 0; i < 20; i++) {207 await thePage.keyboard.press("ArrowDown");208 }209 await thePage.waitForTimeout(3000);210 await thePage.click('button[id="preferenceButton"]');211 await thePage.waitForTimeout(1500);212 await thePage.click('div[id="typewriter"]');213 await thePage.waitForTimeout(1500);214 await thePage.click('div[id="dark"]');215 await thePage.waitForTimeout(1500);216 await thePage.click('div[id="cancelPreferences"]');217 await thePage.waitForTimeout(1500);218 await thePage.focus('div[id="root"]');219 await thePage.click('div[id="root"]');220 await thePage.click('div[id="root"]');221 await thePage.waitForTimeout(1500);222 await thePage.click('button[id="preferenceButton"]');223 await thePage.waitForTimeout(1500);224 await thePage.click('div[id="darkblue"]');225 await thePage.waitForTimeout(1000);226 await thePage.click('div[id="savePreferences"]');227 await thePage.waitForTimeout(1000);228 await thePage.click('div[id="root"]');229 await thePage.focus('div[id="root"]');230 await thePage.click('div[id="root"]');231 await thePage.click('div[id="root"]');232 await thePage.waitForTimeout(1000);233 for (let i = 0; i < 60; i++) {234 await thePage.keyboard.press("ArrowDown");235 }236 await thePage.waitForTimeout(5000);237 await thePage.focus('a[id="originalArticle"]');238 await thePage.waitForTimeout(2500);239 await thePage.click('a[id="originalArticle"]');240 await thePage.waitForTimeout(2500);241 await thePage.goBack();242 await thePage.waitForTimeout(2500);243 await thePage.click('a[id="hamburger"]');244 await thePage.waitForTimeout(1500);245 await thePage.click('i[id="dashboard"]');246 });247 test("User logs out of the LaterLezer app", async () => {248 await thePage.waitForTimeout(1500);249 await thePage.click('a[id="hamburger"]');250 await thePage.waitForTimeout(1000);251 await thePage.click('i[id="logout"]');252 await thePage.waitForTimeout(2500);253 });254 test("User logs in the webpage with wrong password", async () => {255 let email = "joebiden@usa.com";256 let password = "ditiseenwachtwoord1";257 await thePage.type('input[id="email"]', email);258 await thePage.type('input[id="password"]', password);259 await thePage.waitForTimeout(1500);260 await thePage.click('a[id="login"]');261 await thePage.waitForTimeout(4000);262 });263 test("User logs in the webpage with right password", async () => {264 let email = "joebiden@usa.com";265 let password = "ditiseenwachtwoord";266 await thePage.$eval(267 "input[id=email]",268 (input, value) => (input.value = value),269 ""270 );271 await thePage.type('input[id="email"]', email);272 await thePage.waitForTimeout(500);273 await thePage.$eval(274 "input[id=password]",275 (input, value) => (input.value = value),276 ""277 );278 await thePage.type('input[id="password"]', password);279 await thePage.waitForTimeout(1500);280 await thePage.click('a[id="login"]');281 await thePage.waitForTimeout(4000);282 });283 test("User searches for an article", async () => {284 await thePage.click('a[id="hamburger"]');285 await thePage.waitForTimeout(1500);286 await thePage.click('i[id="search"]');287 await thePage.waitForTimeout(1500);288 await thePage.click('button[id="metaData"]');289 await thePage.waitForTimeout(7500);290 await thePage.type('input[id="searchArticle"]', "rutte");291 await thePage.waitForTimeout(1500);292 await thePage.click('button[id="searchButton"]');293 await thePage.waitForTimeout(3500);294 await thePage.waitForTimeout(1000);295 for (let i = 0; i < 60; i++) {296 await thePage.keyboard.press("ArrowDown");297 }298 await thePage.waitForTimeout(2500);299 for (let i = 0; i < 60; i++) {300 await thePage.keyboard.press("ArrowUp");301 }302 await thePage.waitForTimeout(2000);303 await thePage.$eval(304 "input[id=searchArticle]",305 (input, value) => (input.value = value),306 ""307 );308 await thePage.type('input[id="searchArticle"]', "coalitie");309 await thePage.waitForTimeout(1500);310 await thePage.click('input[id="contentSearch"]');311 await thePage.waitForTimeout(1500);312 await thePage.click('button[id="searchButton"]');313 await thePage.waitForTimeout(3500);314 for (let i = 0; i < 60; i++) {315 await thePage.keyboard.press("ArrowDown");316 }317 await thePage.waitForTimeout(5000);318 for (let i = 0; i < 60; i++) {319 await thePage.keyboard.press("ArrowUp");320 }321 });...

Full Screen

Full Screen

stepdefs.js

Source:stepdefs.js Github

copy

Full Screen

...20 let txOrigen = await page.$("form[data-widget=form-booking-box] input.form-control.pbOrigen.airport.airport_ida[data-name=pbOrigen]");21 await txOrigen.type("Bogota", {delay: 100});22 await txOrigen.press("ArrowDown");23 await txOrigen.press("Enter");24 await page.waitForTimeout(1 * 1000);25});26When('I select the destination city', async () => {27 let txDestino = await page.$("form[data-widget=form-booking-box] input.form-control.pbDestino.airport.airport_regreso[data-name=pbDestino]");28 await txDestino.type("Miami", {delay: 100});29 await txDestino.press("ArrowDown");30 await txDestino.press("Enter");31 await page.waitForTimeout(1 * 1000);32});33When('I select my departure date', async () => {34 let txDestino = await page.$("form[data-widget=form-booking-box] input.form-control.pbDestino.airport.airport_regreso[data-name=pbDestino]");35 txDestino.press("Tab");36 await page.waitForSelector("form[data-widget=form-booking-box] div.calendar-container.hidden-xs.new-calendar-pos.calendar-home", {visible: true});37 await page.waitForTimeout(1 * 1000);38 await page.click("form[data-widget=form-booking-box] td.cal1 div.number-days td > div.intern-day")[1];39 await page.waitForTimeout(1 * 1000);40});41When('I select my return date', async () => {42 await page.click("form[data-widget=form-booking-box] td.cal2 div.number-days td > div.intern-day")[1];43 await page.waitForTimeout(1 * 1000);44});45When('I click on search for flights', async () => {46 let btSearch = await page.$("form[data-widget=form-booking-box] button[title~=Buscar]");47 btSearch.click();48});49When('I accept the notification pop-up', async () => {50 await page.waitForSelector("div.modal-dialog.modal-lg", {visible: true});51 await page.click("div.modal-dialog.modal-lg button.btn.primary.continue.pull-right");52 await page.waitForNavigation({timeout: 0, waitUntil: 'networkidle2'});53});54When('I click on the menu button', async () => {55 await page.click("div.nav.navbar-nav.menu-hamb > a.menuGlobal");56 await page.waitForSelector("div.container-links-menu-desktop.visible-lg.visible-md", {visible: true});57});58When("Select Horarios de vuelo", async () => {59 await page.click("a[href*='/consulta-itinerarios/']");60 await page.waitForTimeout(5 * 1000); // waitForNavigation no funciona en este paso. Al parecer la página tiene problemas de latencia61});62When("Select origin Bogota", async () => {63 let txOrigen = await page.$("input#origenIter");64 await txOrigen.type("Bogota", {delay: 100});65 await txOrigen.press("ArrowDown");66 await txOrigen.press("Enter");67 await page.waitForTimeout(1 * 1000);68});69When("Select destination Cartagena", async () => {70 let txDestino = await page.$("input#destinoIter");71 await txDestino.type("Cartagena", {delay: 100});72 await txDestino.press("ArrowDown");73 await txDestino.press("Enter");74 await page.waitForTimeout(1 * 1000);75});76When("Select a departure date", async () => {77 await page.click("input#fechaIdaIter");78 await page.waitForTimeout(2 * 1000);79 let fechaIda = await page.$$("div.calendar-container.hidden-xs td.number");80 await fechaIda[1].click();81 await page.waitForTimeout(2 * 1000);82});83When("Select a return date", async () => {84 await page.click("input#fechaRegresoIter");85 await page.waitForTimeout(2 * 1000);86 let fechaRegreso = await page.$$("div.calendar-container.left.hidden-xs td.number");87 await fechaRegreso[5].click();88 await page.waitForTimeout(2 * 1000);89});90When("Click on Search button", async () => {91 await page.click("input[title='Consultar']");92 await page.waitForTimeout(5 * 1000); // waitForNavigation no funciona en este paso. Al parecer la página tiene problemas de latencia93});94Then("I should be able to sort the flights from latest to earliest", async () => {95 let tabs = await browser.pages();96 let newTab = tabs.pop();97 await newTab.click("input[value='Ordenar por Hora de salida']");98 await newTab.waitForTimeout(1 * 1000);99});100Then('I see a list of available flights', async () => {101 await page.waitForSelector("div.step-label.passed.ng-star-inserted", {visible: true});102 let divStpOne = await page.$('div.step-label.passed.ng-star-inserted');103 let stpTitle = await page.evaluate(el => el.textContent, divStpOne);104 assert.strictEqual(stpTitle, " Selección de vuelos ");105});106AfterAll(async () => {107 await page.waitForTimeout(5 * 1000);108 await page.close();109 await browser.close();...

Full Screen

Full Screen

login.test.js

Source:login.test.js Github

copy

Full Screen

...25 await page.type('input[name="email"]', 'khabibullosaydullaev@gmail.com')26 await page.waitForSelector('input[name="password"]')27 await page.type('input[name="password"]', '111111')28 await page.click('div form button')29 await page.waitForTimeout(5000)30 await page.waitForSelector('#sideBarWrapper')31 const url = await page.url()32 await page.waitForTimeout(4000)33 assert(url !== 'http://localhost:3000/')34})35it('should find text "Loadboard"', async () => {36 const text = await page.evaluate(() => document.body.textContent)37 expect(text).toContain('Loadboard')38})39// test creating new search40test('test create new search', async () => {41 await page.waitForSelector('[href="#/newsearch"] button', { timeout: 10000 })42 await page.waitForTimeout(5000)43 await page.click('[href="#/newsearch"] button')44 await page.waitForTimeout(1500)45 await page.waitForSelector('#search_input', { timeout: 4000 })46 await page.click('#search_input')47 await page.waitForTimeout(1000)48 await page.keyboard.press('Enter')49 await page.click('input[placeholder="origin"]')50 await page.type('input[placeholder="origin"]', 'Sacramento, CA')51 const pDeadhead = await page.$('select[name="pickUpDeadhead"]')52 await pDeadhead.select('300')53 await page.click('input[placeholder="destination"]')54 await page.type('input[placeholder="destination"]', 'Newark, NJ')55 await page.waitForTimeout(1500)56 await page.keyboard.press('ArrowDown')57 await page.keyboard.press('Enter')58 const dDeadhead = await page.$('select[name="destinationDeadHead"]')59 await dDeadhead.select('300')60 await page.waitForTimeout(2000)61 await page.waitForSelector('select[name="equipment"]')62 await page.click('select[name="equipment"]')63 await page.keyboard.press('ArrowDown')64 await page.keyboard.press('Enter')65 await page.waitForTimeout(2000)66 await page.click('#newSearchContainer button')67 const url = await page.url()68 await page.waitForTimeout(2000)69 const text = await page.evaluate(() => document.body.textContent)70 expect(text).not.toContain(71 '1 active search only! Delete or stop a search in Searches'72 )73 assert(url !== 'http://localhost:3000/#/searches')74})75// delete the search76it('should delete search', async () => {77 await page.waitForTimeout(2000)78 await page.click('[href="#/searches"]')79 await page.waitForSelector(80 '#SearchCardWrapper > div > div.sc-crrsfI.DjvNf > button:nth-child(3)',81 { timeout: 10000 }82 )83 await page.click(84 '#SearchCardWrapper > div > div.sc-crrsfI.DjvNf > button:nth-child(3)'85 )86 await page.waitForTimeout(1500)87 await page.waitForSelector('button.sc-dlfnbm.gNCVe')88 await page.click('button.sc-dlfnbm.gNCVe')89 await page.waitForTimeout(3500)90 const text = await page.evaluate(() => document.body.textContent)91 expect(text).toContain('No active searches found. Start a New Search')92})93// add loadboard94it('should add loadboard', async () => {95 await page.waitForTimeout(2000)96 await page.click('[href="#/settings"]')97 await page.waitForSelector('button.gdtwpF')98 await page.click('button.gdtwpF')99 await page.waitForSelector('[name="loadboard"]')100 await page.click('[name="loadboard"]')101 await page.keyboard.press('ArrowDown')102 await page.keyboard.press('Enter')103 await page.type('input[name="email"]', 'khabibullosaydullaev@gmail.com')104 await page.type('input[name="password"]', '111111')105 await page.click('button.hsXACn')106 await page.waitForTimeout(2000)107 const text = await page.evaluate(() => document.body.textContent)108 expect(text).not.toContain('No Loadboards Yet')109})110// delete loadboard111it('should delete loadboard', async () => {112 await page.waitForTimeout(2000)113 await page.waitForSelector('#buttonsWrapper > button.sc-dlfnbm.gNCVe')114 await page.click('#buttonsWrapper > button.sc-dlfnbm.gNCVe')115 await page.waitForTimeout(1000)116 await page.waitForSelector(117 '#DeleteModalContent > div:nth-child(2) > button.sc-dlfnbm.gNCVe'118 )119 await page.click(120 '#DeleteModalContent > div:nth-child(2) > button.sc-dlfnbm.gNCVe'121 )122 await page.waitForTimeout(2000)123 const text = await page.evaluate(() => document.body.textContent)124 expect(text).toContain('No Loadboards Yet')...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForTimeout(1000);7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 await page.waitForTimeout(1000);16 await page.screenshot({ path: `example.png` });17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 const page = await context.newPage();24 await page.waitForTimeout(1000);25 await page.screenshot({ path: `example.png` });26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 await page.waitForTimeout(1000);34 await page.screenshot({ path: `example.png` });35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 await page.waitForTimeout(1000);43 await page.screenshot({ path: `example.png` });44 await browser.close();45})();46const { chromium } = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForTimeout(5000);7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForTimeout(1000);7 await page.screenshot({ path: 'google.png' });8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 await page.waitForTimeout(1000);16 await page.screenshot({ path: 'google.png' });17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 const page = await context.newPage();24 await page.waitForTimeout(1000);25 await page.screenshot({ path: 'google.png' });26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 await page.waitForTimeout(1000);34 await page.screenshot({ path: 'google.png' });35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 await page.waitForTimeout(1000);43 await page.screenshot({ path: 'google.png' });44 await browser.close();45})();46const { chromium } = require('playwright');47(async () => {48 const browser = await chromium.launch();49 const context = await browser.newContext();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForTimeout(5000);7 await browser.close();8})();9Example 1: Using waitForTimeout() method to wait for 5 seconds10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch({ headless: false });13 const context = await browser.newContext();14 const page = await context.newPage();15 await page.waitForTimeout(5000);16 await page.click('input[name="q"]');17 await page.type('input[name="q"]', 'Hello World');18 await page.click('input[name="btnK"]');19 await page.waitForTimeout(5000);20 await browser.close();21})();22Example 2: Using waitForTimeout() method to wait for 5 seconds before checking for an element23const { chromium } = require('playwright');24(async () => {25 const browser = await chromium.launch({ headless: false });26 const context = await browser.newContext();27 const page = await context.newPage();28 await page.waitForTimeout(5000);29 const element = page.locator('input[name="btn

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForTimeout(2000);7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 await page.waitForTimeout(2000);16 await page.screenshot({ path: 'example.png' });17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 const page = await context.newPage();24 await page.waitForTimeout(2000);25 await page.screenshot({ path: 'example.png' });26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 await page.waitForTimeout(2000);34 await page.screenshot({ path: 'example.png' });35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 await page.waitForTimeout(2000);43 await page.screenshot({ path: 'example.png' });44 await browser.close();45})();46const { chromium } = require('playwright');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForTimeout(5000);7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 await page.waitForTimeout(5000);16 await page.screenshot({ path: 'example.png' });17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 const page = await context.newPage();24 await page.waitForTimeout(5000);25 await page.screenshot({ path: 'example.png' });26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 await page.waitForTimeout(5000);34 await page.screenshot({ path: 'example.png' });35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 await page.waitForTimeout(5000);43 await page.screenshot({ path: 'example.png' });44 await browser.close();45})();46const { chromium } = require('playwright');47(async () => {48 const browser = await chromium.launch();49 const context = await browser.newContext();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { chromium } from 'playwright';2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForTimeout(10000);7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium} = require('playwright');2const browser = await chromium.launch();3const context = await browser.newContext();4const page = await context.newPage();5await page.waitForTimeout(3000);6await browser.close();7const {chromium} = require('playwright');8const browser = await chromium.launch();9const context = await browser.newContext();10const page = await context.newPage();11await page.waitForTimeout(3000);12await browser.close();13const {chromium} = require('playwright');14const browser = await chromium.launch();15const context = await browser.newContext();16const page = await context.newPage();17await page.waitForTimeout(3000);18await browser.close();19const {chromium} = require('playwright');20const browser = await chromium.launch();21const context = await browser.newContext();22const page = await context.newPage();23await page.waitForTimeout(3000);24await browser.close();25const {chromium} = require('playwright');26const browser = await chromium.launch();27const context = await browser.newContext();28const page = await context.newPage();29await page.waitForTimeout(3000);30await browser.close();31const {chromium} = require('playwright');32const browser = await chromium.launch();33const context = await browser.newContext();34const page = await context.newPage();35await page.waitForTimeout(3000);36await browser.close();37const {chromium} = require('playwright');38const browser = await chromium.launch();39const context = await browser.newContext();40const page = await context.newPage();41await page.waitForTimeout(3000);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { waitForTimeout } = require('playwright/lib/helper');2await waitForTimeout(1000);3import { test, expect } from '@playwright/test';4test('example', async ({ page }) => {5 await page.waitForTimeout(1000);6});7test.describe('', () => {8 test('example', async ({ page }) => {9 await page.waitForTimeout(1000);10 });11});12test.use({ storageState: 'state.json' });13test('example', async ({ page }) => {14 await page.waitForTimeout(1000);15});16test.use({ video: 'on' });17test('example', async ({ page }) => {18 await page.waitForTimeout(1000);19});20test.use({ trace: 'on' });21test('example', async ({ page }) => {22 await page.waitForTimeout(1000);23});24test('example', async ({ page }) => {25 await page.waitForTimeout(1000);26});27test.use({ ignoreHTTPSErrors: true });28test('example', async ({ page }) => {29 await page.waitForTimeout(1000);30});31test.use({ acceptDownloads: true });32test('example', async ({ page }) => {33 await page.waitForTimeout(1000);34});35test.use({ viewport: { width: 500, height: 500 } });36test('example', async ({ page }) => {37 await page.waitForTimeout(1000);38});39test.use({ userAgent: 'userAgent' });40test('example', async ({ page }) => {41 await page.waitForTimeout(1000);42});43test.use({ deviceScaleFactor: 2 });44test('example', async ({ page }) => {45 await page.waitForTimeout(

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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