How to use queryObjects method in Puppeteer

Best JavaScript code snippet using puppeteer

index.js

Source:index.js Github

copy

Full Screen

1<%2 //curUserID = 6605153029051275340; //Zayats3 //curUserID = 6605155987556877175; // Анапольский4 //curUserID = 6719946806941395578; //Асафов тест5 //curUserID = 6605156452417082406; // Асафов 6 //curUserID = 6711785032659205612; //Me test7 //curUserID = 6668363668628000564; //Me 8 //curUserID = 6605155785782208336; //Пудан9 //curUserID = 6605154398863757020; // my test10 //curUserID = 6719946806941395578; // Асафов тест11 /*try {12 curUserID;13 } catch(e) {14 curUserID = 6668363668628000564;15 }*/16 var _LearningsRequests = OpenCodeLib('x-local://wt/web/vsk/portal/boss-panel/server/utils/learningsRequests.js');17 DropFormsCache('x-local://wt/web/vsk/portal/boss-panel/server/utils/learningsRequests.js');18 var _Utils = OpenCodeLib('x-local://wt/web/vsk/portal/boss-panel/server/utils/utils.js');19 DropFormsCache('x-local://wt/web/vsk/portal/boss-panel/server/utils/utils.js');20 var _ActivateLearnings = OpenCodeLib('x-local://wt/web/vsk/portal/boss-panel/server/utils/activateLearnings.js');21 DropFormsCache('x-local://wt/web/vsk/portal/boss-panel/server/utils/activateLearnings.js');22 var Report = OpenCodeLib('x-local://wt/web/vsk/portal/boss-panel/server/utils/report.js');23 DropFormsCache('x-local://wt/web/vsk/portal/boss-panel/server/utils/report.js');24 function getUser(userId) {25 var us = ArrayOptFirstElem(XQuery("sql: \n\26 select \n\27 distinct(cs.id) id, \n\28 cs.role_id, \n\29 cs.code, \n\ 30 cs.fullname, \n\31 cs.position_name, \n\32 cs.position_parent_name, \n\33 cs.position_parent_id \n\34 from collaborators cs \n\35 inner join func_managers fm on fm.person_id = cs.id \n\36 inner join boss_types bt on bt.id = fm.boss_type_id \n\37 where \n\38 cs.id = " + userId + " \n\39 and cs.is_dismiss = 0 \n\40 and bt.code = 'main' \n\41 "));42 var userObj = undefined;43 if (us != undefined) {44 userObj = {45 id: Int(us.id),46 role_id: String(us.role_id),47 code: String(us.code),48 fullname: String(us.fullname),49 position_name: String(us.position_name),50 position_parent_name: String(us.position_parent_name),51 position_parent_id: Int(us.position_parent_id),52 is_admin: (String(us.role_id) == 'admin' ? true : false)53 }54 return userObj;55 }56 return userObj;57 }58 function getAllSubordinates(userId, subId){59 return XQuery("sql: \n\60 select \n\61 cs.id, \n\62 cs.fullname \n\63 from collaborators cs \n\64 inner join collaborator c on c.id = cs.id \n\65 cross apply c.data.nodes('/collaborator/path_subs') as t(p) \n\66 where \n\67 (t.p.exist('path_sub/id[(. cast as xs:string?) = \"" + subId + "\"]') = 1) \n\68 and cs.is_dismiss = 0 \n\69 and cs.id <> " + userId + " \n\70 ");71 }72 function get_User(){73 var q = getUser(curUserID);74 return _Utils.setSuccess(q);75 }76 function get_Subordinates(queryObjects) {77 var search = queryObjects.HasProperty('search') ? queryObjects.search : '';78 var subId = queryObjects.HasProperty('sub_id') ? OptInt(queryObjects.sub_id) : 0;79 var page = queryObjects.HasProperty('page') ? OptInt(queryObjects.page) : 1;80 var pageSize = queryObjects.HasProperty('page_size') ? OptInt(queryObjects.page_size) : 10;81 if (subId == 0 || subId == undefined) {82 return _Utils.setError('Не указано подразделение');83 }84 var min = (page - 1) * pageSize;85 var max = min + pageSize;86 87 var q = XQuery("sql: \n\88 declare @s varchar(max) = '" + search + "'; \n\89 select d.* \n\90 from ( \n\91 select \n\92 count(cs.id) over() total, \n\93 ROW_NUMBER() OVER (ORDER BY cs.fullname) AS [row_number], \n\94 cs.id, \n\95 cs.fullname, \n\96 cs.position_name, \n\97 cs.code, \n\98 cs.hire_date, \n\99 cs.dismiss_date, \n\100 cs.pict_url, \n\101 cast(t.p.query(' \n\102 for $PD in /collaborator/path_subs/path_sub \n\103 return concat(data($PD/name[1]), \" / \") \n\104 ') as varchar(max)) as structure \n\105 --t.p.query('/collaborator/path_subs') as structure \n\106 from collaborators cs \n\107 inner join collaborator c on c.id = cs.id \n\108 cross apply c.data.nodes('/collaborator/path_subs') as t(p) \n\109 where \n\110 (t.p.exist('path_sub/id[(. cast as xs:string?) = \"" + subId + "\"]') = 1) \n\111 and cs.is_dismiss = 0 \n\112 and cs.id <> " + curUserID + " \n\113 and cs.fullname like '%'+@s+'%' \n\114 ) d \n\115 where \n\116 d.[row_number] > " + min + " and d.[row_number] <= " + max + " \n\117 order by d.fullname asc \n\118 ");119 var total = 0;120 var fobj = ArrayOptFirstElem(q);121 if (fobj != undefined) {122 total = fobj.total;123 }124 var obj = {125 meta: {126 total: Int(total),127 pageSize: pageSize128 },129 subordinates: q130 }131 return _Utils.setSuccess(obj);132 }133 function get_Courses(queryObjects){134 var search = queryObjects.HasProperty('search') ? queryObjects.search : '';135 var page = queryObjects.HasProperty('page') ? OptInt(queryObjects.page) : 1;136 var pageSize = queryObjects.HasProperty('page_size') ? OptInt(queryObjects.page_size) : 10;137 var min = (page - 1) * pageSize;138 var max = min + pageSize;139 var q = XQuery("sql: \n\140 declare @s varchar(max) = '" + search + "'; \n\141 select \n\142 d.* \n\143 from ( \n\144 select \n\145 count(cs.id) over() total, \n\146 ROW_NUMBER() OVER (ORDER BY cs.name) AS [row_number], \n\147 cs.id, \n\148 cs.code, \n\149 cs.name title, \n\150 case cs.resource_id \n\151 when null then '' \n\152 else '/download_file.html?file_id=' + cast(cs.resource_id as varchar(30)) \n\153 end pict_url, \n\154 cs.status, \n\155 cs.max_score, \n\156 cs.yourself_start, \n\157 cs.duration \n\158 from courses cs \n\159 where \n\160 cs.name like '%'+@s+'%' \n\161 and cs.[status] <> 'secret' \n\162 ) d \n\163 where \n\164 d.[row_number] > " + min + " and d.[row_number] <= " + max + " \n\165 ");166 var total = 0;167 var fobj = ArrayOptFirstElem(q);168 if (fobj != undefined) {169 total = fobj.total;170 }171 var obj = {172 meta: {173 total: Int(total),174 pageSize: pageSize175 },176 learnings: q177 }178 return _Utils.setSuccess(obj);179 }180 function get_Assessments(queryObjects){181 var search = queryObjects.HasProperty('search') ? queryObjects.search : '';182 var page = queryObjects.HasProperty('page') ? OptInt(queryObjects.page) : 1;183 var pageSize = queryObjects.HasProperty('page_size') ? OptInt(queryObjects.page_size) : 10;184 var min = (page - 1) * pageSize;185 var max = min + pageSize;186 var q = XQuery("sql: \n\187 declare @s varchar(max) = '" + search + "'; \n\188 select \n\189 case d.resource_id \n\190 when null then '' \n\191 else '/download_file.html?file_id=' + cast(d.resource_id as varchar(30)) \n\192 end pict_url, \n\193 d.* \n\194 from ( \n\195 select \n\196 count(ats.id) over() total, \n\197 ROW_NUMBER() OVER (ORDER BY ats.title) AS [row_number], \n\198 ats.id, \n\199 ats.code, \n\200 ats.title, \n\201 ats.status, \n\202 ats.duration, \n\203 ats.passing_score, \n\204 R.cmp.query('resource_id').value('.', 'varchar(30)') resource_id \n\205 from assessments ats \n\206 inner join assessment as c_xml ON ats.id = c_xml.id \n\207 cross apply c_xml.data.nodes('/assessment') as R(cmp) \n\208 where \n\209 ats.title like '%'+@s+'%' \n\210 and ats.[status] <> 'secret' \n\211 ) d \n\212 where \n\213 d.[row_number] > " + min + " and d.[row_number] <= " + max + " \n\214 ");215 var total = 0;216 var fobj = ArrayOptFirstElem(q);217 if (fobj != undefined) {218 total = fobj.total;219 }220 var obj = {221 meta: {222 total: Int(total),223 pageSize: pageSize224 },225 learnings: q226 }227 return _Utils.setSuccess(obj);228 }229 function post_Courses(queryObjects){230 var data = tools.read_object(queryObjects.Body);231 var isAll = data.HasProperty('is_all') ? data.is_all : false;232 var cls = data.HasProperty('collaborators') ? data.collaborators : [];233 var crs = data.HasProperty('learnings') ? data.learnings : [];234 var isRequirePassing = data.HasProperty('is_require_settings_passing') ? data.is_require_settings_passing : false;235 var passingPeriod = data.HasProperty('selected_settings_passing_period') ? data.selected_settings_passing_period : 2;236 var settingsDate = data.HasProperty('settings_date') ? data.settings_date : null;237 if (crs.length == 0) {238 return _Utils.setError('Invalid parametres');239 }240 var errors = '';241 if (isAll) {242 cls = getAllSubordinates(curUserID, curUser.position_parent_id);243 }244 for (cr in crs) {245 for (cl in cls){246 try {247 _ActivateLearnings.activateCourseWithSettings(cl.id, cr.id, isRequirePassing, passingPeriod, settingsDate);248 } catch(e) {249 errors = errors + e;250 }251 }252 }253 return _Utils.setSuccess(null, errors);254 }255 function post_Assessments(queryObjects){256 var data = tools.read_object(queryObjects.Body);257 var isAll = data.HasProperty('is_all') ? data.is_all : false;258 var cls = data.HasProperty('collaborators') ? data.collaborators : [];259 var ats = data.HasProperty('learnings') ? data.learnings : [];260 var isRequirePassing = data.HasProperty('is_require_settings_passing') ? data.is_require_settings_passing : false;261 var passingPeriod = data.HasProperty('selected_settings_passing_period') ? data.selected_settings_passing_period : 2;262 var settingsDate = data.HasProperty('settings_date') ? data.settings_date : null;263 if (ats.length == 0) {264 return _Utils.setError('Invalid parametres');265 }266 var errors = '';267 if (isAll) {268 cls = getAllSubordinates(curUserID, OpenDoc(UrlFromDocID(curUserID)).TopElem.position_parent_id);269 }270 for (at in ats) {271 for (cl in cls){272 try {273 //alert('=====123=======');274 _ActivateLearnings.activateAssessmentWithSettings(cl.id, at.id, isRequirePassing, passingPeriod, settingsDate);275 } catch(e) {276 errors = errors + e;277 }278 }279 }280 return _Utils.setSuccess(null, errors);281 }282 function get_EventsReport(queryObjects) {283 var u = getUser(curUserID);284 if (u == undefined) {285 return _Utils.setError('Пользователь не найден или не является руководителем');286 }287 var ls = _LearningsRequests.getEvents(Int(u.position_parent_id));288 var excelPath = '';289 try {290 excelPath = Report.create(ls, [291 'Название',292 'Дата начала',293 'Дата окончания',294 'Категория мероприятия',295 'Блок',296 'Наименование компании-партнера (партнерский канал)',297 'Учебная программа',298 'Плановое/внеплановое обучение ',299 'Форма проведения',300 'Город проведения',301 'Место проведения',302 'Провайдер',303 'Продожительность в днях',304 'Продожительность',305 'Заказчик',306 'Ответственные за подготовку',307 'Преподаватели',308 'Максимальное количество участников',309 'Плановое количество участников (сотрудники ВСК и Агенты)',310 'Фактическое количество участников (сотрудники ВСК и Агенты)',311 'Планируемое количество участников (не сотрудников ВСК)',312 'Фактическое количество участников (не сотрудников ВСК)',313 'Статус',314 'Категория мероприятия',315 'ФИО обучаемых',316 'Примечание'317 ]);318 } catch(e) {319 alert('e: ' + e);320 return _Utils.setError(e);321 }322 323 Request.AddRespHeader('Content-Type', 'application/octet-stream');324 Request.AddRespHeader('Content-disposition', 'attachment; filename=report.xlsx');325 Request.AddRespHeader('set-cookie', 'downloadStarted=0; Expires=' + Date() + ';');326 return LoadFileData(excelPath);327 }328 function get_LearningsReport(queryObjects) {329 var _subordinates = [];330 var _learnings = [];331 if (queryObjects.HasProperty('subordinates')) {332 var _s = queryObjects.subordinates;333 if (Trim(_s) != '') {334 _subordinates = _s.split(',');335 }336 }337 if (queryObjects.HasProperty('learnings')) {338 var _l = queryObjects.learnings;339 if (Trim(_l) != '') {340 _learnings = _l.split(',');341 }342 }343 var isAllSubordinates = queryObjects.HasProperty('is_all_subordinates') ? _Utils.strToBool(queryObjects.is_all_subordinates) : true;344 var isAllLearnings = queryObjects.HasProperty('is_all_learnings') ? _Utils.strToBool(queryObjects.is_all_learnings) : true;345 var u = getUser(curUserID);346 if (u == undefined) {347 return _Utils.setError('Пользователь не найден или не является руководителем');348 }349 var ls = _LearningsRequests.getLearnings(Int(u.position_parent_id), _subordinates, _learnings, isAllSubordinates, isAllLearnings);350 var excelPath = '';351 try {352 excelPath = Report.create(ls, [353 'ФИО',354 'Подразделение',355 'Должность',356 'Название',357 'Дата начала',358 'Дата последнего посещения',359 'Дата планируемого завершения',360 'Процент выполнения',361 'Статус',362 'Обязательно к прохождению',363 'Подразделение 1',364 'Подразделение 2',365 'Подразделение 3',366 'Подразделение 4',367 'Подразделение 5',368 'Подразделение 6',369 'Подразделение 7',370 'Подразделение 8'371 ]);372 } catch(e) {373 alert('e: ' + e);374 return _Utils.setError(e);375 }376 377 Request.AddRespHeader('Content-Type', 'application/octet-stream');378 Request.AddRespHeader('Content-disposition', 'attachment; filename=report.xlsx');379 Request.AddRespHeader('set-cookie', 'downloadStarted=0; Expires=' + Date() + ';');380 return LoadFileData(excelPath);381 }382 function get_TestLearningsReport(queryObjects) {383 var _subordinates = [];384 var _learnings = [];385 if (queryObjects.HasProperty('subordinates')) {386 var _s = queryObjects.subordinates;387 if (Trim(_s) != '') {388 _subordinates = _s.split(',');389 }390 }391 if (queryObjects.HasProperty('learnings')) {392 var _l = queryObjects.learnings;393 if (Trim(_l) != '') {394 _learnings = _l.split(',');395 }396 }397 var isAllSubordinates = queryObjects.HasProperty('is_all_subordinates') ? _Utils.strToBool(queryObjects.is_all_subordinates) : true;398 var isAllLearnings = queryObjects.HasProperty('is_all_learnings') ? _Utils.strToBool(queryObjects.is_all_learnings) : true;399 var u = getUser(curUserID);400 if (u == undefined) {401 return _Utils.setError('Пользователь не найден или не является руководителем');402 }403 var tls = _LearningsRequests.getTestLearnings(Int(u.position_parent_id), _subordinates, _learnings, isAllSubordinates, isAllLearnings);404 var excelPath = '';405 try {406 excelPath = Report.create(tls, [407 'ФИО',408 'Подразделение',409 'Должность',410 'Название',411 'Дата начала',412 'Дата последнего посещения',413 'Дата планируемого завершения',414 'Процент выполнения',415 'Статус',416 'Обязательно к прохождению',417 'Подразделение 1',418 'Подразделение 2',419 'Подразделение 3',420 'Подразделение 4',421 'Подразделение 5',422 'Подразделение 6',423 'Подразделение 7',424 'Подразделение 8'425 ]);426 } catch(e) {427 alert('e: ' + e);428 return _Utils.setError(e);429 }430 431 Request.AddRespHeader('Content-Type', 'application/octet-stream');432 Request.AddRespHeader('Content-disposition', 'attachment; filename=report.xlsx');433 Request.AddRespHeader('set-cookie', 'downloadStarted=0; Expires=' + Date() + ';');434 return LoadFileData(excelPath);435 }436 function post_UploadCoursesFile(queryObjects) {437 var formData = queryObjects.Request.Form;438 var file = formData.file;439 var tempFilePath = UserDataDirectoryPath() + '\\datex_user_temp\\' + curUserID;440 var filePath = '';441 try {442 ObtainDirectory(tempFilePath, true);443 filePath = tempFilePath + '\\' + DateToRawSeconds(Date()) + '.xls';444 PutFileData(filePath, file);445 Request.Session.boss_panel = {};446 Request.Session.boss_panel.file_upload_path = filePath;447 var info = _ActivateLearnings.getCoursesInfoByFile(filePath);448 return _Utils.setSuccess(info);449 } catch(e) {450 return _Utils.setError(e);451 }452 }453 function post_UploadAssementsFile(queryObjects) {454 var formData = queryObjects.Request.Form;455 var file = formData.file;456 var tempFilePath = UserDataDirectoryPath() + '\\datex_user_temp\\' + curUserID;457 var filePath = '';458 try {459 ObtainDirectory(tempFilePath, true);460 filePath = tempFilePath + '\\' + DateToRawSeconds(Date()) + '.xls';461 PutFileData(filePath, file);462 Request.Session.boss_panel = {};463 Request.Session.boss_panel.file_upload_path = filePath;464 //alert(tools.object_to_text(Request.Session, 'json'));465 var info = _ActivateLearnings.getAssessmentsInfoByFile(filePath);466 return _Utils.setSuccess(info);467 } catch(e) {468 return _Utils.setError(e);469 }470 }471 function post_ActivateCoursesByFile(queryObjects) {472 var filePath = null;473 var mode = Request.Session.GetOptProperty('boss_panel');474 if (mode != undefined) {475 filePath = mode.GetOptProperty('file_upload_path');476 }477 if (filePath != undefined && filePath != null) {478 var data = tools.read_object(queryObjects.Body);479 var isRequirePassing = data.HasProperty('is_require_settings_passing') ? data.is_require_settings_passing : false;480 var passingPeriod = data.HasProperty('selected_settings_passing_period') ? data.selected_settings_passing_period : 2;481 var settingsDate = data.HasProperty('settings_date') ? data.settings_date : null;482 var rObj = _ActivateLearnings.activateCoursesByFile(filePath, isRequirePassing, passingPeriod, settingsDate);483 return _Utils.setSuccess(rObj);484 }485 return _Utils.setError('Неизвестная ошибка');486 }487 function post_ActivateAssementsByFile(queryObjects) {488 var filePath = null;489 var mode = Request.Session.GetOptProperty('boss_panel');490 if (mode != undefined) {491 filePath = mode.GetOptProperty('file_upload_path');492 }493 if (filePath != undefined && filePath != null) {494 var data = tools.read_object(queryObjects.Body);495 var isRequirePassing = data.HasProperty('is_require_settings_passing') ? data.is_require_settings_passing : false;496 var passingPeriod = data.HasProperty('selected_settings_passing_period') ? data.selected_settings_passing_period : 2;497 var settingsDate = data.HasProperty('settings_date') ? data.settings_date : null;498 var rObj = _ActivateLearnings.activateAssessmentsByFile(filePath, isRequirePassing, passingPeriod, settingsDate);499 return _Utils.setSuccess(rObj);500 }501 /*var data = tools.read_object(queryObjects.Body);502 var isRequirePassing = data.HasProperty('is_require_settings_passing') ? data.is_require_settings_passing : false;503 var passingPeriod = data.HasProperty('selected_settings_passing_period') ? data.selected_settings_passing_period : 2;504 var settingsDate = data.HasProperty('settings_date') ? data.settings_date : null;505 var rObj = _ActivateLearnings.activateAssessmentsByFile('E:\\WebSoft\\WebTutorServer\\datex_user_temp\\6719946806941395578\\1583922249.xls', isRequirePassing, passingPeriod, settingsDate);506 return _Utils.setSuccess(rObj);*/507 return _Utils.setError('Неизвестная ошибка');508 }...

Full Screen

Full Screen

query-objects.js

Source:query-objects.js Github

copy

Full Screen

...17 });18 for (let i = 0; i < 2; ++i) {19 InspectorTest.log('Create object with class Foo.');20 Protocol.Runtime.evaluate({expression: 'new Foo()'});21 await queryObjects(session, objectId, 'Foo');22 }23 session.disconnect();24 },25 async function testDerivedNewClass() {26 let contextGroup = new InspectorTest.ContextGroup();27 let session = contextGroup.connect();28 let Protocol = session.Protocol;29 InspectorTest.log('Declare class Foo & store its constructor.');30 Protocol.Runtime.evaluate({expression: 'class Foo{};'});31 let {result:{result:{objectId}}} = await Protocol.Runtime.evaluate({32 expression: 'Foo.prototype'33 });34 let fooConstructorId = objectId;35 InspectorTest.log('Declare class Boo extends Foo & store its constructor.');36 Protocol.Runtime.evaluate({expression: 'class Boo extends Foo{};'});37 ({result:{result:{objectId}}} = await Protocol.Runtime.evaluate({38 expression: 'Boo.prototype'39 }));40 let booConstructorId = objectId;41 await queryObjects(session, fooConstructorId, 'Foo');42 await queryObjects(session, booConstructorId, 'Boo');43 InspectorTest.log('Create object with class Foo');44 Protocol.Runtime.evaluate({expression: 'new Foo()'});45 await queryObjects(session, fooConstructorId, 'Foo');46 InspectorTest.log('Create object with class Boo');47 Protocol.Runtime.evaluate({expression: 'new Boo()'});48 await queryObjects(session, fooConstructorId, 'Foo');49 await queryObjects(session, booConstructorId, 'Boo');50 session.disconnect();51 },52 async function testNewFunction() {53 let contextGroup = new InspectorTest.ContextGroup();54 let session = contextGroup.connect();55 let Protocol = session.Protocol;56 InspectorTest.log('Declare Foo & store it.');57 Protocol.Runtime.evaluate({expression: 'function Foo(){}'});58 let {result:{result:{objectId}}} = await Protocol.Runtime.evaluate({59 expression: 'Foo.prototype'60 });61 for (let i = 0; i < 2; ++i) {62 InspectorTest.log('Create object using Foo.');63 Protocol.Runtime.evaluate({expression: 'new Foo()'});64 await queryObjects(session, objectId, 'Foo');65 }66 session.disconnect();67 },68 async function testNonInspectable() {69 let contextGroup = new InspectorTest.ContextGroup();70 let session = contextGroup.connect();71 let Protocol = session.Protocol;72 InspectorTest.log('Declare Foo & store it.');73 Protocol.Runtime.evaluate({expression: 'function Foo(){}'});74 let {result:{result:{objectId}}} = await Protocol.Runtime.evaluate({75 expression: 'Foo.prototype'76 });77 InspectorTest.log('Create object using Foo.');78 Protocol.Runtime.evaluate({expression: 'a = new Foo()'});79 await queryObjects(session, objectId, 'Foo');80 InspectorTest.log('Mark object as not inspectable.')81 Protocol.Runtime.evaluate({expression: 'inspector.markObjectAsNotInspectable(a)'});82 await queryObjects(session, objectId, 'Foo');83 session.disconnect();84 },85 async function testObjectCreate() {86 let contextGroup = new InspectorTest.ContextGroup();87 let session = contextGroup.connect();88 let Protocol = session.Protocol;89 InspectorTest.log('Declare Object p & store it.');90 let {result:{result:{objectId}}} = await Protocol.Runtime.evaluate({91 expression: 'p = {a:1}'92 });93 for (let i = 0; i < 2; ++i) {94 InspectorTest.log('Create object using Object.create(p).');95 Protocol.Runtime.evaluate({expression: 'Object.create(p)'});96 await queryObjects(session, objectId, 'p');97 }98 session.disconnect();99 },100 async function testWithObjectGroup() {101 let contextGroup = new InspectorTest.ContextGroup();102 let session = contextGroup.connect();103 let Protocol = session.Protocol;104 let {result:{result:{objectId}}} = await Protocol.Runtime.evaluate({105 expression: 'Array.prototype'106 });107 let initialArrayCount;108 const N = 3;109 InspectorTest.log(`Query for Array.prototype ${N} times`);110 for (let i = 0; i < N; ++i) {111 const {result:{objects}} = await Protocol.Runtime.queryObjects({112 prototypeObjectId: objectId,113 objectGroup: 'console'114 });115 logCountSinceInitial(objects.description);116 }117 await Protocol.Runtime.releaseObjectGroup({objectGroup: 'console'});118 InspectorTest.log('\nReleased object group.');119 const {result:{objects}} = await Protocol.Runtime.queryObjects({120 prototypeObjectId: objectId,121 objectGroup: 'console'122 });123 logCountSinceInitial(objects.description);124 session.disconnect();125 function logCountSinceInitial(description) {126 const count = parseInt(/Array\((\d+)\)/.exec(description)[1]);127 if (typeof initialArrayCount === 'undefined')128 initialArrayCount = count;129 InspectorTest.logMessage(`Results since initial: ${count - initialArrayCount}`);130 }131 },132]);133const constructorsNameFunction = `134function() {135 return this.map(o => o.constructor.name + ',' + typeof o).sort();136}`;137async function queryObjects(sesion, prototypeObjectId, name) {138 let {result:{objects}} = await sesion.Protocol.Runtime.queryObjects({139 prototypeObjectId140 });141 InspectorTest.log(`Query objects with ${name} prototype.`);142 let {result:{result:{value}}} = await sesion.Protocol.Runtime.callFunctionOn({143 objectId: objects.objectId,144 functionDeclaration: constructorsNameFunction,145 returnByValue: true146 });147 InspectorTest.log('Dump each object constructor name.');148 InspectorTest.logMessage(value);...

Full Screen

Full Screen

loadStudy.js

Source:loadStudy.js Github

copy

Full Screen

...6network_questions = new Object;7expressions = new Object;8function getInterviewIds(intId){9 var egoValue = db.queryValue("SELECT VALUE FROM answer WHERE CONCAT(',', interviewId, ',') LIKE '%," + intId + ",%' AND questionID = " + study.MULTISESSIONEGOID);10 column = db.queryObjects("SELECT ID FROM question WHERE title = (SELECT q.title FROM question q WHERE q.ID = " + study.MULTISESSIONEGOID + ")").data;11 var multiIds = [];12 for (var k in column){13 multiIds.push(column[k].ID)14 }15 column = db.queryObjects("SELECT INTERVIEWID FROM answer WHERE questionId in (" + multiIds.join(",") + ") AND value = '" + egoValue + "'" ).data;16 var interviewIds = [];17 for (var k in column){18 interviewIds.push(column[k].INTERVIEWID)19 }20 return interviewIds;21}22function loadStudy(id, intId){23 study = db.queryRowObject("SELECT * FROM study WHERE id = " + id);24 ego_id_questions = db.queryObjects("SELECT * FROM question WHERE subjectType = 'EGO_ID' AND studyId = " + id + " ORDER BY ORDERING").data;25 ego_questions = db.queryObjects("SELECT * FROM question WHERE subjectType = 'EGO' AND studyId = " + id + " ORDER BY ORDERING").data;26 alter_questions = db.queryObjects("SELECT * FROM question WHERE subjectType = 'ALTER' AND studyId = " + id + " ORDER BY ORDERING").data;27 alter_pair_questions = db.queryObjects("SELECT * FROM question WHERE subjectType = 'ALTER_PAIR' AND studyId = " + id + " ORDER BY ORDERING").data;28 network_questions = db.queryObjects("SELECT * FROM question WHERE subjectType = 'NETWORK' AND studyId = " + id + " ORDER BY ORDERING").data;29 options = db.queryObjects("SELECT * FROM questionOption WHERE studyId = " + id + " ORDER BY ORDERING").data;30 expressions = db.queryObjects("SELECT * FROM expression WHERE studyId = " + id).data;31 if(intId == null){32 loadFirst(id, 0, null);33 }else{34 interviewId = intId;35 page = db.queryValue("SELECT completed FROM interview WHERE id = " + intId);36 if(typeof study.MULTISESSIONEGOID != "undefined" && parseInt(study.MULTISESSIONEGOID) != 0){37 var interviewIds = getInterviewIds(intId);38 answers = db.queryObjects("SELECT * FROM answer WHERE interviewId in (" + interviewIds.join(",") + ")").data;39 }else{40 answers = db.queryObjects("SELECT * FROM answer WHERE interviewId = " + intId).data;41 }42 for (k in answers){43 if(answers[k].QUESTIONTYPE == "ALTER")44 array_id = answers[k].QUESTIONID + "-" + answers[k].ALTERID1;45 else if(answers[k].QUESTIONTYPE == "ALTER_PAIR")46 array_id = answers[k].QUESTIONID + "-" + answers[k].ALTERID1 + "and" + answers[k].ALTERID2;47 else48 array_id = answers[k].QUESTIONID;49 answers[k].ID = parseInt(answers[k].ID);50 console.log(answers[k]);51 model[array_id] = answers[k];52 }53 if(page == -1)54 page = 0;55 loadFirst(id, page, intId);56 }57}58function getInterviewName(studyId){59 var whole_name = db.queryValue("SELECT name FROM study WHERE id = " + studyId) + " (" + db.queryValue("SELECT modified FROM study WHERE id = " + studyId) + ")";60 return whole_name;61}62function getEgoIdValue(interviewId){63 var studyId = db.queryValue("SELECT studyID FROM interview WHERE id = " + interviewId);64 var egoIdQs = db.queryObjects("SELECT * FROM question WHERE studyId = " + studyId + " AND subjectType = 'EGO_ID' ORDER BY ORDERING").data;65 var egoId = "";66 for(var k in egoIdQs){67 if(egoId)68 egoId = egoId + "_";69 egoId = egoId + db.queryValue("SELECT value FROM answer WHERE questionId = " + egoIdQs[k].ID + " AND interviewId = " + interviewId);70 }71 return egoId;...

Full Screen

Full Screen

ComicPageBrowserScript.js

Source:ComicPageBrowserScript.js Github

copy

Full Screen

1function NextPage() {2 document.getElementById("ComicLeaf").src = RewriteComicSource("Next");3}4function PrevPage() {5 document.getElementById("ComicLeaf").src = RewriteComicSource("Previous");6}7function RewriteComicSource(request) {8 //update Comic Image source9 var baseurl = "https://www.de-baay.nl/ComicCloud/";10 var queryObjects = {11 file: getQueryVariable('file'),12 page: parseInt(getQueryVariable('page'), 10),13 size: parseInt(getQueryVariable('size'), 10),14 };15 if (request == "Next") { 16 queryObjects.page = queryObjects.page + 1; 17 }18 else {19 queryObjects.page = queryObjects.page - 1;20 }21 var queryString = Object.keys(queryObjects).map(key => key + '=' + queryObjects[key]).join('&');22 var URL = baseurl + "?" + queryString;23 //update URL24 var documentTitle = document.title;25 var pathArray = window.location.pathname.split('/');26 pathArray.shift();27 pathArray[pathArray.length - 1] = queryObjects.page;28 var newPathname = "";29 for (i = 0; i < pathArray.length; i++) {30 newPathname += "/";31 newPathname += pathArray[i];32 }33 window.history.pushState(null, documentTitle, newPathname);34 return URL;35}36function getQueryVariable(variable) {37 var query = document.getElementById("ComicLeaf").src.split("?")[1];38 var vars = query.split('&');39 for (var i = 0; i < vars.length; i++) {40 var pair = vars[i].split('=');41 if (decodeURIComponent(pair[0]) == variable) {42 return decodeURIComponent(pair[1]);43 }44 }45 console.log('Query variable %s not found', variable);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1(async () => {2 const browser = await puppeteer.launch();3 const page = await browser.newPage();4 await page.waitForSelector('input[name="q"]');5 await page.type('input[name="q"]', 'puppeteer');6 await page.click('input[type="submit"]');7 await page.waitForSelector('h3');8 const results = await page.$$eval('h3', links => links.map(link => link.textContent));9 console.log(results);

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require("puppeteer");2async function main() {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 const objects = await page.queryObjects("div");6 console.log(objects.length);7 await browser.close();8}9main();

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Puppeteer automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful