Skip to content

Commit 3f0e520

Browse files
committed
Merge pull request sschwartzman#3 from Skrath/patch-1
Slightly more robust isTextPresent method
2 parents c5fd1f1 + 67d1ac3 commit 3f0e520

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

nr_synthetics_formatter/nr-synthetics.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,16 @@ builder.selenium2.io.addLangFormatter({
5050
" } catch (err) { return false; }\n" +
5151
"}\n" +
5252
"function isElementSelected(el) { return $browser.findElement(el).isSelected(); }\n" +
53-
"function isTextPresent(text) {\n" +
54-
" return $browser.findElement(By.tagName('html')).getText()\n" +
53+
"function isTextPresentIn(text, sourceEl) {\n" +
54+
" return sourceEl.getText()\n" +
5555
" .then(function (wholetext) {\n" +
56-
" return wholetext.indexOf(text) != -1;\n" +
56+
" log("Assert Text Present: '\" + text +\"'\");\n" +
57+
" assert.notEqual(wholetext.indexOf(text), -1, "Text Not Found: '\" + text + \"'\");\n" +
5758
" });\n" +
5859
"}\n\n" +
60+
"function isTextPresent(text) {\n" +
61+
" return isTextPresentIn(text, $browser.findElement(By.tagName('html')));\n" +
62+
"}\n\n" +
5963
"/** BEGINNING OF SCRIPT **/\n\n" +
6064
"// Setting User Agent is not then-able, so we do this first (if defined and not default)\n" +
6165
"if ((typeof UserAgent !== 'undefined') && (UserAgent != 'default')) {\n" +
@@ -501,4 +505,4 @@ function scriptify(msg) {
501505
"})\n\n";
502506
}
503507

504-
if (builder && builder.loader && builder.loader.loadNextMainScript) { builder.loader.loadNextMainScript(); }
508+
if (builder && builder.loader && builder.loader.loadNextMainScript) { builder.loader.loadNextMainScript(); }

0 commit comments

Comments
 (0)