How to use LoadTarget method in wpt

Best JavaScript code snippet using wpt

basic-popup-and-iframe-tests.https.js

Source:basic-popup-and-iframe-tests.https.js Github

copy

Full Screen

...90 eSecureIfCreatorSecure,91 eResultFromExaminationSync),92];93const loadTargets = [94 new LoadTarget("an iframe", eLoadInUnsandboxedIframe),95 new LoadTarget("a sandboxed iframe", eLoadInSandboxedIframe),96 new LoadTarget("a popup", eLoadInPopup),97];98function LoadType(description, loadInFlags, uri, expectedSecureFlag, resultFrom) {99 this.desc = description;100 this.loadInFlags = loadInFlags;101 this.uri = uri;102 this.expectedSecureFlag = expectedSecureFlag;103 this.resultFrom = resultFrom;104}105function LoadTarget(description, loadInFlag) {106 this.desc = description;107 this.loadInFlag = loadInFlag;108}109LoadTarget.prototype.open = function(loadType) {110 let loadTarget = this;111 this.currentTest.step(function() {112 assert_true((loadTarget.loadInFlag & loadType.loadInFlags) != 0,113 loadType.desc + " cannot be tested in " + loadTarget.desc);114 });115 if (this.loadInFlag == eLoadInUnsandboxedIframe) {116 let iframe = document.createElement("iframe");117 document.body.appendChild(iframe);118 iframe[loadType.desc == "a srcdoc" ? "srcdoc" : "src"] = loadType.uri;119 return iframe;...

Full Screen

Full Screen

agent_models.py

Source:agent_models.py Github

copy

Full Screen

1# !/usr/bin/env python2# -*- coding:utf-8 _*-3# @Author: swang4# @Contact: wang00sheng@gmail.com5# @Project Name: D3QN6# @File: A2C.py7# @Time: 2021/10/29/22:548# @Software: PyCharm9import os10import numpy as np11import tensorflow as tf12import tensorflow.keras as keras13from tensorflow.keras.models import Model, Sequential14from tensorflow.keras.layers import Dense, Activation, Input, Conv2D, Flatten, Lambda, Add, BatchNormalization, Reshape15import tensorflow_probability as tfp16def FeatureExtractor(model_dir='../model/base_model/'):17 '''18 initialize a feature extractor for a d3qn RL agent.19 '''20 ckpt_dir = os.path.join(model_dir, 'feature_extractor', 'ckpt')21 fe = tf.keras.models.load_model(ckpt_dir)22 fe.trainable = False23 fe.compile()24 25 print('-' * 20, 'ResCNN_feature_extractor', '-' * 20, )26 fe.summary()27 28 return fe29def D3QN_Classifier(dueling=True, base_model_dir='../model/base_model/', loadTarget=False,30 load_d3qn_model=False, d3qn_model_dir='../model/d3qn_model/', based_on_base_model=True):31 def __init_d3qn_model__():32 print('-' * 20, 'Initializing a new D3QN model...', '-' * 20, )33 if based_on_base_model:34 print('-' * 20, 'Based on base_model\'s classifier...', '-' * 20, )35 base_classifier = tf.keras.models.load_model(base_ckpt_dir)36 conv, reshape = base_classifier.layers37 # input = base_classifier.input38 # base_classifier = Model(inputs=input, outputs=reshape(conv(input)))39 40 else:41 print('-' * 20, 'Even the classifier is initialized randomly...', '-' * 20, )42 base_classifier = Sequential([43 Input(shape=(30, 8, 82), name='feature_input'),44 Conv2D(1, kernel_size=(30, 1), strides=(1, 1), padding='valid', use_bias=True),45 Reshape((-1,)), ],46 name='output_conv')47 48 if dueling:49 # ------------------------------------- value network -------------------------------------------------#50 state_value = Conv2D(1, kernel_size=(30, 1), strides=(1, 1), padding='valid', use_bias=True,51 name='value_conv')(base_classifier.input)52 # state_value = BatchNormalization(axis=-1)(state_value)53 state_value = Reshape((-1,), name='value_reshape')(state_value)54 state_value = Dense(1, name='value_dense')(state_value)55 56 # ------------------------------------- advantage network -------------------------------------------------#57 action_advantage = base_classifier.output58 # kernel_constraint=max_norm(norm_rate))(feature_extraction.output)59 60 # ------------------------------------- add -------------------------------------------------#61 output = Add()([state_value, action_advantage])62 else:63 output = base_classifier.output64 # outputs = tf.keras.layers.Multiply()([output, [1, 1. / 2460]])65 output = Lambda(lambda x: x / 2460.)(output)66 return Model(inputs=base_classifier.input, outputs=output)67 68 def __load_d3qn_model__():69 try:70 print('-' * 20, 'Loading pre-trained D3QN classifier...', '-' * 20, )71 return tf.keras.models.load_model(d3qn_ckpt_dir)72 except Exception as e:73 print('Warning:', e)74 print('-' * 20, 'Fail to load the pre-trained D3QN model! An initialized model will be used!',75 '-' * 20, )76 return __init_d3qn_model__()77 78 # ------------------------------------- main procedure -------------------------------------------------#79 base_ckpt_dir = os.path.join(base_model_dir, 'classifier', 'ckpt')80 if loadTarget:81 d3qn_ckpt_dir = os.path.join(d3qn_model_dir, 'classifier', 'target_ckpt')82 else:83 d3qn_ckpt_dir = os.path.join(d3qn_model_dir, 'classifier', 'ckpt')84 85 if load_d3qn_model:86 d3qn_model = __load_d3qn_model__()87 else:88 d3qn_model = __init_d3qn_model__()89 90 if loadTarget:91 print('-' * 20, 'd3qn_target_classifier', '-' * 20, )92 else:93 print('-' * 20, 'd3qn_classifier', '-' * 20, )94 d3qn_model.summary()95 96 return d3qn_model97def SAC_actor(base_model_dir='../model/base_model/',98 load_sac_model=False, sac_model_dir='../model/sac_model/', based_on_base_model=True):99 def __init_sac_actor__():100 print('-' * 20, 'Initializing a new SAC_actor...', '-' * 20, )101 if based_on_base_model:102 print('-' * 20, 'Based on base_model\'s classifier...', '-' * 20, )103 base_classifier = tf.keras.models.load_model(base_ckpt_dir)104 else:105 print('-' * 20, 'Even the classifier is initialized randomly...', '-' * 20, )106 base_classifier = Sequential([107 Input(shape=(30, 8, 82), name='feature_input'),108 Conv2D(1, kernel_size=(30, 1), strides=(1, 1), padding='valid', use_bias=True),109 BatchNormalization(axis=-1), Reshape((-1,)), ],110 name='output_conv')111 112 output = Activation('softmax', name='softmax')(base_classifier.output)113 114 return Model(inputs=base_classifier.input, outputs=output)115 116 def __load_sac_actor__():117 try:118 print('-' * 20, 'Loading pre-trained sac_actor...', '-' * 20, )119 return tf.keras.models.load_model(sac_ckpt_dir)120 except Exception as e:121 print('Warning:', e)122 print('-' * 20, 'Fail to load the pre-trained sac_actor! An initialized model will be used!',123 '-' * 20, )124 return __init_sac_actor__()125 126 # ------------------------------------- main procedure -------------------------------------------------#127 base_ckpt_dir = os.path.join(base_model_dir, 'classifier', 'ckpt')128 sac_ckpt_dir = os.path.join(sac_model_dir, 'actor', 'ckpt')129 130 if load_sac_model:131 sac_actor = __load_sac_actor__()132 else:133 sac_actor = __init_sac_actor__()134 135 print('-' * 20, 'sac_actor', '-' * 20, )136 sac_actor.summary()137 138 return sac_actor139def SAC_critic(base_model_dir='../model/base_model/', load_sac_model=False, sac_model_dir='../model/sac_model/',140 based_on_base_model=True, index=None, loadTarget=False):141 def __init_sac_critic__():142 print('-' * 20, 'Initializing a new SAC_critic...', '-' * 20, )143 if based_on_base_model:144 print('-' * 20, 'Based on base_model\'s classifier...', '-' * 20, )145 base_classifier = tf.keras.models.load_model(base_ckpt_dir)146 else:147 print('-' * 20, 'Even the classifier is initialized randomly...', '-' * 20, )148 base_classifier = Sequential([149 Input(shape=(30, 8, 82), name='feature_input'),150 Conv2D(1, kernel_size=(30, 1), strides=(1, 1), padding='valid', use_bias=True),151 Reshape((-1,)), ],152 name='output_conv')153 154 return Model(inputs=base_classifier.input, outputs=base_classifier.output)155 156 def __load_sac_critic__():157 try:158 if loadTarget:159 print('-' * 20, 'Loading pre-trained target sac_critic...', '-' * 20, )160 else:161 print('-' * 20, 'Loading pre-trained sac_critic...', '-' * 20, )162 return tf.keras.models.load_model(sac_ckpt_dir)163 except Exception as e:164 print('Warning:', e)165 print('-' * 20, 'Fail to load the pre-trained sac_critic! An initialized model will be used!',166 '-' * 20, )167 return __init_sac_critic__()168 169 # ------------------------------------- main procedure -------------------------------------------------#170 base_ckpt_dir = os.path.join(base_model_dir, 'classifier', 'ckpt')171 if loadTarget:172 if index is None:173 sac_ckpt_dir = os.path.join(sac_model_dir, 'critic', 'target_ckpt')174 else:175 sac_ckpt_dir = os.path.join(sac_model_dir, 'critic', 'target_ckpt_' + str(index))176 else:177 if index is None:178 sac_ckpt_dir = os.path.join(sac_model_dir, 'critic', 'ckpt')179 else:180 sac_ckpt_dir = os.path.join(sac_model_dir, 'critic', 'ckpt_' + str(index))181 182 if load_sac_model:183 sac_critic = __load_sac_critic__()184 else:185 sac_critic = __init_sac_critic__()186 187 print('-' * 20, 'sac_critic', '-' * 20, )188 sac_critic.summary()189 190 return sac_critic191if __name__ == '__main__':192 print('Hello World!')193 os.environ['CUDA_VISIBLE_DEVICES'] = '-1'194 195 fe = FeatureExtractor()196 cls = D3QN_Classifier(based_on_base_model=True)197 cls = SAC_actor(based_on_base_model=True)198 cls = SAC_critic(based_on_base_model=True)199 ...

Full Screen

Full Screen

Add_Data.py

Source:Add_Data.py Github

copy

Full Screen

1'''2Created on Oct 12, 20153@author: kyleg4'''5if __name__ == '__main__':6 pass7def main():8 pass9 #LoadARegion()10 LoadAliasTables()11def LoadARegion():12 from arcpy import Append_management, ListFeatureClasses, ListDatasets, env, ListTables13 #importGDB = r"//gisdata/planning/Cart/projects/Conflation/GIS_DATA/GEO_COMM/REGION3_20151002/REGION3_20151002.gdb"14 #importGDB = r"\\gisdata\planning\Cart\projects\Conflation\GIS_DATA\GEO_COMM\REGION4_20151021\REGION4_20151021\REGION4_20151021.gdb"15 importGDB = r"\\gisdata\planning\Cart\projects\Conflation\GIS_DATA\GEO_COMM\REGION5_20151211\REGION5_20151211.gdb"16 LoadTarget = r"\\gisdata\planning\Cart\projects\Conflation\Workflow\conflation_sqlgis_geo.sde\Conflation.GEO."17 env.workspace = importGDB18 ### There are no tables in the conflated dataset products - handle similarly and separately19 skiplist = ['Stitch_Lines', 'RoadCenterlines', 'Overlaps_Gaps_MunicipalBoundary', 'Overlaps_Gaps_FIRE', 'Overlaps_Gaps_LAW', 'Overlaps_Gaps_PSAP', 'Overlaps_Gaps_ESZ', 'Overlaps_Gaps_EMS', 'Overlaps_Gaps_CountyBoundary', 'Overlaps_Gaps_AuthoritativeBoundary']20 tables = ListTables()21 for table in tables:22 print table23 target = LoadTarget+table24 print target25 26 datasets = ListDatasets("*")27 for fd in datasets:28 print fd29 featureClasses = ListFeatureClasses("*", "All", fd)30 for fc in featureClasses:31 print fc32 if fc in skiplist:33 print 'skipping'34 else:35 target = LoadTarget+fd+"/"+fc36 print "loading to "+target37 Append_management(fc, target, schema_type="NO_TEST")38 39def LoadAliasTables():40 from arcpy import Append_management, env, ListTables, ListWorkspaces, CalculateField_management41 importFolder = r"\\gisdata\planning\Cart\projects\Conflation\GIS_DATA\R1\Alias3"42 LoadTarget = r"Database Connections\Conflation2012_sde.sde\Conflation.SDE.RoadAlias"43 env.workspace = importFolder44 GDBList = []45 for gdb in ListWorkspaces("*", "FileGDB"):46 GDBList.append(gdb)47 48 for geodatabase in GDBList:49 env.workspace = geodatabase50 tables = ListTables("RoadAlias")51 for table in tables:52 print table53 CalculateField_management(table, "SEGID", expression="""[STEWARD]&" "& [SEGID]""", expression_type="VB", code_block="")54 Append_management(table, LoadTarget, schema_type="NO_TEST")55 print geodatabase56 57 58 59''' 60 61 ### There are no tables in the conflated dataset products62 tables = ListTables()63 for table in tables:64 print table65 target = LoadTarget+table66 print target67 68 datasets = ListDatasets("*")69 for fd in datasets:70 print fd71 featureClasses = ListFeatureClasses("*", "All", fd)72 for fc in featureClasses:73 print fc74 if fc in skiplist:75 print 'skipping'76 else:77 target = LoadTarget+fd+"/"+fc78 print "loading to "+target79 Append_management(fc, target, schema_type="NO_TEST")80'''...

Full Screen

Full Screen

script_DashPart_Detail.js

Source:script_DashPart_Detail.js Github

copy

Full Screen

1let loadTarget = document.querySelector(".loading")23function show_loading(){4 loadTarget.style.display = "block";5 loadTarget.style.opacity = 1;6}7function hide_loading(){8 //loadTarget.style.display = "none";9 let loadEffect = setInterval(() => {10 if(!loadTarget.style.opacity) {11 loadTarget.style.opacity = 1;12 }13 if (loadTarget.style.opacity > 0){14 loadTarget.style.opacity -= 0.1;15 } else {16 clearInterval(loadEffect)17 loadTarget.style.display = "none"18 }19 },100)20}21function tampil_data(){22 show_loading()23 fetch("http://192.168.18.68:8055/items/order?fields=customer_id.customer_id,customer_id.customer_name,ticket_id.ticket_id,ticket_id.ticket_type&filter[customer_id]=2")24 .then((response) => response.json())25 .then((response) => {26 response.map(data => {27 //var textNode = document.createTextNode(response.)28 })29 }) ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = wpt('WPT_API_KEY');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 test.loadTarget(data.data.testId, {location: 'ec2-us-west-1:Firefox'}, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 }13 });14 }15});16var wpt = require('webpagetest');17var test = wpt('WPT_API_KEY');18 if (err) {19 console.log(err);20 } else {21 console.log(data);22 }23});24var wpt = require('webpagetest');25var test = wpt('WPT_API_KEY');26test.getTestStatus('131122_1K_1', function(err, data) {27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33var wpt = require('webpagetest');34var test = wpt('WPT_API_KEY');35test.getTestResults('131122_1K_1', function(err, data) {36 if (err) {37 console.log(err);38 } else {39 console.log(data);40 }41});42var wpt = require('webpagetest');43var test = wpt('WPT_API_KEY');44test.getTestResults('131122_1K_1', {pagespeed: 1, requests: 1}, function(err, data) {45 if (err) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var util = require('util');3var fs = require('fs');4var wpt = new WebPageTest('www.webpagetest.org', 'A.0c4a7d9e8f9a7a2d1a2e2f4f8f2a2a4');5 if (err) {6 console.log('Error: ' + err);7 } else {8 console.log('Load Target Data: ' + util.inspect(data));9 }10});11wpt.runTest(data.target, {runs: 1}, function(err, data) {12 if (err) {13 console.log('Error: ' + err);14 } else {15 console.log('Test Data: ' + util.inspect(data));16 }17});18wpt.getTestResults(data.data.testId, function(err, data) {19 if (err) {20 console.log('Error: ' + err);21 } else {22 console.log('Results: ' + util.inspect(data));23 }24});25wpt.getTestResults(data.data.testId, function(err, data) {26 if (err) {27 console.log('Error: ' + err);28 } else {29 fs.writeFile("results.txt", data, function(err) {30 if (err) {31 console.log(err);32 } else {33 console.log("The file was saved!");34 }35 });36 }37});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2 if (err) {3 console.log('Error: ' + err);4 }5 else {6 console.log('Page loaded successfully');7 }8});9 if (err) {10 console.log('Error: ' + err);11 }12 else {13 console.log('Page loaded successfully');14 }15});16var wpt = require('wpt.js');17 if (err) {18 console.log('Error: ' + err);19 }20 else {21 console.log('Test started successfully');22 }23});24 if (err) {25 console.log('Error: ' + err);26 }27 else {28 console.log('Test started successfully');29 }30});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3}, function(err, data) {4 if (err) return console.error(err);5 console.log('Test status:', data.statusText);6 console.log('Test ID:', data.data.testId);7 console.log('Test URL:', data.data.summary);8 console.log('Test runs:', data.data.average.firstView.loadTime);9});10### new WebPageTest([host], [options])11### wpt.getLocations([callback])12### wpt.getTests([callback])13### wpt.getTestStatus(testId, [callback])14Get the status of a test. `callback` is called with `(err, status)`, where `status` is an object with the following properties:15### wpt.getTestResults(testId, [callback])16Get the results of a test. `callback` is called with `(err,

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org', 'A.d3e3c60c8b8f3d3d0b3c3d3f3d3e3d3d');3 if (err) return console.error(err);4 console.log('Test started:', data.data.testId);5 wpt.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log('Test completed:', data.data.summary);8 });9});10var wpt = require('wpt');11var wpt = new WebPageTest('www.webpagetest.org', 'A.d3e3c60c8b8f3d3d0b3c3d3f3d3e3d3d');12 if (err) return console.error(err);13 console.log('Test started:', data.data.testId);14 wpt.getTestResults(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log('Test completed:', data.data.summary);17 });18});19var wpt = require('wpt');20var wpt = new WebPageTest('www.webpagetest.org', 'A.d3e3c60c8b8f3d3d0b3c3d3f3d3e3d3d');21 if (err) return console.error(err);22 console.log('Test started:', data.data.testId);23 wpt.getTestResults(data.data.testId, function(err, data) {24 if (err) return console.error(err);25 console.log('Test completed:', data.data.summary);26 });27});

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 wpt 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