@@ -5,7 +5,7 @@ builder.selenium2.io.addLangFormatter({
55 start :
66 "/**\n" +
77 " * Script Name: {scriptName}\n" +
8- " * \n" +
8+ " * \n" +
99 " * Generated script for New Relic Synthetics\n" +
1010 " * Generated using se-builder with New Relic Synthetics Formatter\n" +
1111 " *\n" +
@@ -30,9 +30,9 @@ builder.selenium2.io.addLangFormatter({
3030 " prevStep = 0,\n" +
3131 " lastStep = 9999,\n" +
3232 "VARS = {};\n" +
33- "// Uncomment and use this if you're running Se-Builder 2 and used Manual Entry variables.\n" +
34- "// If you don't know what those are, fuggedaboutit!\n" +
35- "// VARS = {{scriptManualEntryData}};\n\n" +
33+ "// Uncomment and use this if you're running Se-Builder 2 and used Manual Entry variables.\n" +
34+ "// If you don't know what those are, fuggedaboutit!\n" +
35+ "// VARS = {{scriptManualEntryData}};\n\n" +
3636 "var log = function(thisStep, thisMsg) {\n" +
3737 " if (thisStep > 1 || thisStep == lastStep) {\n" +
3838 " var totalTimeElapsed = Date.now() - startTime;\n" +
@@ -56,25 +56,11 @@ builder.selenium2.io.addLangFormatter({
5656 " return true;\n" +
5757 " } catch (err) { return false; }\n" +
5858 "}\n\n" +
59- "function isElementSelected(el) { return $browser.findElement(el).isSelected(); }\n\n" +
60- "function isTextPresentIn(text, selector) {\n" +
61- " return $browser.findElement(selector)\n" +
62- " .getText()\n" +
63- " .then(function (wholetext) {\n" +
64- " return wholetext.indexOf(text) != -1;\n" +
65- " })\n" +
66- " .catch(function(err) {\n" +
67- " return false;\n" +
68- " });\n" +
69- "}\n\n" +
70- "function isTextPresent(text) {\n" +
71- " return isTextPresentIn(text, By.tagName('html'));\n" +
72- "}\n\n" +
7359 "/** BEGINNING OF SCRIPT **/\n\n" +
7460 "console.log('Starting synthetics script: {scriptName}');\n" +
75- "console.log('Default timeout is set to ' + (DefaultTimeout/1000) + ' seconds');\n" +
76- "console.log('Variables set in this script: ', VARS);\n" +
77- "\n" +
61+ "console.log('Default timeout is set to ' + (DefaultTimeout/1000) + ' seconds');\n" +
62+ "console.log('Variables set in this script: ', VARS);\n" +
63+ "\n" +
7864 "// Setting User Agent is not then-able, so we do this first (if defined and not default)\n" +
7965 "if (UserAgent && (0 !== UserAgent.trim().length) && (UserAgent != 'default')) {\n" +
8066 " $browser.addHeader('User-Agent', UserAgent);\n" +
@@ -91,7 +77,7 @@ builder.selenium2.io.addLangFormatter({
9177 " throw(err);\n" +
9278 "});\n\n" +
9379 "/** END OF SCRIPT **/" ,
94-
80+
9581lineForType : {
9682 "get" : function ( step , escapeValue , userParams , doSubs ) {
9783 return doSubs ( scriptify ( "$browser.get({url})" ) ) ; } ,
@@ -208,7 +194,7 @@ lineForType: {
208194 var entryArr = entry . split ( "=" ) ;
209195 data [ entryArr [ 0 ] ] = entryArr [ 1 ] ;
210196 } ) ;
211- return commentstep ( ) +
197+ return commentstep ( ) +
212198 ".then(function () {\n" +
213199 " log(" + thisstep + ", 'addCookie " + data [ 'name' ] + ", " + data [ 'value' ] + "');\n" +
214200 " browser.addCookie('" + data [ 'name' ] + "', '" + data [ 'value' ] + "');\n" +
@@ -217,17 +203,17 @@ lineForType: {
217203 "deleteCookie" :
218204 function ( step ) { return scriptify ( "browser.deleteCookie(\"" + step . name + "\")" ) ; } ,
219205 "saveScreenshot" :
220- function ( step ) { return commentstep ( ) +
206+ function ( step ) { return commentstep ( ) +
221207 ".then(function () {\n" +
222208 " log(" + thisstep + ", '$browser.takeScreenshot()');\n" +
223209 " $browser.takeScreenshot();\n" +
224- "})\n\n" ;
210+ "})\n\n" ;
225211 } ,
226212 } ,
227213 waitFor : function ( step , escapeValue , doSubs , getter ) {
228214 if ( step . negated ) {
229215 return doSubs (
230- commentstep ( ) +
216+ commentstep ( ) +
231217 ".then(function () {\n" +
232218 " log(" + thisstep + ", '{stepTypeName} {negNot}{cmp}');\n" +
233219 " return $browser.wait(function() {\n" +
@@ -237,7 +223,7 @@ lineForType: {
237223 "{getterFinish}" , getter ) ;
238224 } else {
239225 return doSubs (
240- commentstep ( ) +
226+ commentstep ( ) +
241227 ".then(function () {\n" +
242228 " log(" + thisstep + ", '{stepTypeName} {cmp}');\n" +
243229 " return $browser.wait(function() {\n" +
@@ -250,15 +236,15 @@ lineForType: {
250236 assert : function ( step , escapeValue , doSubs , getter ) {
251237 if ( step . negated ) {
252238 return doSubs (
253- commentstep ( ) +
239+ commentstep ( ) +
254240 ".then(function () {\n" +
255241 " log(" + thisstep + ", '{stepTypeName} {negNot}{cmp}');\n" +
256242 " {getter}\n" +
257243 " assert.notEqual({value}, {cmp}, '{stepTypeName} {negNot}{cmp} FAILED.');\n" +
258244 "{getterFinish}" , getter ) ;
259245 } else {
260246 return doSubs (
261- commentstep ( ) +
247+ commentstep ( ) +
262248 ".then(function () {\n" +
263249 " log(" + thisstep + ", '{stepTypeName} {negNot}{cmp}');\n" +
264250 " {getter}\n" +
@@ -269,7 +255,7 @@ lineForType: {
269255 verify : function ( step , escapeValue , doSubs , getter ) {
270256 if ( step . negated ) {
271257 return doSubs (
272- commentstep ( ) +
258+ commentstep ( ) +
273259 ".then(function () {\n" +
274260 " log(" + thisstep + ", '{stepTypeName} {negNot}{cmp}');\n" +
275261 " {getter}\n" +
@@ -282,7 +268,7 @@ lineForType: {
282268 "{getterFinish}" , getter ) ;
283269 } else {
284270 return doSubs (
285- commentstep ( ) +
271+ commentstep ( ) +
286272 ".then(function () {\n" +
287273 " log(" + thisstep + ", '{stepTypeName} {negNot}{cmp}');\n" +
288274 " {getter}\n" +
@@ -297,14 +283,14 @@ lineForType: {
297283 } ,
298284 store : function ( step , escapeValue , doSubs , getter ) {
299285 return doSubs (
300- commentstep ( ) +
286+ commentstep ( ) +
301287 ".then(function () {\n" +
302288 " log(" + thisstep + ", '{stepTypeName} ${{variable}}');\n" +
303289 " {getter}\n" +
304290 " ${{variable}} = {value};\n" +
305- "{getterFinish}" , getter ) ;
291+ "{getterFinish}" , getter ) ;
306292 } ,
307- getters : {
293+ getters : {
308294 "BodyText" : {
309295 getter : "return $browser.findElement($driver.By.tagName('body')); })\n" +
310296 " .then(function (el) { return el.getText(); })\n" +
@@ -357,7 +343,7 @@ lineForType: {
357343 getterFinish : "})\n\n" ,
358344 cmp : "{value}" ,
359345 value : "value"
360- } ,
346+ } ,
361347 "ElementAttribute" : {
362348 getter : "return $browser.findElement($driver.By.{locatorBy}({locator})); })\n" +
363349 " .then(function (el) { return el.getAttribute({attributeName}); })\n" +
@@ -392,17 +378,17 @@ lineForType: {
392378 } ,
393379 boolean_assert : function ( step , escapeValue , doSubs , getter ) {
394380 return doSubs (
395- commentstep ( ) +
396- ".then(function () {\n" +
381+ commentstep ( ) +
382+ ".then(function () {\n" +
397383 " log(" + thisstep + ", '{stepTypeName} {negNot}{value}');\n" +
398384 " {getter}.then(function (bool) {\n" +
399385 " assert.ok(({negNot}bool), '{stepTypeName} FAILED.');\n" +
400386 " });\n" +
401387 "{getterFinish}" , getter ) ; } ,
402388 boolean_verify : function ( step , escapeValue , doSubs , getter ) {
403389 return doSubs (
404- commentstep ( ) +
405- ".then(function () {\n" +
390+ commentstep ( ) +
391+ ".then(function () {\n" +
406392 " log(" + thisstep + ", '{stepTypeName} {negNot}{value}');\n" +
407393 " {getter}.then(function (bool) {\n" +
408394 " if ({posNot}bool) {\n" +
@@ -415,7 +401,7 @@ lineForType: {
415401 "{getterFinish}" , getter ) ; } ,
416402 boolean_waitFor : function ( step , escapeValue , doSubs , getter ) {
417403 return doSubs (
418- commentstep ( ) +
404+ commentstep ( ) +
419405 ".then(function () {\n" +
420406 " log(" + thisstep + ", '{stepTypeName} {negNot}{value}');\n" +
421407 " $browser.wait(function () {\n" +
@@ -424,14 +410,15 @@ lineForType: {
424410 "})\n\n" , getter ) ; } ,
425411 boolean_store : function ( step , escapeValue , doSubs , getter ) {
426412 return doSubs (
427- commentstep ( ) +
428- ".then(function () {\n" +
413+ commentstep ( ) +
414+ ".then(function () {\n" +
429415 " log(" + thisstep + ", '{stepTypeName} ${{variable}}');\n" +
430416 " {getter}.then(function (bool) { ${{variable}} = bool; });\n" +
431417 "{getterFinish}" , getter ) ; } ,
432418 boolean_getters : {
433419 "TextPresent" : {
434- getter : "isTextPresent({text})" ,
420+ getter : "$browser.findElement(By.tagName('body')).getText()\n" +
421+ " .then(function (text) { return text.indexOf({text}) != -1; })" ,
435422 getterFinish : "})\n\n" ,
436423 value : "{text}"
437424 } ,
@@ -441,7 +428,7 @@ lineForType: {
441428 value : "{locator}"
442429 } ,
443430 "ElementSelected" : {
444- getter : "isElementSelected (By.{locatorBy}({locator}))" ,
431+ getter : "$browser.findElement (By.{locatorBy}({locator})).isSelected( )" ,
445432 getterFinish : "})\n\n" ,
446433 value : "{locator}"
447434 } ,
@@ -558,16 +545,16 @@ function print_nr_unsupported(thing) {
558545
559546function scriptify ( msg ) {
560547 return commentstep ( ) +
561- ".then(function() {\n" +
548+ ".then(function() {\n" +
562549 " log(" + thisstep + ", \'" + msg + "\');\n" +
563- " return " + msg + "; })\n\n" ;
550+ " return " + msg + "; })\n\n" ;
564551}
565-
552+
566553function scriptify_complex ( logmsg , msg ) {
567554 return commentstep ( ) +
568- ".then(function() {\n" +
555+ ".then(function() {\n" +
569556 " log(" + thisstep + ", \'" + logmsg + "\');\n" +
570- " return " + msg + "; })\n\n" ;
557+ " return " + msg + "; })\n\n" ;
571558}
572559
573560if ( builder && builder . loader && builder . loader . loadNextMainScript ) { builder . loader . loadNextMainScript ( ) ; }
0 commit comments