Best JavaScript code snippet using webdriverio-monorepo
demo-panel.js
Source:demo-panel.js
1$(document).ready(function(){2 /** DEMO PANEL **/3 $("#demo-panel").click(function () {4 "use strict";5 $(".box-demo").toggleClass("tugel");6 });7 $("#color-reset").click(function(){8 "use strict";9 RemoveClasses();10 AddCookie("", "", "");11 });12 $("#btn-reset").click(function(){13 "use strict";14 RemoveClasses();15 AddCookie("", "", "");16 });17 $("#change-color-light").click(function(){18 "use strict";19 RemoveClasses()20 $(".logo-brand").addClass("white-color");21 $(".sidebar-left").addClass("light-color");22 AddCookie("white-color", "", "light-color");23 });24 $("#change-primary-dark").click(function(){25 "use strict";26 RemoveClasses()27 $(".logo-brand").addClass("primary-color");28 AddCookie("primary-color", "", "");29 });30 $("#change-info-dark").click(function(){31 "use strict";32 RemoveClasses()33 $(".logo-brand").addClass("info-color");34 AddCookie("info-color", "", "");35 });36 $("#change-success-dark").click(function(){37 "use strict";38 RemoveClasses()39 $(".logo-brand").addClass("success-color");40 $(".sidebar-left").removeClass("light-color");41 AddCookie("success-color", "", "");42 });43 $("#change-danger-dark").click(function(){44 "use strict";45 RemoveClasses()46 $(".logo-brand").addClass("danger-color");47 AddCookie("danger-color", "", "");48 });49 $("#change-warning-dark").click(function(){50 "use strict";51 RemoveClasses()52 $(".logo-brand").addClass("warning-color");53 AddCookie("warning-color", "", "");54 });55 $("#change-primary-light").click(function(){56 "use strict";57 RemoveClasses()58 $(".logo-brand").addClass("primary-color");59 $(".sidebar-left").addClass("light-color");60 AddCookie("primary-color", "", "light-color");61 });62 $("#change-info-light").click(function(){63 "use strict";64 RemoveClasses()65 $(".logo-brand").addClass("info-color");66 $(".sidebar-left").addClass("light-color");67 AddCookie("info-color", "", "light-color");68 });69 $("#change-success-light").click(function(){70 "use strict";71 RemoveClasses()72 $(".logo-brand").addClass("success-color");73 $(".sidebar-left").addClass("light-color");74 AddCookie("success-color", "", "light-color");75 });76 $("#change-danger-light").click(function(){77 "use strict";78 RemoveClasses()79 $(".logo-brand").addClass("danger-color");80 $(".sidebar-left").addClass("light-color");81 AddCookie("danger-color", "", "light-color");82 });83 $("#change-warning-light").click(function(){84 "use strict";85 RemoveClasses()86 $(".logo-brand").addClass("warning-color");87 $(".sidebar-left").addClass("light-color");88 AddCookie("warning-color", "", "light-color");89 });90 $("#change-dark-light").click(function(){91 "use strict";92 RemoveClasses()93 $(".sidebar-left").addClass("light-color");94 AddCookie("", "", "light-color");95 });96 97 $("#change-full-primary-light").click(function(){98 "use strict";99 RemoveClasses()100 $(".logo-brand").addClass("primary-color");101 $(".top-navbar").addClass("primary-color");102 $(".sidebar-left").addClass("light-color");103 AddCookie("primary-color", "primary-color", "light-color");104 });105 $("#change-full-success-light").click(function(){106 "use strict";107 RemoveClasses()108 $(".logo-brand").addClass("success-color");109 $(".top-navbar").addClass("success-color");110 $(".sidebar-left").addClass("light-color");111 AddCookie("success-color", "success-color", "light-color");112 });113 $("#change-full-info-light").click(function(){114 "use strict";115 RemoveClasses()116 $(".logo-brand").addClass("info-color");117 $(".top-navbar").addClass("info-color");118 $(".sidebar-left").addClass("light-color");119 AddCookie("info-color", "info-color", "light-color");120 });121 $("#change-full-danger-light").click(function(){122 "use strict";123 RemoveClasses()124 $(".logo-brand").addClass("danger-color");125 $(".top-navbar").addClass("danger-color");126 $(".sidebar-left").addClass("light-color");127 AddCookie("danger-color", "danger-color", "light-color");128 });129 $("#change-full-warning-light").click(function(){130 "use strict";131 RemoveClasses()132 $(".logo-brand").addClass("warning-color");133 $(".top-navbar").addClass("warning-color");134 $(".sidebar-left").addClass("light-color");135 AddCookie("warning-color", "warning-color", "light-color");136 });137 $("#change-full-dark-light").click(function(){138 "use strict";139 RemoveClasses()140 $(".top-navbar").addClass("dark-color");141 $(".sidebar-left").addClass("light-color");142 AddCookie("dark-color", "dark-color", "light-color");143 });144 145 $("#change-sidebar-primary-light").click(function(){146 "use strict";147 RemoveClasses()148 $(".logo-brand").addClass("primary-color");149 $(".sidebar-left").addClass("primary-color");150 AddCookie("primary-color", "", "primary-color");151 });152 $("#change-sidebar-success-light").click(function(){153 "use strict";154 RemoveClasses()155 $(".logo-brand").addClass("success-color");156 $(".sidebar-left").addClass("success-color");157 AddCookie("success-color", "", "success-color");158 });159 $("#change-sidebar-info-light").click(function(){160 "use strict";161 RemoveClasses()162 $(".logo-brand").addClass("info-color");163 $(".sidebar-left").addClass("info-color");164 AddCookie("info-color", "", "info-color");165 });166 $("#change-sidebar-danger-light").click(function(){167 "use strict";168 RemoveClasses()169 $(".logo-brand").addClass("danger-color");170 $(".sidebar-left").addClass("danger-color");171 AddCookie("danger-color", "", "danger-color");172 });173 $("#change-sidebar-warning-light").click(function(){174 "use strict";175 RemoveClasses()176 $(".logo-brand").addClass("warning-color");177 $(".sidebar-left").addClass("warning-color");178 AddCookie("warning-color", "", "warning-color");179 });180 181 $("#change-full-primary-dark").click(function(){182 "use strict";183 RemoveClasses()184 $(".logo-brand").addClass("primary-color");185 $(".top-navbar").addClass("primary-color");186 $(".sidebar-left").addClass("dark-color");187 AddCookie("primary-color", "primary-color", "dark-color");188 });189 $("#change-full-success-dark").click(function(){190 "use strict";191 RemoveClasses()192 $(".logo-brand").addClass("success-color");193 $(".top-navbar").addClass("success-color");194 $(".sidebar-left").addClass("dark-color");195 AddCookie("success-color", "success-color", "dark-color");196 });197 $("#change-full-info-dark").click(function(){198 "use strict";199 RemoveClasses()200 $(".logo-brand").addClass("info-color");201 $(".top-navbar").addClass("info-color");202 $(".sidebar-left").addClass("dark-color");203 AddCookie("info-color", "info-color", "dark-color");204 });205 $("#change-full-danger-dark").click(function(){206 "use strict";207 RemoveClasses()208 $(".logo-brand").addClass("danger-color");209 $(".top-navbar").addClass("danger-color");210 $(".sidebar-left").addClass("dark-color");211 AddCookie("danger-color", "danger-color", "dark-color");212 });213 $("#change-full-warning-dark").click(function(){214 "use strict";215 RemoveClasses()216 $(".logo-brand").addClass("warning-color");217 $(".top-navbar").addClass("warning-color");218 $(".sidebar-left").addClass("dark-color");219 AddCookie("warning-color", "warning-color", "dark-color");220 });221 $("#change-full-primary").click(function(){222 "use strict";223 RemoveClasses()224 $(".logo-brand").addClass("primary-color");225 $(".top-navbar").addClass("primary-color");226 $(".sidebar-left").addClass("primary-color");227 AddCookie("primary-color", "primary-color", "primary-color");228 });229 $("#change-full-success").click(function(){230 "use strict";231 RemoveClasses()232 $(".logo-brand").addClass("success-color");233 $(".top-navbar").addClass("success-color");234 $(".sidebar-left").addClass("success-color");235 AddCookie("success-color", "success-color", "success-color");236 });237 $("#change-full-info").click(function(){238 "use strict";239 RemoveClasses()240 $(".logo-brand").addClass("info-color");241 $(".top-navbar").addClass("info-color");242 $(".sidebar-left").addClass("info-color");243 AddCookie("info-color", "info-color", "info-color");244 });245 $("#change-full-danger").click(function(){246 "use strict";247 RemoveClasses()248 $(".logo-brand").addClass("danger-color");249 $(".top-navbar").addClass("danger-color");250 $(".sidebar-left").addClass("danger-color");251 AddCookie("danger-color", "danger-color", "danger-color");252 });253 $("#change-full-warning").click(function(){254 "use strict";255 RemoveClasses()256 $(".logo-brand").addClass("warning-color");257 $(".top-navbar").addClass("warning-color");258 $(".sidebar-left").addClass("warning-color");259 AddCookie("warning-color", "warning-color", "warning-color");260 });261 $("#change-full-dark").click(function(){262 "use strict";263 RemoveClasses()264 $(".top-navbar").addClass("dark-color");265 AddCookie("", "dark-color", "");266 });267 268 function RemoveClasses() {269 "use strict";270 $(".logo-brand").removeClass("white-color");271 $(".logo-brand").removeClass("primary-color");272 $(".logo-brand").removeClass("info-color");273 $(".logo-brand").removeClass("success-color");274 $(".logo-brand").removeClass("danger-color");275 $(".logo-brand").removeClass("warning-color");276 $(".top-navbar").removeClass("primary-color");277 $(".top-navbar").removeClass("info-color");278 $(".top-navbar").removeClass("success-color");279 $(".top-navbar").removeClass("danger-color");280 $(".top-navbar").removeClass("warning-color");281 $(".top-navbar").removeClass("dark-color");282 $(".sidebar-left").removeClass("light-color");283 $(".sidebar-left").removeClass("primary-color");284 $(".sidebar-left").removeClass("info-color");285 $(".sidebar-left").removeClass("success-color");286 $(".sidebar-left").removeClass("danger-color");287 $(".sidebar-left").removeClass("warning-color");288 }289 function AddCookie(logobrand,topnavbar,sidebarleft) {290 setCookie("logo-brand", logobrand, 30);291 setCookie("top-navbar", topnavbar, 30);292 setCookie("sidebar-left", sidebarleft, 30);293 }294 function ShowCookie() {295 $(".logo-brand").addClass(getCookie("logo-brand"));296 $(".top-navbar").addClass(getCookie("top-navbar"));297 $(".sidebar-left").addClass(getCookie("sidebar-left"));298 }299 function getCookie(c_name) {300 if (document.cookie.length > 0) {301 var c_start = document.cookie.indexOf(c_name + "=");302 if (c_start != -1) {303 c_start = c_start + c_name.length + 1;304 c_end = document.cookie.indexOf(";", c_start);305 if (c_end == -1) c_end = document.cookie.length;306 return unescape(document.cookie.substring(c_start, c_end));307 }308 }309 return ""310 }311 function setCookie(c_name, value, expiredays) {312 var exdate = new Date();313 exdate.setDate(exdate.getDate() + expiredays);314 document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());315 }316 ShowCookie();...
add-cookie.js
Source:add-cookie.js
...12 for (let i = 0, len = config.currentAvailableLangs.length; i < len; i++) {13 const preferredErrorLanguage = config.currentAvailableLangs[i]14 cm.preferredErrorLanguage = preferredErrorLanguage15 try {16 cm.addCookie()17 throw new Error()18 } catch (e) {19 ev({t, scope: [...scope, `No options`], e, errorCategory, preferredErrorLanguage})20 }21 try {22 cm.addCookie('')23 throw new Error()24 } catch (e) {25 ev({t, scope: [...scope, `Empty string`], e, errorCategory, preferredErrorLanguage})26 }27 try {28 cm.addCookie('n=v; Domain=com', {requestURL: 'example.com'})29 throw new Error()30 } catch (e) {31 ev({t, scope: [...scope, `public suffix`], e, errorCategory, preferredErrorLanguage})32 }33 try {34 cm.addCookie('n=v', {requestURL: 'example.com', topLevelURL: ''})35 throw new Error()36 } catch (e) {37 ev({t, scope: [...scope, `invalid topLevelURL`], e, errorCategory, preferredErrorLanguage})38 }39 try {40 cm.addCookie('n=v', {requestURL: 'example.com', topLevelURL: {hostname: 'not-example.com'}})41 throw new Error()42 } catch (e) {43 ev({t, scope: [...scope, `third-party cookies disabled by default`], e, errorCategory, preferredErrorLanguage})44 }45 try {46 cm.addCookie('n=v; Domain=http-only.example.com; httpOnly')47 cm.addCookie('n=v; Domain=http-only.example.com')48 throw new Error()49 } catch (e) {50 ev({t, scope: [...scope, `httpOnly cannot be overwritten by cookie w/o httpOnly`], e, errorCategory, preferredErrorLanguage})51 }52 try {53 cm.addCookie(`n=v; Domain=${'a'.repeat(cm.maxCookieByteLength)}.com;`)54 throw new Error()55 } catch (e) {56 ev({t, scope: [...scope, `should not exceed "maxCookieByteLength"`], e, errorCategory, preferredErrorLanguage})57 }58 try {59 cm.addCookie({name: 'n', value: 'v', domain: `${'a'.repeat(cm.maxCookieByteLength)}.com`})60 throw new Error()61 } catch (e) {62 ev({t, scope: [...scope, `should not exceed "maxCookieByteLength" - OBJECT`], e, errorCategory, preferredErrorLanguage})63 }64 for (let j = 0, jLen = config.addCookieStrings.invalid.length; j < jLen; j++) {65 const invalidGroup = Array.from(config.addCookieStrings.invalid[j])66 try {67 cm.addCookie(invalidGroup[0], invalidGroup[1])68 throw new Error()69 } catch (e) {70 ev({t, scope: [...scope, invalidGroup], e, errorCategory, preferredErrorLanguage})71 }72 }73 for (let j = 0, jLen = config.addCookieObjects.invalid.length; j < jLen; j++) {74 const invalidGroup = Array.from(config.addCookieObjects.invalid[j])75 try {76 cm.addCookie(invalidGroup[0], invalidGroup[1])77 throw new Error()78 } catch (e) {79 ev({t, scope: [...scope, invalidGroup], e, errorCategory, preferredErrorLanguage})80 }81 }82 }83 cm.preferredErrorLanguage = cachedpreferredErrorLanguage84 for (let i = 0, len = config.addCookieStrings.valid.length; i < len; i++) {85 const validGroup = Array.from(config.addCookieStrings.valid[i])86 const cookieObject = cm.addCookie(validGroup[0], validGroup[1])87 validateCookieObject(t, [...scope, validGroup], Object.assign({}, sharedState, {cookieObject}))88 cm.cookies = {}89 }90 for (let i = 0, len = config.addCookieObjects.valid.length; i < len; i++) {91 const validGroup = Array.from(config.addCookieStrings.valid[i])92 const cookieObject = cm.addCookie(validGroup[0], validGroup[1])93 validateCookieObject(t, [...scope, validGroup], Object.assign({}, sharedState, {cookieObject}))94 cm.cookies = {}95 }96 cm.cookies = {}97 t.false(cm.addCookie({name: 'n', value: 'v', domain: 'example.com'})['persistent-flag'], m(scope, `cookies created without Expires or Max-Age should be a session cookie (persistent-flag === false)`))98 t.true(cm.addCookie({name: 'n', value: 'v', domain: 'example.com', expires: Date.now() + 10000})['persistent-flag'], m(scope, `cookies created with Expires should be a persistent cookie`))99 t.true(cm.addCookie({name: 'n', value: 'v', domain: 'example.com', expires: Date.now() + 10000})['expiry-time'] > Date.now(), m(scope, `cookies created with Max-Age should have an expiry-time later than now`))100 t.true(cm.addCookie({name: 'n', value: 'v', domain: 'example.com', maxAge: 10})['persistent-flag'], m(scope, `cookies created with Max-Age should be a persistent cookie`))101 t.true(cm.addCookie({name: 'n', value: 'v', domain: 'example.com', maxAge: 10})['expiry-time'] > Date.now(), m(scope, `cookies created with Max-Age should have an expiry-time later than now`))102 t.true(cm.addCookie({name: 'n', value: 'v', domain: 'example.com', expires: Date.now() + 10000, maxAge: 20})['expiry-time'] > (Date.now() + 15000), m(scope, `cookies created with Expires or Max-Age should prefer Max-Age (Expires < Max-Age check)`))103 t.true(cm.addCookie({name: 'n', value: 'v', domain: 'example.com', expires: Date.now() + 20000, maxAge: 10})['expiry-time'] < (Date.now() + 15000), m(scope, `cookies created with Expires or Max-Age should prefer Max-Age (Expires > Max-Age check)`))104 t.true(cm.addCookie({name: 'n', value: 'v', domain: 'example.com', secure: true})['secure-only-flag'], m(scope, `cookies created with Secure should have a 'secure-only-flag'`))105 await new Promise((resolve, reject) => {106 function addedCookieHandler (cookieObject) {107 if (cookieObject.name === uniqueCookieId) {108 t.pass(m(scope, `should fire an 'addedCookie' event when a new cookie has been added`))109 t.equal(typeof cm.cookies[cookieObject.domain][cookieObject.path][cookieObject.name], 'object', m(scope, `should create a nested cookie object path to cookie object once added`))110 t.true(cookieObject instanceof jetta.CookieManagerCookie, m(scope, `should be an instance of jetta.CookieManagerCookie`))111 cm.removeListener('addedCookie', addedCookieHandler)112 resolve()113 }114 }115 cm.on('addedCookie', addedCookieHandler)116 cm.addCookie({name: uniqueCookieId, value: uniqueCookieId, domain: uniqueCookieId})117 })118 await new Promise((resolve, reject) => {119 function updatedCookieHandler (cookieObject) {120 if (cookieObject.name === uniqueCookieId) {121 t.pass(m(scope, `should fire an 'updatedCookie' event when a cookie has been updated`))122 t.equal(typeof cm.cookies[cookieObject.domain][cookieObject.path][cookieObject.name], 'object', m(scope, `should have a nested cookie object path to updated cookie object`))123 t.true(cookieObject instanceof jetta.CookieManagerCookie, m(scope, `should be an instance of jetta.CookieManagerCookie`))124 cm.removeListener('updatedCookie', updatedCookieHandler)125 resolve()126 }127 }128 cm.on('updatedCookie', updatedCookieHandler)129 cm.addCookie({name: uniqueCookieId, value: uniqueCookieId, domain: uniqueCookieId})130 })131 await new Promise((resolve, reject) => {132 function deleteCookieHandler (cookieObject) {133 if (cookieObject.name === uniqueCookieId) {134 t.pass(m(scope, `"deletedCookie" event\` should fire a 'deletedCookie' event when a new cookie has been deleted`))135 t.equal(cm.cookies[cookieObject.domain], undefined, m(scope, `should delete a nested cookie object path if no more cookies are in the cookie object path`))136 t.true(cookieObject instanceof jetta.CookieManagerCookie, m(scope, `should be an instance of jetta.CookieManagerCookie`))137 cm.removeListener('deletedCookie', deleteCookieHandler)138 resolve()139 }140 }141 cm.on('deletedCookie', deleteCookieHandler)142 cm.addCookie({name: uniqueCookieId, value: uniqueCookieId, domain: uniqueCookieId, maxAge: -1})143 })144 cm.cookies = {}145 cm.maxCookiesPerDomain = 64146 cm.maxCookies = 64147 for (let i = 0, len = cm.maxCookiesPerDomain; i < len; i++) {148 cm.addCookie({name: `n${i}`, value: `v${i}`, domain: `example.com`})149 }150 cm.addCookie({name: 'n', value: 'v', domain: 'example.com'})151 t.equal(cm.getCookies().length, 1, m(scope, `cookies should be emptied for a particular domain when domain surpasses "maxCookiesPerDomain"`))152 cm.cookies = {}153 for (let i = 0, len = cm.maxCookies; i < len; i++) {154 cm.addCookie({name: `n`, value: `v`, domain: `s${i}.example.com`})155 }156 cm.addCookie({name: 'n', value: 'v', domain: 'example.com'})157 t.equal(cm.getCookies().length, 1, m(scope, `cookies should be emptied for all domains when "maxCookies" as been reached`))158 cm.maxCookiesPerDomain = cachedMaxCookiesPerDomain159 cm.maxCookies = cachedMaxCookies160 cm.cookies = {}161 cm.addCookie({name: uniqueCookieExpireId, value: '', domain: uniqueCookieExpireId, maxAge: 1})162 cm.cookies[uniqueCookieExpireId]['/'][uniqueCookieExpireId]['expiry-time'] = Date.now() - 1163 cm.addCookie({name: uniqueCookieId, value: uniqueCookieId, domain: uniqueCookieId, maxAge: -1})164 t.equal(cm.cookies[uniqueCookieExpireId], undefined, m(scope, `should delete expired cookies`))165 cm.cookies = {}166}...
action.js
Source:action.js
...5//" 6//"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''7function Action()8{9 web.addCookie('SRCHUID=V=2&GUID=929B6FA041A640DFACCBCF7DC0980197; DOMAIN=www.bing.com');10 web.addCookie('SRCHD=AF=NOFORM; DOMAIN=www.bing.com');11 web.addCookie('SRCHUSR=DOB=20170405; DOMAIN=www.bing.com');12 web.url(13 {14 name : 'favicon.ico', 15 url : 'http://www.bing.com/favicon.ico', 16 resource : 1, 17 recContentType : 'image/x-icon', 18 referer : '', 19 snapshot : 't1.inf'20 }21 );22 web.addCookie('currency=EUR; DOMAIN=172.16.44.19');23 web.addCookie('__atuvc=9%7C15%2C15%7C16%2C0%7C17%2C1%7C18; DOMAIN=172.16.44.19');24 web.regFind(25 {26 text : 'Your Store'27 }28 );29 web.url(30 {31 name : 'oc', 32 url : 'http://172.16.44.19/oc/', 33 resource : 0, 34 recContentType : 'text/html', 35 referer : '', 36 snapshot : 't2.inf', 37 mode : 'HTML', 38 extraRes : [39 {url : 'catalog/view/theme/default/image/loading.gif'},40 {url : 'catalog/view/theme/default/image/button-search.png'},41 {url : 'catalog/view/theme/default/image/button-previous.png'},42 {url : 'catalog/view/theme/default/image/button-next.png'},43 {url : 'catalog/view/theme/default/image/arrow-down.png'},44 {url : 'catalog/view/theme/default/image/menu.png'},45 {url : 'catalog/view/theme/default/image/background.png'},46 {url : 'catalog/view/theme/default/image/button.png'},47 {url : 'catalog/view/theme/default/image/bullets.png'},48 {url : 'catalog/view/theme/default/image/arrows.png'}49 ]50 }51 );52 web.regFind(53 {54 text : 'Cameras'55 }56 );57 lr.thinkTime(6);58 web.link(59 {60 name : 'Cameras', 61 text : 'Cameras', 62 snapshot : 't3.inf', 63 extraRes : [64 {url : 'catalog/view/theme/default/image/add.png', referer : 'http://172.16.44.19/oc/index.php?route=product/category&path=33'}65 ]66 }67 );68 lr.thinkTime(9);69 web.submitData(70 {71 name : 'index.php', 72 action : 'http://172.16.44.19/oc/index.php?route=product/compare/add', 73 method : 'POST', 74 recContentType : 'text/html', 75 referer : 'http://172.16.44.19/oc/index.php?route=product/category&path=33', 76 snapshot : 't4.inf', 77 mode : 'HTML', 78 itemData : [79 {name : 'product_id', value : '30'}80 ],81 extraRes : [82 {url : 'catalog/view/theme/default/image/close.png', referer : 'http://172.16.44.19/oc/index.php?route=product/category&path=33'},83 {url : 'catalog/view/theme/default/image/success.png', referer : 'http://172.16.44.19/oc/index.php?route=product/category&path=33'}84 ]85 }86 );87 lr.thinkTime(4);88 web.submitData(89 {90 name : 'index.php_2', 91 action : 'http://172.16.44.19/oc/index.php?route=product/compare/add', 92 method : 'POST', 93 recContentType : 'text/html', 94 referer : 'http://172.16.44.19/oc/index.php?route=product/category&path=33', 95 snapshot : 't5.inf', 96 mode : 'HTML', 97 itemData : [98 {name : 'product_id', value : '31'}99 ]100 }101 );102 web.regFind(103 {104 text : 'Product Comparison'105 }106 );107 web.url(108 {109 name : 'index.php_3', 110 url : 'http://172.16.44.19/oc/index.php?route=product/compare', 111 resource : 0, 112 recContentType : 'text/html', 113 referer : 'http://172.16.44.19/oc/index.php?route=product/category&path=33', 114 snapshot : 't6.inf', 115 mode : 'HTML'116 }117 );118 web.setSocketsOption('SSL_VERSION', '2&3');119 web.addCookie('MC1=GUID=605b1210a00d984c98b65aa1bb3f1fe4&HASH=1012&LV=201612&V=4&LU=1482491531276; DOMAIN=iecvlist.microsoft.com');120 web.addCookie('A=I&I=AxUFAAAAAAA/CgAAw19EUVpKI2axcHutFCiCJA!!&V=4; DOMAIN=iecvlist.microsoft.com');121 web.addCookie('MSFPC=ID=605b1210a00d984c98b65aa1bb3f1fe4&CS=3&LV=201612&V=1; DOMAIN=iecvlist.microsoft.com');122 web.addCookie('SRCHD=AF=NOFORM; DOMAIN=iecvlist.microsoft.com');123 web.addCookie('SRCHUSR=DOB=20170102; DOMAIN=iecvlist.microsoft.com');124 web.addCookie('MUID=2966A66248FA6A192AC5AC364CFA6C73; DOMAIN=iecvlist.microsoft.com');125 web.addCookie('MC1=GUID=605b1210a00d984c98b65aa1bb3f1fe4&HASH=1012&LV=201612&V=4&LU=1482491531276; DOMAIN=r20swj13mr.microsoft.com');126 web.addCookie('A=I&I=AxUFAAAAAAA/CgAAw19EUVpKI2axcHutFCiCJA!!&V=4; DOMAIN=r20swj13mr.microsoft.com');127 web.addCookie('MSFPC=ID=605b1210a00d984c98b65aa1bb3f1fe4&CS=3&LV=201612&V=1; DOMAIN=r20swj13mr.microsoft.com');128 web.addCookie('SRCHD=AF=NOFORM; DOMAIN=r20swj13mr.microsoft.com');129 web.addCookie('SRCHUSR=DOB=20170102; DOMAIN=r20swj13mr.microsoft.com');130 web.addCookie('MUID=2966A66248FA6A192AC5AC364CFA6C73; DOMAIN=r20swj13mr.microsoft.com');131 web.url(132 {133 name : 'iecompatviewlist.xml', 134 url : 'https://iecvlist.microsoft.com/IE11/1479242656000/iecompatviewlist.xml', 135 resource : 0, 136 recContentType : 'text/xml', 137 referer : '', 138 snapshot : 't7.inf', 139 mode : 'HTML', 140 extraRes : [141 {url : 'https://r20swj13mr.microsoft.com/ieblocklist/v1/urlblockindex.bin', referer : ''}142 ]143 }144 );...
comlog.js
Source:comlog.js
...7 // è®°å½æ§çagencyid/marchantid8 var agencyid = getCookie("agencyid");9 var merchantid = getCookie("merchantid");10 // å·æ°agencyid/merchantid cookie11 addCookie('agencyid',agencyId);12 addCookie('merchantid',merchantId);13 var key = getCookie("key");14 if (parseInt(agencyId)>0 && parseInt(merchantId) > 0){15 if (agencyId != agencyid || merchantId != merchantid){16 // èåç»å½17 $.ajax({18 url: ApiUrl + "/index.php?con=login&fun=comlogin",19 type: 'post',20 dataType: 'json',21 timeout:5000,22 data:{agencyid:agencyId,merchantid:merchantId,key:key,client:'wap'},23 success: function(result) {24 if(!result.datas.error){25 if(typeof(result.datas.key)=='undefined'){26 delCookie('key')27 delCookie('username')28 addCookie('agencyid',"-1");29 addCookie('merchantid',"-1");30 }else{31 // æ´æ°cookieè´ç©è½¦32 updateCookieCart(result.datas.key);33 addCookie('username',result.datas.username);34 addCookie('key',result.datas.key);35 36 }37 }else{38 delCookie('key')39 delCookie('username')40 addCookie('agencyid',"-1");41 addCookie('merchantid',"-1");42 errorTipsShow("<p>"+result.datas.error+"</p>");43 }44 // ç»å½è¿åä¹ååè°åç»é»è¾ 45 callback();46 },47 complete: function (XMLHttpRequest, textStatus) {48 if(textStatus == 'timeout'){49 delCookie('key')50 delCookie('username')51 addCookie('agencyid',"-1");52 addCookie('merchantid',"-1");53 errorTipsShow("<p>èåç»å½è¶
æ¶</p>");54 }55 // ç»å½è¿åä¹ååè°åç»é»è¾ 56 callback();57 },58 error: function (XMLHttpRequest, textStatus) {59 delCookie('key')60 delCookie('username')61 addCookie('agencyid',"-1");62 addCookie('merchantid',"-1");63 errorTipsShow("<p>èåç»å½åºé</p>");64 // ç»å½è¿åä¹ååè°åç»é»è¾ 65 callback();66 }67 });68 }69 else {70 if (key == null || key == ""){71 delCookie('key')72 delCookie('username')73 addCookie('agencyid',"-1");74 addCookie('merchantid',"-1");75 }76 // ç»å½è¿åä¹ååè°åç»é»è¾ 77 callback();78 }79 } else {80 if (key != null && key != ""){81 // èå注é 82 $.ajax({83 url: ApiUrl + "/index.php?con=logout&fun=comlogout",84 type: 'post',85 dataType: 'json',86 data:{agencyid:agencyid,merchantid:merchantid,key:key,client:'wap'},87 success: function(result) {88 if(!result.datas.error){89 delCookie('key')90 delCookie('username')91 addCookie('agencyid',"-1");92 addCookie('merchantid',"-1");93 }else{94 errorTipsShow("<p>"+result.datas.error+"</p>");95 }96 // 注éè¿åä¹ååè°åç»é»è¾ 97 callback();98 }99 });100 }101 else{102 delCookie('key')103 delCookie('username')104 addCookie('agencyid',"-1");105 addCookie('merchantid',"-1");106 // 注éè¿åä¹ååè°åç»é»è¾ 107 callback();108 }109 }...
app.js
Source:app.js
...32var skins = document.getElementById("skin");3334function skin1() {35 skins.href = "css/bg1.css";36 addCookie("color", "css/bg1.css");37}3839function skin2() {40 skins.href = "css/bg2.css";41 addCookie("color", "css/bg2.css");42}4344function skin3() {45 skins.href = "css/bg3.css";46 addCookie("color", "css/bg3.css");47}4849function skin4() {50 skins.href = "css/bg4.css";51 addCookie("color", "css/bg4.css");52}5354function skin5() {55 skins.href = "css/bg5.css";56 addCookie("color", "css/bg5.css");57}5859function skin6() {60 skins.href = "css/bg6.css";61 addCookie("color", "css/bg6.css");62}6364function skin7() {65 skins.href = "css/bg7.css";66 addCookie("color", "css/bg7.css");67}6869function skin8() {70 skins.href = "css/bg8.css";71 addCookie("color", "css/bg8.css");72}7374function skin9() {75 skins.href = "css/bg9.css";76 addCookie("color", "css/bg9.css");77}7879function skin10() {80 skins.href = "css/bg10.css";81 addCookie("color", "css/bg10.css");82}8384function skin11() {85 skins.href = "css/bg11.css";86 addCookie("color", "css/bg11.css");87}8889function skin12() {90 skins.href = "css/bg12.css";91 addCookie("color", "css/bg12.css");92}9394function changeColor(href) {95 skins.href;96}97//æ·»å cookie 98function addCookie(name, value) {99 var Days = 30;100 var exp = new Date();101 exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);102 document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();103}104105//è·åæå®å称çcookieçå¼ 106function getCookie(objName) {107 var arrStr = document.cookie.split("; ");108 for (var i = 0; i < arrStr.length; i++) {109 var temp = arrStr[i].split("=");110 if (temp[0] == objName) return unescape(temp[1]);111 }112}
...
home.js
Source:home.js
1/**2 * Created by loumoon on 2018/6/9.3 */4/*为cookieèµå¼çå½æ°*/5function addCookie(name,value,expiresHours){6 var cookieString=name+"="+escape(value);7 //å¤ææ¯å¦è®¾ç½®è¿ææ¶é´,å¦ææ¯0ï¼åcookieå¨æµè§å¨å
³éä¹åæ°¸è¿ææ8 if(expiresHours>0){9 var date=new Date();10 date.setTime(date.getTime+expiresHours*3600*1000);11 cookieString=cookieString+"; expires="+date.toGMTString();12 }13 document.cookie=cookieString;14}15/*ä»cookieä¸åå¼çå½æ°*/16function getCookie(name){17 var strCookie=document.cookie;18 var arrCookie=strCookie.split("; ");19 for(var i=0;i<arrCookie.length;i++){20 var arr=arrCookie[i].split("=");21 if(arr[0]==name)return arr[1];22 }23 return "";24}25/*clickäºä»¶1ï¼ç¹å»è·ågold market depthæé®*/26$("#goldDepth").click(function(e) {27 var period=$("#goldPeriod").find("option:selected").text();28 var broker=$("#goldBroker").find("option:selected").text();29 if(period=="period"){30 alert("Please choose one period!");31 return false;32 }33 else if(broker=="broker"){34 alert("Please choose one broker!");35 return false;36 }37 addCookie("depth_product","gold",0);38 addCookie("depth_period",period,0);39 addCookie("depth_broker",broker,0);40 window.location.href="depth.html";41})42/*clickäºä»¶2ï¼ç¹å»è·åsilver market depthæé®*/43$("#silverDepth").click(function(e) {44 var period=$("#silverPeriod").find("option:selected").text();45 var broker=$("#silverBroker").find("option:selected").text();46 if(period=="period"){47 alert("Please choose one period!");48 return false;49 }50 else if(broker=="broker"){51 alert("Please choose one broker!");52 return false;53 }54 addCookie("depth_product","silver",0);55 addCookie("depth_period",period,0);56 addCookie("depth_broker",broker,0);57 window.location.href="depth.html";58})59/*clickäºä»¶3ï¼ç¹å»è·åoil market depthæé®*/60$("#oilDepth").click(function(e) {61 var period=$("#oilPeriod").find("option:selected").text();62 var broker=$("#oilBroker").find("option:selected").text();63 if(period=="period"){64 alert("Please choose one period!");65 return false;66 }67 else if(broker=="broker"){68 alert("Please choose one broker!");69 return false;70 }71 addCookie("depth_product","oil",0);72 addCookie("depth_period",period,0);73 addCookie("depth_broker",broker,0);74 window.location.href="depth.html";75})76/*clickäºä»¶4ï¼ç¹å»è·åsoybean market depthæé®*/77$("#soybeanDepth").click(function(e) {78 var period=$("#soybeanPeriod").find("option:selected").text();79 var broker=$("#soybeanBroker").find("option:selected").text();80 if(period=="period"){81 alert("Please choose one period!");82 return false;83 }84 else if(broker=="broker"){85 alert("Please choose one broker!");86 return false;87 }88 addCookie("depth_product","soybean",0);89 addCookie("depth_period",period,0);90 addCookie("depth_broker",broker,0);91 window.location.href="depth.html";...
product.js
Source:product.js
...8 var pic=$("#prouct-1-1").attr("src");9 var text=$("#product-1-2").html();10 if(!!getCookie("count_1")){11 str+=count1;12 addCookie("count_1", str, 10);//æ°é13 addCookie("price_1",str*80.00,10);//æ»ä»·14 $('.shoppingcar').html((Number(getCookie("count_1")))+(Number(getCookie("count_2")))+"<b>件货å</b>");15 $('.shoppingmoney').html(Number(getCookie("price_1"))+Number(getCookie("price_2"))+" <b>USD</b>");16 }else{17 addCookie("pic_1",pic,10);//å¾ç18 addCookie("name_1",text,10);//å称19 // addCookie("one_price_1",oneprice,10);//åä»·20 addCookie("count_1",count1,10);21 addCookie('price_1',price1,10);22 $('.shoppingcar').html((Number(getCookie("count_1")))+(Number(getCookie("count_2")))+"<b>件货å</b>");23 $('.shoppingmoney').html(Number(getCookie("price_1"))+Number(getCookie("price_2"))+" <b>USD</b>");24 }25 26 })27 $('#addcart2').click(function(){28 var count2=Number($('#select2').val());29 var price2=16.00*count2; 30 var str=Number(getCookie("count_2"));31 var pic=$("#prouct-2-1").attr("src");32 var text=$("#product-2-2").html();33 if(!!getCookie("count_2")){34 str+=count2; 35 addCookie("count_2", str, 10);36 addCookie("price_2",str*16.00,10);37 $('.shoppingcar').html((Number(getCookie("count_1")))+(Number(getCookie("count_2")))+"<b>件货å</b>");38 $('.shoppingmoney').html(Number(getCookie("price_1"))+Number(getCookie("price_2"))+" <b>USD</b>");39 }else{40 addCookie("pic_2",pic,10);//å¾ç41 addCookie("name_2",text,10);//å称42 addCookie("count_2",count2,10);43 addCookie('price_2',price2,10);44 $('.shoppingcar').html((Number(getCookie("count_1")))+(Number(getCookie("count_2")))+"<b>件货å</b>");45 $('.shoppingmoney').html(Number(getCookie("price_1"))+Number(getCookie("price_2"))+" <b>USD</b>");46 }47 48 })49 function addCookie(_name, _value, _day){50 var d = new Date();51 d.setDate(d.getDate()+_day);52 document.cookie=_name+"="+_value+"; expires="+d.toGMTString();53 }54 55 // function getCookie(_name){56 // var str="";57 // var col=document.cookie.split("; ");58 // for(var i in col){59 // var arr=col[i].split("=");60 // if(arr[0]==_name){61 // str=arr[1];62 // break;63 // }...
login.js
Source:login.js
...35 dataType : 'text', 36 success : function(data) { 37 var jsonlogin = $.parseJSON( data ); 38 if (jsonlogin.status == 'OK'){39 addCookie("userid",userid.value,7,"/"); 40 addCookie("authorization",jsonlogin.authorization,7,"/");41 addCookie("login","YES",7,"/");42 addCookie("locked","NO",7,"/");43 addCookie("password",password.value,7,"/");44 45 window.location.href="index.do";46 }else{47 addCookie("login","NO",7,"/");48 addCookie("userid","",7,"/");49 document.getElementById("message").innerHTML = "<code>éæ³ç¨æ·!</code>";50 return false;51 }52 53 }, 54 error : function(data) { 55 document.getElementById("message").innerHTML = "<code>ask Failure 请æ±å¤±è´¥!</code>";56 } 57 }); 58 59 60 };61 document.getElementById("logout").onclick = function () {62 if (confirm("æ¨ç¡®å®è¦æ³¨éæ¬ç³»ç»åï¼")){63 deleteCookie("userid","/")64 deleteCookie("authorization","/")65 deleteCookie("login","/")66 deleteCookie("locked","/")67 68 addCookie("userid","",7,"/");69 addCookie("login","NO",7,"/");70 CloseWebPage();71 }...
Using AI Code Generation
1browser.addCookie({name: 'foo', value: 'bar'});2browser.deleteCookie('foo');3browser.deleteCookies();4browser.getCookies();5browser.getCookie('foo');6browser.addValue('#myInput', 'test');7browser.clearElement('#myInput');8browser.click('#myButton');9browser.doubleClick('#myButton');10browser.dragAndDrop('#elem1', '#elem2');11browser.elementIdClear('#myInput');12browser.elementIdClick('#myButton');13browser.elementIdDoubleClick('#myButton');14browser.elementIdValue('#myInput', 'test');15browser.getAttribute('#myInput', 'value');16browser.getHTML('#myInput');17browser.getLocation('#myInput');18browser.getLocationInView('#myInput');19browser.getTagName('#myInput');20browser.getText('#myInput');21browser.getValue('#myInput');22browser.isExisting('#myInput');23browser.isVisible('#myInput');24browser.moveTo('#myInput');25browser.saveScreenshot('/path/to/save/screenshot.png');
Using AI Code Generation
1browser.addCookie({2});3browser.deleteCookie('test');4browser.deleteCookies();5browser.getCookies();6browser.getCookie('test');7browser.getCookies();8browser.setCookie({9});10browser.setCookies([{11}, {12}]);13browser.setCookies({14}, {15});16browser.setCookies({17});18browser.setCookies([{19}]);20browser.setCookies([{21}, {22}]);23browser.setCookies({24}, {25});26browser.setCookies({27});28browser.setCookies([{29}]);30browser.setCookies([{31}, {32}]);33browser.setCookies({
Using AI Code Generation
1browser.addCookie({name: 'cookieName', value: 'cookieValue'});2browser.getCookies();3browser.getCookie('cookieName');4browser.deleteCookie('cookieName');5browser.deleteCookies();6### browser.url(url)7### browser.getTitle()8browser.getTitle();9### browser.waitForVisible(selector, ms, reverse)10browser.waitForVisible('#elemToWaitFor', 5000);11### browser.waitForExist(selector, ms, reverse)12browser.waitForExist('#elemToWaitFor', 5000);13### browser.waitForText(selector, ms, reverse)14browser.waitForText('#elemToWaitFor', 500
Using AI Code Generation
1browser.addCookie({2});3browser.deleteCookie('key');4browser.getCookie('key');5browser.getCookies();6browser.back();7browser.forward();8browser.refresh();9browser.getTitle();10browser.getUrl();11browser.pause(1000);12browser.saveScreenshot('screen.png');13browser.setViewportSize({14});15browser.setWindowSize(1024, 768);16browser.getSource();17browser.getHTML();18browser.getHTML('#some-element');19browser.getAttribute('.some-element', 'href');20browser.getAttribute('.some-element', 'href', function(err, result) {21});22browser.getCssProperty('.some-element', 'background-color');23browser.getCssProperty('.some-element', 'background-color', function(err, result) {24});25browser.getCssProperty('.some-element', 'background-color', function(err, result) {26});
Using AI Code Generation
1browser.addCookie({name: 'myCookie', value: '1234567890'});2browser.getCookie('myCookie').then(function(cookie){3 console.log(cookie);4});5browser.deleteCookie('myCookie');6browser.addCookie({name: 'myCookie', value: '1234567890'});7browser.getCookie('myCookie').then(function(cookie){8 console.log(cookie);9});10browser.deleteCookie('myCookie');11browser.addCookie({name: 'myCookie', value: '1234567890'});12browser.getCookie('myCookie').then(function(cookie){13 console.log(cookie);14});15browser.deleteCookie('myCookie');16browser.addCookie({name: 'myCookie', value: '1234567890'});17browser.getCookie('myCookie').then(function(cookie){18 console.log(cookie);19});20browser.deleteCookie('myCookie');21browser.addCookie({name: 'myCookie', value: '1234567890'});22browser.getCookie('myCookie').then(function(cookie){23 console.log(cookie);24});25browser.deleteCookie('myCookie');26browser.addCookie({name: 'myCookie', value: '1234567890'});27browser.getCookie('myCookie').then(function(cookie){28 console.log(cookie);29});30browser.deleteCookie('myCookie');
Using AI Code Generation
1browser.addCookie({2});3browser.deleteCookie('test');4browser.deleteCookies();5browser.getCookie('test');6browser.getCookies();7browser.setCookie({8});9browser.setCookies([{10}, {11}]);12browser.windowHandleMaximize();13browser.windowHandleSize({width: 1024, height: 768});14browser.windowHandlePosition({x: 0, y: 0});15browser.windowHandleFullscreen();
Using AI Code Generation
1var cookie = {2}3browser.addCookie(cookie);4browser.addCookie({name: 'myCookie', value: '12345'});5var cookie = browser.getCookie('myCookie');6console.log(cookie.value);7browser.deleteCookie('myCookie');8browser.deleteCookie();9browser.deleteCookie('myCookie');10describe('Cookie handling', function() {11 it('should set a cookie', function() {12 browser.addCookie({name: 'myCookie', value: '12345'});13 var cookie = browser.getCookie('myCookie');14 console.log(cookie.value);15 });16 it('should delete a cookie', function() {17 browser.addCookie({name: 'myCookie', value: '12345'});18 browser.deleteCookie('myCookie');19 var cookie = browser.getCookie('myCookie');20 console.log(cookie);21 });22});23var assert = require('chai').assert;24describe('Cookie handling', function() {25 it('should set a cookie', function() {26 browser.addCookie({name: 'myCookie', value: '12345'});27 var cookie = browser.getCookie('myCookie');28 console.log(cookie.value);29 assert(cookie.value === '12345');30 });31 it('should delete a cookie', function() {32 browser.addCookie({name: 'myCookie', value: '12345'});33 browser.deleteCookie('my
Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.
Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.
Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.
Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.
Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?
Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.
How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.
Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.
Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.
Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.
JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.
Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.
Get 100 minutes of automation test minutes FREE!!