Best JavaScript code snippet using taiko
securerandom.js
Source:securerandom.js
1/*!2* Random number generator with ArcFour PRNG3* 4* NOTE: For best results, put code like5* <body onclick='SecureRandom.seedTime();' onkeypress='SecureRandom.seedTime();'>6* in your main HTML document.7* 8* Copyright Tom Wu, bitaddress.org BSD License.9* http://www-cs-students.stanford.edu/~tjw/jsbn/LICENSE10*/11(function () {12 // Constructor function of Global SecureRandom object13 var sr = window.SecureRandom = function () { };14 // Properties15 sr.state;16 sr.pool;17 sr.pptr;18 sr.poolCopyOnInit;19 // Pool size must be a multiple of 4 and greater than 32.20 // An array of bytes the size of the pool will be passed to init()21 sr.poolSize = 256;22 // --- object methods ---23 // public method24 // ba: byte array25 sr.prototype.nextBytes = function (ba) {26 var i;27 if (window.crypto && window.crypto.getRandomValues && window.Uint8Array) {28 try {29 var rvBytes = new Uint8Array(ba.length);30 window.crypto.getRandomValues(rvBytes);31 for (i = 0; i < ba.length; ++i)32 ba[i] = sr.getByte() ^ rvBytes[i];33 return;34 } catch (e) {35 alert(e);36 }37 }38 for (i = 0; i < ba.length; ++i) ba[i] = sr.getByte();39 };40 // --- static methods ---41 // Mix in the current time (w/milliseconds) into the pool42 // NOTE: this method should be called from body click/keypress event handlers to increase entropy43 sr.seedTime = function () {44 sr.seedInt(new Date().getTime());45 }46 sr.getByte = function () {47 if (sr.state == null) {48 sr.seedTime();49 sr.state = sr.ArcFour(); // Plug in your RNG constructor here50 sr.state.init(sr.pool);51 sr.poolCopyOnInit = [];52 for (sr.pptr = 0; sr.pptr < sr.pool.length; ++sr.pptr)53 sr.poolCopyOnInit[sr.pptr] = sr.pool[sr.pptr];54 sr.pptr = 0;55 }56 // TODO: allow reseeding after first request57 return sr.state.next();58 }59 // Mix in a 32-bit integer into the pool60 sr.seedInt = function (x) {61 sr.seedInt8(x);62 sr.seedInt8((x >> 8));63 sr.seedInt8((x >> 16));64 sr.seedInt8((x >> 24));65 }66 // Mix in a 16-bit integer into the pool67 sr.seedInt16 = function (x) {68 sr.seedInt8(x);69 sr.seedInt8((x >> 8));70 }71 // Mix in a 8-bit integer into the pool72 sr.seedInt8 = function (x) {73 sr.pool[sr.pptr++] ^= x & 255;74 if (sr.pptr >= sr.poolSize) sr.pptr -= sr.poolSize;75 }76 // Arcfour is a PRNG77 sr.ArcFour = function () {78 function Arcfour() {79 this.i = 0;80 this.j = 0;81 this.S = new Array();82 }83 // Initialize arcfour context from key, an array of ints, each from [0..255]84 function ARC4init(key) {85 var i, j, t;86 for (i = 0; i < 256; ++i)87 this.S[i] = i;88 j = 0;89 for (i = 0; i < 256; ++i) {90 j = (j + this.S[i] + key[i % key.length]) & 255;91 t = this.S[i];92 this.S[i] = this.S[j];93 this.S[j] = t;94 }95 this.i = 0;96 this.j = 0;97 }98 function ARC4next() {99 var t;100 this.i = (this.i + 1) & 255;101 this.j = (this.j + this.S[this.i]) & 255;102 t = this.S[this.i];103 this.S[this.i] = this.S[this.j];104 this.S[this.j] = t;105 return this.S[(t + this.S[this.i]) & 255];106 }107 Arcfour.prototype.init = ARC4init;108 Arcfour.prototype.next = ARC4next;109 return new Arcfour();110 };111 // Initialize the pool with junk if needed.112 if (sr.pool == null) {113 sr.pool = new Array();114 sr.pptr = 0;115 var t;116 if (window.crypto && window.crypto.getRandomValues && window.Uint8Array) {117 try {118 // Use webcrypto if available119 var ua = new Uint8Array(sr.poolSize);120 window.crypto.getRandomValues(ua);121 for (t = 0; t < sr.poolSize; ++t)122 sr.pool[sr.pptr++] = ua[t];123 } catch (e) { alert(e); }124 }125 while (sr.pptr < sr.poolSize) { // extract some randomness from Math.random()126 t = Math.floor(65536 * Math.random());127 sr.pool[sr.pptr++] = t >>> 8;128 sr.pool[sr.pptr++] = t & 255;129 }130 sr.pptr = Math.floor(sr.poolSize * Math.random());131 sr.seedTime();132 // entropy133 var entropyStr = "";134 // screen size and color depth: ~4.8 to ~5.4 bits135 entropyStr += (window.screen.height * window.screen.width * window.screen.colorDepth);136 entropyStr += (window.screen.availHeight * window.screen.availWidth * window.screen.pixelDepth);137 // time zone offset: ~4 bits138 var dateObj = new Date();139 var timeZoneOffset = dateObj.getTimezoneOffset();140 entropyStr += timeZoneOffset;141 // user agent: ~8.3 to ~11.6 bits142 entropyStr += navigator.userAgent;143 // browser plugin details: ~16.2 to ~21.8 bits144 var pluginsStr = "";145 for (var i = 0; i < navigator.plugins.length; i++) {146 pluginsStr += navigator.plugins[i].name + " " + navigator.plugins[i].filename + " " + navigator.plugins[i].description + " " + navigator.plugins[i].version + ", ";147 }148 var mimeTypesStr = "";149 for (var i = 0; i < navigator.mimeTypes.length; i++) {150 mimeTypesStr += navigator.mimeTypes[i].description + " " + navigator.mimeTypes[i].type + " " + navigator.mimeTypes[i].suffixes + ", ";151 }152 entropyStr += pluginsStr + mimeTypesStr;153 // cookies and storage: 1 bit154 entropyStr += navigator.cookieEnabled + typeof (sessionStorage) + typeof (localStorage);155 // language: ~7 bit156 entropyStr += navigator.language;157 // history: ~2 bit158 entropyStr += window.history.length;159 // location160 entropyStr += window.location;161 var entropyBytes = Crypto.SHA256(entropyStr, { asBytes: true });162 for (var i = 0 ; i < entropyBytes.length ; i++) {163 sr.seedInt8(entropyBytes[i]);164 }165 }...
custom.js
Source:custom.js
1//Auto Close Responsive Navbar on Click2 function close_toggle() {3 if ($(window).width() <= 768) {4 $('.navbar-collapse a').on('click', function () {5 $('.navbar-collapse').collapse('hide');6 });7 }8 else {9 $('.navbar .navbar-default a').off('click');10 }11 }12 close_toggle();13 $(window).resize(close_toggle);14 //hero text fade flexslider15 $(window).load(function () {16 $('.flexslider').flexslider({17 controlNav: false,18 directionNav: false,19 slideshowSpeed: 400020 });21 });22 //home slider23 $(window).load(function () {24 $('.main-slider').flexslider({25 controlNav: false,26 directionNav: true,27 slideshowSpeed: 4000,28 prevText: "<i class='ion-chevron-left'></i>",29 nextText: "<i class='ion-chevron-right'></i>"30 });31 });32 //home slider33 (function(){34 var config = {35 viewFactor : 0.15,36 duration : 800,37 distance : "0px",38 scale : 0.839 };40 window.sr = ScrollReveal( config );41 if (sr.isSupported()) {42 document.documentElement.classList.add('sr');43 }44 })();45 //home counter46 $('.count').each(function () {47 $(this).prop('Counter',0).animate({48 Counter: $(this).text()49 }, {50 duration: 4000,51 easing: 'swing',52 step: function (now) {53 $(this).text(Math.ceil(now));54 }55 });56});57 //home scrool58var $ = $.noConflict();59$(document).ready(function () {60 "use strict";61 if ($('.scrollReveal').length && !$('html.ie9').length) {62 $('.scrollReveal').parent().css('overflow', 'hidden');63 window.sr = ScrollReveal({64 reset: true,65 distance: '32px',66 mobile: true,67 duration: 850,68 scale: 1,69 viewFactor: 0.3,70 easing: 'ease-in-out'71 });72 sr.reveal('.sr-top', {origin: 'top'});73 sr.reveal('.sr-bottom', {origin: 'bottom'});74 sr.reveal('.sr-left', {origin: 'left'});75 sr.reveal('.sr-long-left', {origin: 'left', distance: '70px', duration: 1000});76 sr.reveal('.sr-right', {origin: 'right'});77 sr.reveal('.sr-scaleUp', {scale: '0.8'});78 sr.reveal('.sr-scaleDown', {scale: '1.15'});79 sr.reveal('.sr-delay-1', {delay: 200});80 sr.reveal('.sr-delay-2', {delay: 400});81 sr.reveal('.sr-delay-3', {delay: 600});82 sr.reveal('.sr-delay-4', {delay: 800});83 sr.reveal('.sr-delay-5', {delay: 1000});84 sr.reveal('.sr-delay-6', {delay: 1200});85 sr.reveal('.sr-delay-7', {delay: 1400});86 sr.reveal('.sr-delay-8', {delay: 1600});87 sr.reveal('.sr-ease-in-out-quad', {easing: 'cubic-bezier(0.455, 0.030, 0.515, 0.955)'});88 sr.reveal('.sr-ease-in-out-cubic', {easing: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)'});89 sr.reveal('.sr-ease-in-out-quart', {easing: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)'});90 sr.reveal('.sr-ease-in-out-quint', {easing: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)'});91 sr.reveal('.sr-ease-in-out-sine', {easing: 'cubic-bezier(0.445, 0.050, 0.550, 0.950)'});92 sr.reveal('.sr-ease-in-out-expo', {easing: 'cubic-bezier(1.000, 0.000, 0.000, 1.000)'});93 sr.reveal('.sr-ease-in-out-circ', {easing: 'cubic-bezier(0.785, 0.135, 0.150, 0.860)'});94 sr.reveal('.sr-ease-in-out-back', {easing: 'cubic-bezier(0.680, -0.550, 0.265, 1.550)'});95 }96});97// Wait for window load98 $(window).load(function() {99 // Animate loader off screen100 $(".se-pre-con").fadeOut("slow");;101 });102// js loader103/* -------------------------------------------------------- */104//Sliders owlCarousel - start105/* -------------------------------------------------------- */106 $(document).ready(function () {107 $("#owl-clients").owlCarousel({108 navigation: true,109 items: 6,110 itemsDesktop: [1200, 6],111 itemsTablet: [800, 3],112 itemsMobile: [700, 2],113 autoPlay : true,114 pagination : false,115 paginationNumbers: false,116 });117 118 119 }); 120/* -------------------------------------------------------- */121// Owl Carousels - end122/* -------------------------------------------------------- */123/* -------------------------------------------------------- */124// Scroll To Top - start125/* -------------------------------------------------------- */126 $(window).scroll(function () {127 if ($(this)128 .scrollTop() > 100) {129 $('.scrollTop')130 .fadeIn();131 } else {132 $('.scrollTop')133 .fadeOut();134 }135 });136 $('.scrollTop').on('click', function () {137 $('html, body').animate({138 scrollTop: 0139 }, 1000);140 return false;141 });142/* -------------------------------------------------------- */143// Scroll To Top - end...
Using AI Code Generation
1const { openBrowser, goto, click, closeBrowser, text } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await click("Gmail");6 await click("Sign in");7 await click("Create account");8 await write("test", into(textBox({placeholder:"First name"})));9 await write("test", into(textBox({placeholder:"Last name"})));10 await write("test", into(textBox({placeholder:"Username"})));11 await write("test", into(textBox({placeholder:"Password"})));12 await click("Next");13 await click("I agree");14 await click("Next");15 await click("Skip for n
Using AI Code Generation
1const assert = require("assert");2const { openBrowser, closeBrowser, goto, text, click, textBox, toRightOf, button, link, $, toLeftOf } = require('taiko');3const headless = process.env.headless_chrome.toLowerCase() === 'true';4const { setDefaultTimeout, setNavigationOptions } = require('taiko');5setDefaultTimeout(60000);6const assert = require("assert");7const { openBrowser, closeBrowser, goto, text, click, textBox, toRightOf, button, link, $, toLeftOf } = require('taiko');8const headless = process.env.headless_chrome.toLowerCase() === 'true';9const { setDefaultTimeout, setNavigationOptions } = require('taiko');10setDefaultTimeout(60000);11const assert = require("assert");12const { openBrowser, closeBrowser, goto, text, click, textBox, toRightOf, button, link, $, toLeftOf } = require('taiko');13const headless = process.env.headless_chrome.toLowerCase() === 'true';14const { setDefaultTimeout, setNavigationOptions } = require('taiko');15setDefaultTimeout(60000);16const assert = require("assert");17const { openBrowser, closeBrowser, goto, text, click, textBox, toRightOf, button, link, $, toLeftOf } = require('taiko');18const headless = process.env.headless_chrome.toLowerCase() === 'true';19const { setDefaultTimeout, setNavigationOptions } = require('taiko');20setDefaultTimeout(60000);21const assert = require("assert");22const { openBrowser, closeBrowser, goto, text, click, textBox, toRightOf, button, link, $, toLeftOf } = require('taiko');23const headless = process.env.headless_chrome.toLowerCase() === 'true';24const { setDefaultTimeout, setNavigationOptions } = require('taiko');25setDefaultTimeout(60000);26const assert = require("assert");27const { openBrowser, closeBrowser, goto, text, click, textBox, toRightOf, button, link, $, toLeftOf } = require('taiko');28const headless = process.env.headless_chrome.toLowerCase() === 'true';29const { setDefaultTimeout, setNavigationOptions } = require('taiko');30setDefaultTimeout(60000);31const assert = require("assert");32const { openBrowser,
Using AI Code Generation
1const { openBrowser, goto, click, closeBrowser, textBox, write, button, into, text } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await goto("google.com");6 await write("Taiko", into(textBox({id:"lst-ib"})));7 await click(button({id:"sblsbb"}));8 await click(text("Taiko - Test automation for modern web applications"));9 console.log(await text("Taiko").exists());10 console.log(await text("Taiko").exists(2000));11 console.log(await text("Taiko").exists(2000, 1000));12 console.log(await text("Taiko").exists(2000, 1000, "this text is not present"));13 console.log(await text("Taiko").exists(2000, 1000, "this text is not present", 5000));14 console.log(await text("Taiko").exists(2000, 1000, "this text is not present", 5000, "this text is not present in 5 seconds"));15 } catch (error) {16 console.error(error);17 } finally {18 await closeBrowser();19 }20})();21### text(selector).exists(timeout, interval, message, retryInterval, retryMessage)
Using AI Code Generation
1const taiko = require('taiko');2const { openBrowser, goto, click, closeBrowser, textBox, write, dropDown, toRightOf, button, waitFor, link, image, near, toLeftOf, radioButton, text, $, evaluate } = require('taiko');3const assert = require("assert");4const headless = false;5const { openBrowserArgs } = require('taiko/lib/taiko');6const { waitForNavigation } = require('taiko/lib/taiko');7const { openBrowserOptions } = require('taiko/lib/taiko');8const { openBrowserOptionsHeadless_false } = require('taiko/lib/taiko');9const { openBrowserOptionsHeadless_true } = require('taiko/lib/taiko');10const { openBrowserOptionsHeadless_false_args } = require('taiko/lib/taiko');11const { openBrowserOptionsHeadless_true_args } = require('taiko/lib/taiko');12const { openBrowserArgsHeadless_false } = require('taiko/lib/taiko');13const { openBrowserArgsHeadless_true } = require('taiko/lib/taiko');14const { openBrowserArgsHeadless_false_options } = require('taiko/lib/taiko');15const { openBrowserArgsHeadless_true_options } = require('taiko/lib/taiko');16const { openBrowserHeadless_false } = require('taiko/lib/taiko');17const { openBrowserHeadless_true } = require('taiko/lib/taiko');18const { openBrowserHeadless_false_args } = require('taiko/lib/taiko');19const { openBrowserHeadless_true_args } = require('taiko/lib/taiko');20const { openBrowserHeadless_false_options } = require('taiko/lib/taiko');21const { openBrowserHeadless_true_options } = require('taiko/lib/taiko');22const { openBrowserArgsHeadless_false_options } = require('taiko/lib/taiko');23const { openBrowserArgsHeadless_true_options } = require('taiko/lib/taiko');24const { openBrowserOptionsHeadless_false_args } = require('taiko/lib/taiko');25const { openBrowserOptionsHeadless_true_args } = require('taiko/lib/taiko');26const { openBrowserHeadless_false_args } = require('taiko/lib/taiko');27const { openBrowserHeadless_true_args } = require
Using AI Code Generation
1const { openBrowser, goto, closeBrowser, write, press, click, link, text, $, waitFor, toRightOf, toLeftOf, below, above, button, image, focus, textBox, evaluate, dropDown, radioButton, checkBox, clear, listItem, fileField } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await write("Taiko");6 await press("Enter");7 await click(link("Taiko - A Node.js library for automating ..."));8 await waitFor(2000);9 await click(image("Taiko"));10 await waitFor(2000);11 await click("Documentation");12 await waitFor(2000);13 await click("API Reference");14 await waitFor(2000);15 await click("openBrowser");16 await waitFor(2000);17 await click("goto");18 await waitFor(2000);19 await click("closeBrowser");20 await waitFor(2000);21 await focus(textBox({ id: 'lst-ib' }));22 await clear(textBox({ id: 'lst-ib' }));23 await write("Taiko");24 await press("Enter");25 await waitFor(2000);26 await click(link("Taiko - A Node.js library for automating ..."));27 await waitFor(2000);28 await click(image("Taiko"));29 await waitFor(2000);30 await click("Documentation");31 await waitFor(2000);32 await click("API Reference");33 await waitFor(2000);34 await click("openBrowser");35 await waitFor(2000);36 await click("goto");37 await waitFor(2000);38 await click("closeBrowser");39 await waitFor(2000);40 await focus(textBox({ id: 'lst-ib' }));41 await clear(textBox({ id: 'lst-ib' }));42 await write("Taiko");43 await press("Enter");44 await waitFor(2000);45 await click(link("Taiko - A Node.js library for automating ..."));46 await waitFor(2000);47 await click(image("Taiko"));48 await waitFor(2000);49 await click("Documentation");50 await waitFor(2000);51 await click("API Reference");52 await waitFor(2000);53 await click("openBrowser");54 await waitFor(2000);55 await click("goto");
Using AI Code Generation
1const { openBrowser, goto, click, below, write, closeBrowser, waitFor, textBox, into, toRightOf, button, image, link, text, waitForNavigation, closeTab, reload, $, evaluate } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await write("taiko", into(textBox(below("Search"))));6 await click("Google Search");7 await waitFor(2000);8 await click("Taiko - A Node.js library to automate web ...");9 await waitFor(2000);10 await click("Get Started");11 await waitFor(2000);12 await click("Install Taiko");13 await waitFor(2000);14 await click("Installation");15 await waitFor(2000);16 await click("Install Taiko");17 await waitFor(2000);18 await click("Installation");19 await waitFor(2000);20 await click("Install Taiko");21 await waitFor(2000);22 await click("Installation");23 await waitFor(2000);24 await click("Install Taiko");25 await waitFor(2000);26 await click("Installation");27 await waitFor(2000);28 await click("Install Taiko");29 await waitFor(2000);30 await click("Installation");31 await waitFor(2000);32 await click("Install Taiko");33 await waitFor(2000);34 await click("Installation");35 await waitFor(2000);36 await click("Install Taiko");37 await waitFor(2000);38 await click("Installation");39 await waitFor(2000);40 await click("Install Taiko");41 await waitFor(2000);42 await click("Installation");43 await waitFor(2000);44 await click("Install Taiko");45 await waitFor(2000);46 await click("Installation");47 await waitFor(2000);48 await click("Install Taiko");49 await waitFor(2000);50 await click("Installation");51 await waitFor(2000);52 await click("Install Taiko");53 await waitFor(2000);54 await click("Installation");55 await waitFor(2000);56 } catch (error) {57 console.error(error);58 } finally {59 await closeBrowser();60 }61})();
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!!