Best JavaScript code snippet using wpt
r-d.spec.js
Source:r-d.spec.js
1const httpServer = Cypress.env('TESTSITE');2describe('It recognises and downloads a', () => {3 beforeEach(() => {4 cy.visit(httpServer);5 cy.get('#nav-import-tab').click()6cy.wait(500);7 })8 // JPG Recognize -> Download 9 10 it('text file from a jpg with no imported ocr data', () => {11 cy.get('#uploader').selectFile(['cypress/fixtures/multi_jpg/aurelia.jpg'])12 cy.wait(3000)13 cy.get('#pageCount').should('have.text', '1')14 15 16 cy.get('#nav-recognize-tab').click()17cy.wait(500)18 cy.get('#recognizeAll').click()19 cy.wait(10000)20 cy.get('#nav-download-tab').click()21cy.wait(500)22 cy.get('#downloadFormat').click()23 cy.get('#formatLabelOptionText').click()24 cy.get('#download').click()25 cy.verifyDownload('aurelia.txt')26 })27 it('text file from 4 jpgs with no imported ocr data', () => {28 cy.get('#uploader').selectFile([29 'cypress/fixtures/multi_jpg/henreys_grave.jpg', 30 'cypress/fixtures/multi_jpg/aurelia.jpg',31 'cypress/fixtures/multi_jpg/the_past.jpg', 32 'cypress/fixtures/snow_drops.jpg'33 ])34 cy.wait(10000)35 cy.get('#pageCount').should('have.text', '4')36 37 38 cy.get('#nav-recognize-tab').click()39cy.wait(500)40 cy.get('#recognizeAll').click()41 cy.wait(30000)42 cy.get('#nav-download-tab').click()43cy.wait(500)44 cy.get('#downloadFormat').click()45 cy.get('#formatLabelOptionText').click()46 cy.get('#download').click()47 cy.verifyDownload('henreys_grave.txt')48 })49 it('pdf file from a jpg with no imported ocr data, NATIVE', () => {50 cy.get('#uploader').selectFile(['cypress/fixtures/multi_jpg/the_past.jpg'])51 cy.wait(3000)52 cy.get('#pageCount').should('have.text', '1')53 54 cy.get('#nav-recognize-tab').click()55cy.wait(500)56 cy.get('#recognizeAll').click()57 cy.wait(10000)58 cy.get('#nav-view-tab').click()59cy.wait(500)60 cy.get('#colorMode').select('Native')61 cy.get('#nav-download-tab').click()62cy.wait(500)63 cy.get('#downloadFormat').click()64 cy.get('#formatLabelOptionPDF').click()65 cy.get('#download').click()66 cy.verifyDownload('the_past', {contains: true})67 })68 it('pdf file from a jpg with no imported ocr data, BINARY', () => {69 cy.get('#uploader').selectFile(['cypress/fixtures/multi_jpg/the_past.jpg'])70 cy.wait(3000)71 cy.get('#pageCount').should('have.text', '1')72 73 cy.get('#nav-recognize-tab').click()74cy.wait(500)75 cy.get('#recognizeAll').click()76 cy.wait(10000)77 cy.get('#nav-view-tab').click()78cy.wait(500)79 cy.get('#colorMode').select('Binary')80 cy.get('#nav-download-tab').click()81cy.wait(500)82 cy.get('#downloadFormat').click()83 cy.get('#formatLabelOptionPDF').click()84 cy.get('#download').click()85 cy.verifyDownload('the_past', {contains: true})86 })87 it('pdf file from 4 jpgs with no imported ocr data', () => {88 cy.get('#uploader').selectFile([89 'cypress/fixtures/multi_jpg/aurelia.jpg', 90 'cypress/fixtures/multi_jpg/henreys_grave.jpg',91 'cypress/fixtures/multi_jpg/the_past.jpg', 92 'cypress/fixtures/snow_drops.jpg'93 ])94 cy.wait(10000)95 cy.get('#pageCount').should('have.text', '4')96 cy.get('#nav-recognize-tab').click()97cy.wait(500)98 cy.get('#recognizeAll').click()99 cy.wait(30000)100 cy.get('#nav-download-tab').click()101cy.wait(500)102 cy.get('#downloadFormat').click()103 cy.get('#formatLabelOptionPDF').click()104 cy.get('#download').click()105 cy.verifyDownload('aurelia.pdf')106 })107 it('hocr file from a jpg with no imported ocr data', () => {108 cy.get('#uploader').selectFile(['cypress/fixtures/snow_drops.jpg'])109 cy.wait(3000)110 cy.get('#pageCount').should('have.text', '1')111 cy.get('#nav-recognize-tab').click()112cy.wait(500)113 cy.get('#recognizeAll').click()114 cy.wait(10000)115 cy.get('#nav-download-tab').click()116cy.wait(500)117 cy.get('#downloadFormat').click()118 cy.get('#formatLabelOptionHOCR').click()119 cy.get('#download').click()120 cy.verifyDownload('snow_drops.hocr')121 })122 it('text file from 4 jpgs with no imported ocr data', () => {123 cy.get('#uploader').selectFile([124 'cypress/fixtures/multi_jpg/the_past.jpg', 125 'cypress/fixtures/multi_jpg/henreys_grave.jpg',126 'cypress/fixtures/multi_jpg/aurelia.jpg', 127 'cypress/fixtures/snow_drops.jpg',128 ])129 cy.wait(10000)130 cy.get('#pageCount').should('have.text', '4')131 cy.get('#nav-recognize-tab').click()132cy.wait(500)133 cy.get('#recognizeAll').click()134 cy.wait(30000)135 cy.get('#nav-download-tab').click()136cy.wait(500)137 cy.get('#downloadFormat').click()138 cy.get('#formatLabelOptionHOCR').click() 139 cy.get('#download').click()140 cy.verifyDownload('the_past.hocr')141 })142 143 // PDF Recognize -> Download 144 it('text file from a pdf with no imported ocr data', () => {145 cy.get('#uploader').selectFile(['cypress/fixtures/multi_pdf_nd/aurelia.pdf'])146 cy.wait(3000)147 cy.get('#pageCount').should('have.text', '1')148 149 150 cy.get('#nav-recognize-tab').click()151cy.wait(500)152 cy.get('#recognizeAll').click()153 cy.wait(11000)154 cy.get('#nav-download-tab').click()155cy.wait(500)156 cy.get('#downloadFormat').click()157 cy.get('#formatLabelOptionText').click()158 cy.get('#download').click()159 cy.verifyDownload('aurelia.txt')160 })161/*162 it('recognises and downloads a text file from 5 pdfs with no imported ocr data', () => {163 cy.get('#uploader').selectFile([164 'cypress/fixtures/multi_pdf_nd/snow_drops.pdf', 165 'cypress/fixtures/multi_pdf_nd/aurelia.pdf',166 'cypress/fixtures/multi_pdf_nd/henreys_grave.pdf', 167 'cypress/fixtures/multi_pdf_nd/pretty_faces.pdf',168 'cypress/fixtures/multi_pdf_nd/the_past.pdf'169 ])170 cy.wait(10000)171 cy.get('#pageCount').should('have.text', '5')172 173 174 cy.get('#nav-recognize-tab').click()175cy.wait(500)176 cy.get('#recognizeAll').click()177 cy.wait(10000)178 cy.get('#nav-download-tab').click()179cy.wait(500)180 cy.get('#downloadFormat').click()181 cy.get('#formatLabelOptionText').click()182 cy.get('#download').click()183 cy.verifyDownload('snow_drops.txt')184 })185*/186it('r & d pdf from pdf, no imported ocr data, COLOR', () => {187 cy.get('#uploader').selectFile(['cypress/fixtures/multi_pdf_nd/the_past.pdf'])188 cy.wait(3000)189 cy.get('#pageCount').should('have.text', '1')190 191 cy.get('#nav-recognize-tab').click()192cy.wait(500)193 cy.get('#recognizeAll').click()194 cy.wait(12000)195 cy.get('#nav-view-tab').click()196cy.wait(500)197 cy.get('#colorMode').select('Color')198 199 cy.get('#nav-download-tab').click()200cy.wait(500)201 cy.get('#downloadFormat').click()202 cy.get('#formatLabelOptionPDF').click()203 cy.get('#download').click()204 cy.verifyDownload('the_past.pdf')205})206it('r & d pdf from pdf, no imported ocr data, BINARY', () => {207 cy.get('#uploader').selectFile(['cypress/fixtures/multi_pdf_nd/henreys_grave.pdf'])208 cy.wait(3000)209 cy.get('#pageCount').should('have.text', '1')210 211 cy.get('#nav-recognize-tab').click()212cy.wait(500)213 cy.get('#recognizeAll').click()214 cy.wait(12000)215 cy.get('#nav-view-tab').click()216cy.wait(500)217 cy.get('#colorMode').select('Binary')218 219 cy.get('#nav-download-tab').click()220cy.wait(500)221 cy.get('#downloadFormat').click()222 cy.get('#formatLabelOptionPDF').click()223 cy.get('#download').click()224 cy.verifyDownload('henreys_grave.pdf')225})226/*227 it('recognises and downloads a pdf file from 5 pdfs with no imported ocr data', () => {228 cy.get('#uploader').selectFile([229 'cypress/fixtures/multi_pdf_nd/the_past.pdf', 230 'cypress/fixtures/multi_pdf_nd/aurelia.pdf',231 'cypress/fixtures/multi_pdf_nd/henreys_grave.pdf', 232 'cypress/fixtures/multi_pdf_nd/pretty_faces.pdf',233 'cypress/fixtures/multi_pdf_nd/snow_drops.pdf'234 ])235 cy.wait(10000)236 cy.get('#pageCount').should('have.text', '5')237 cy.get('#nav-recognize-tab').click()238cy.wait(500)239 cy.get('#recognizeAll').click()240 cy.wait(10000)241 cy.get('#nav-download-tab').click()242cy.wait(500)243 cy.get('#downloadFormat').click()244 cy.get('#formatLabelOptionPDF').click()245 cy.get('#download').click()246 cy.verifyDownload('the_past.pdf')247 })248*/249 it('hocr file from a pdf with no imported ocr data', () => {250 cy.get('#uploader').selectFile(['cypress/fixtures/multi_pdf_nd/pretty_faces.pdf'])251 cy.wait(3000)252 cy.get('#pageCount').should('have.text', '1')253 cy.get('#nav-recognize-tab').click()254cy.wait(500)255 cy.get('#recognizeAll').click()256 cy.wait(10000)257 cy.get('#nav-download-tab').click()258cy.wait(500)259 cy.get('#downloadFormat').click()260 cy.get('#formatLabelOptionHOCR').click()261 cy.get('#download').click()262 cy.verifyDownload('pretty_faces.hocr')263 })264/*265 it('recognises and downloads a text file from 5 pdfs with no imported ocr data', () => {266 cy.get('#uploader').selectFile([267 'cypress/fixtures/multi_pdf_nd/pretty_faces.pdf', 268 'cypress/fixtures/multi_pdf_nd/aurelia.pdf',269 'cypress/fixtures/multi_pdf_nd/henreys_grave.pdf', 270 'cypress/fixtures/multi_pdf_nd/snow_drops.pdf',271 'cypress/fixtures/multi_pdf_nd/the_past.pdf'272 ])273 cy.wait(10000)274 cy.get('#pageCount').should('have.text', '5')275 cy.get('#nav-recognize-tab').click()276cy.wait(500)277 cy.get('#recognizeAll').click()278 cy.wait(10000)279 cy.get('#nav-download-tab').click()280cy.wait(500)281 cy.get('#downloadFormat').click()282 cy.get('#formatLabelOptionHOCR').click() 283 cy.get('#download').click()284 cy.verifyDownload('pretty_faces.hocr')285 })286*/287 //PNG Recognize -> Download288 it('text file from a png with no imported ocr data', () => {289 cy.get('#uploader').selectFile(['cypress/fixtures/multi_png/aurelia.png'])290 cy.wait(3000)291 cy.get('#pageCount').should('have.text', '1')292 293 294 cy.get('#nav-recognize-tab').click()295cy.wait(500)296 cy.get('#recognizeAll').click()297 cy.wait(15000)298 cy.get('#nav-download-tab').click()299cy.wait(500)300 cy.get('#downloadFormat').click()301 cy.get('#formatLabelOptionText').click()302 cy.get('#download').click()303 cy.verifyDownload('aurelia.txt')304 })305 it('text file from 4 pngs with no imported ocr data', () => {306 cy.get('#uploader').selectFile([307 'cypress/fixtures/multi_png/henreys_grave.png', 308 'cypress/fixtures/multi_png/aurelia.png',309 'cypress/fixtures/multi_png/the_past.png', 310 'cypress/fixtures/pretty_faces.png'311 ])312 cy.wait(10000)313 cy.get('#pageCount').should('have.text', '4')314 315 316 cy.get('#nav-recognize-tab').click()317cy.wait(500)318 cy.get('#recognizeAll').click()319 cy.wait(35000)320 cy.get('#nav-download-tab').click()321cy.wait(500)322 cy.get('#downloadFormat').click()323 cy.get('#formatLabelOptionText').click()324 cy.get('#download').click()325 cy.verifyDownload('henreys_grave.txt')326 })327 it('pdf file from a png with no imported ocr data, NATIVE', () => {328 cy.get('#uploader').selectFile(['cypress/fixtures/multi_png/the_past.png'])329 cy.wait(3000)330 cy.get('#pageCount').should('have.text', '1')331 332 cy.get('#nav-recognize-tab').click()333cy.wait(500)334 cy.get('#recognizeAll').click()335 cy.wait(15000)336 cy.get('#nav-view-tab').click()337cy.wait(500)338 cy.get('#colorMode').select('Native')339 340 cy.get('#nav-download-tab').click()341cy.wait(500)342 cy.get('#downloadFormat').click()343 cy.get('#formatLabelOptionPDF').click()344 cy.get('#download').click()345 cy.verifyDownload('the_past.pdf')346 })347 it('pdf file from a png with no imported ocr data, BINARY', () => {348 cy.get('#uploader').selectFile(['cypress/fixtures/multi_png/the_past.png'])349 cy.wait(3000)350 cy.get('#pageCount').should('have.text', '1')351 352 cy.get('#nav-recognize-tab').click()353cy.wait(500)354 cy.get('#recognizeAll').click()355 cy.wait(15000)356 cy.get('#nav-view-tab').click()357cy.wait(500)358 cy.get('#colorMode').select('Binary')359 360 cy.get('#nav-download-tab').click()361cy.wait(500)362 cy.get('#downloadFormat').click()363 cy.get('#formatLabelOptionPDF').click()364 cy.get('#download').click()365 cy.verifyDownload('the_past.pdf')366 })367 it('pdf file from 4 pngs with no imported ocr data', () => {368 cy.get('#uploader').selectFile([369 'cypress/fixtures/multi_png/aurelia.png', 370 'cypress/fixtures/multi_png/henreys_grave.png',371 'cypress/fixtures/multi_png/the_past.png', 372 'cypress/fixtures/pretty_faces.png'373 ])374 cy.wait(10000)375 cy.get('#pageCount').should('have.text', '4')376 cy.get('#nav-recognize-tab').click()377cy.wait(500)378 cy.get('#recognizeAll').click()379 cy.wait(35000)380 cy.get('#nav-download-tab').click()381cy.wait(500)382 cy.get('#downloadFormat').click()383 cy.get('#formatLabelOptionPDF').click()384 cy.get('#download').click()385 cy.verifyDownload('aurelia.pdf')386 })387 it('hocr file from a png with no imported ocr data', () => {388 cy.get('#uploader').selectFile(['cypress/fixtures/pretty_faces.png'])389 cy.wait(3000)390 cy.get('#pageCount').should('have.text', '1')391 cy.get('#nav-recognize-tab').click()392cy.wait(500)393 cy.get('#recognizeAll').click()394 cy.wait(15000)395 cy.get('#nav-download-tab').click()396cy.wait(500)397 cy.get('#downloadFormat').click()398 cy.get('#formatLabelOptionHOCR').click()399 cy.get('#download').click()400 cy.verifyDownload('pretty_faces.hocr')401 })402 it('text file from 4 pngs with no imported ocr data', () => {403 cy.get('#uploader').selectFile([404 'cypress/fixtures/multi_png/the_past.png', 405 'cypress/fixtures/multi_png/henreys_grave.png',406 'cypress/fixtures/multi_png/aurelia.png', 407 'cypress/fixtures/pretty_faces.png',408 ])409 cy.wait(10000)410 cy.get('#pageCount').should('have.text', '4')411 cy.get('#nav-recognize-tab').click()412cy.wait(500)413 cy.get('#recognizeAll').click()414 cy.wait(35000)415 cy.get('#nav-download-tab').click()416cy.wait(500)417 cy.get('#downloadFormat').click()418 cy.get('#formatLabelOptionHOCR').click() 419 cy.get('#download').click()420 cy.verifyDownload('the_past.hocr')421 })...
iframe_sandbox_download_helper.js
Source:iframe_sandbox_download_helper.js
...3}4function DownloadVerifyDelay() {5 return 1000;6}7function VerifyDownload(test_obj, token, timeout, expect_download) {8 var verify_token = test_obj.step_func(function () {9 var xhr = new XMLHttpRequest();10 xhr.open('GET', 'support/download_stash.py?verify-token&token=' + token);11 xhr.onload = test_obj.step_func(function(e) {12 if (expect_download) {13 if (xhr.response != "TOKEN_SET") {14 // Always retry, and rely on the test timeout to conclude that15 // download didn't happen and to fail the test.16 test_obj.step_timeout(verify_token, DownloadVerifyDelay());17 return;18 }19 } else {20 assert_equals(xhr.response, "TOKEN_NOT_SET", "Expect no download to happen, but got one.");21 }22 test_obj.done();23 });24 xhr.send();25 });26 test_obj.step_timeout(verify_token, timeout);27}28function AssertDownloadSuccess(test_obj, token, timeout) {29 VerifyDownload(test_obj, token, timeout, true);30}31function AssertDownloadFailure(test_obj, token, timeout) {32 VerifyDownload(test_obj, token, timeout, false);...
export.ts
Source:export.ts
1import 'cypress-file-upload';2import {3 create4Translations,4 createExportableProject,5 exportSelectFormat,6 exportToggleLanguage,7 visitExport,8} from '../../common/export';9describe('Projects Basics', () => {10 beforeEach(() => {11 createExportableProject().then((p) => {12 create4Translations(p.id);13 visitExport(p.id);14 cy.gcy('export-submit-button').should('be.visible');15 });16 });17 it('exports all to zip by default', () => {18 cy.gcy('export-submit-button').click();19 cy.verifyDownload('Test project.zip');20 });21 it('exports one language to json', () => {22 exportToggleLanguage('Äesky');23 cy.gcy('export-submit-button').click();24 cy.verifyDownload('en.json');25 });26 it('exports one language to xliff', () => {27 exportToggleLanguage('Äesky');28 exportSelectFormat('XLIFF');29 cy.gcy('export-submit-button').click();30 cy.verifyDownload('en.xliff');31 });...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (!err) {4 console.log(data);5 }6});7var wpt = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org');9wpt.getLocations(function(err, data) {10 if (!err) {11 console.log(data);12 }13});14var wpt = require('webpagetest');15var wpt = new WebPageTest('www.webpagetest.org');16wpt.getLocation('Dulles:Chrome', function(err, data) {17 if (!err) {18 console.log(data);19 }20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org');23wpt.getBrowsers(function(err, data) {24 if (!err) {25 console.log(data);26 }27});28var wpt = require('webpagetest');29var wpt = new WebPageTest('www.webpagetest.org');30wpt.getBrowser('Chrome', function(err, data) {31 if (!err) {32 console.log(data);
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!!