Skip to content

Commit 7c5cdb9

Browse files
committed
Updated readme, script tweaks, build script
1 parent fcbeaa1 commit 7c5cdb9

File tree

6 files changed

+63
-25
lines changed

6 files changed

+63
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

README.md

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,41 @@ Plugin (formatter) for Se-builder that generates javascript from Se-builder scri
55

66
## IMPORTANT - Version Compatibility
77

8-
<b>The old version of Se-Builder no longer runs in Firefox by default. See https://support.mozilla.org/en-US/kb/add-on-signing-in-firefox for a workaround.</b> I will update this plugin to work with the new version once it is closer to feature parity with the old version.
8+
### Selenium Builder 3 Compatibility Update
99

10-
* Old version of Selenium Builder (works with this plugin): https://github.com/SeleniumBuilder/se-builder/
11-
* New version of Selenium Builder (untested with this plugin): https://github.com/SeleniumBuilder/selenium-builder/
10+
<b>I have tested the plugin with the new version of se-builder and it works fine!</b> You can use that version if you want, installed from here: https://addons.mozilla.org/en-GB/firefox/addon/selenium-builder/
1211

13-
## Download the plugin
12+
The only change in the installation is the location of the plugin. It is now placed in `SeBuilder3/plugins` instead of `SeBuilder/plugins`. Can't find the plugins directory? [Check here!](#cant-find-the-plugins-directory)
1413

15-
[Download link for plugin](https://github.com/sschwartzman/newrelic-synthetics-sebuilder/archive/master.zip)
14+
<b>Limitation of Selenium Builder 3: local playback does not work.</b> If you want to record a script and replay it after tweaking, you'll need to run a Selenium Server somewhere. [That's easy enough to do.](http://www.seleniumhq.org/docs/05_selenium_rc.jsp#installation) It can be run locally on your laptop.
1615

17-
## Install the prerequisites
16+
### Selenium Builder 2 (aka Se-Builder) Compatibility
1817

19-
1. Download & install [selenium-builder](http://seleniumbuilder.github.io/se-builder/selenium-builder-latest.xpi).
20-
* Yes, you'll need [FireFox](https://www.mozilla.org/en-US/firefox/new/) too.
21-
2. Run Se-builder at least once before proceeding. Running it the first time creates the folder where you'll put the plugin.
22-
* Run it by going to Tools > Web Developer > Launch Selenium Builder.
23-
3. Se-builder will appear as a small icon that looks like a Lego piece in the Firefox add-ons toolbar. Click on that icon to load.
24-
* If Se-builder does not show up, click on the Hamburger menu, click Customise, and drag the Se-builder icon from "Additional Tools and Features" on the left into the toolbar.
18+
This formatter plugin is tested and compatible with the old version of Se-Builder, which is an unisgned plugin. <b>The old version of Se-Builder no longer runs in Firefox by default. See https://support.mozilla.org/en-US/kb/add-on-signing-in-firefox for a workaround.</b> NOTE: This workaround may not work for the most recent versions of Firefox. If that's the case, either use an older version of Firefox, or use Selenium Builder 3 (now that the plugin supports it).
2519

26-
## Install the plugin
20+
* Old version: Se-Builder 2: https://github.com/SeleniumBuilder/se-builder/
21+
* Download: http://www.saucelabs.com/addons/selenium-builder-latest.xpi
22+
* New version: Selenium Builder 3: https://github.com/SeleniumBuilder/selenium-builder/
23+
* Download: https://addons.mozilla.org/en-GB/firefox/addon/selenium-builder/
2724

28-
1. [Download the plugin](https://github.com/sschwartzman/newrelic-synthetics-sebuilder/archive/master.zip)
29-
2. Unzip the plugin into the `SeBuilder/plugins` directory on in your Firefox profile.
30-
* **NOTE:** The zip contains a folder called `nr_synthetics_formatter`. Move the **FOLDER with enclosed files** into the plugins directory, rather than moving the files themselves without the folder.
25+
## Installation
26+
27+
### Download the plugin
28+
29+
[Download link for plugin](https://github.com/sschwartzman/newrelic-synthetics-sebuilder/blob/master/nr_synthetics_formatter.zip)
30+
31+
### Install the prerequisites
32+
33+
1. Download & install either Se-builder v2 or v3:
34+
* [se-builder 2](http://www.saucelabs.com/addons/selenium-builder-latest.xpi).
35+
* [Selenium Builder 3](https://addons.mozilla.org/en-GB/firefox/addon/selenium-builder/)
36+
* You'll need [FireFox](https://www.mozilla.org/en-US/firefox/new/) too.
37+
2. Run Se-builder at least once before proceeding. Running it the first time creates the folder where you'll put the plugin. Run it by going to <b>Tools > Web Developer > Launch Selenium Builder.</b>
38+
39+
### Install the plugin
40+
41+
1. [Download the plugin](https://github.com/sschwartzman/newrelic-synthetics-sebuilder/blob/master/nr_synthetics_formatter.zip)
42+
2. Unzip the plugin into the `SeBuilder/plugins` (v2) or `SeBuilder3/plugins` (v3) directory on in your Firefox profile. Your folder structure should look like this: ![Img of folder structure](https://github.com/sschwartzman/newrelic-synthetics-sebuilder/blob/master/etc/folder_structure.png)
3143
* Can't find the Se-builder plugins directory? [Check here](#cant-find-the-plugins-directory)
3244
3. Restart the se-builder if you still have it running. You don't have to restart Firefox, just exit and re-open Se-builder.
3345
4. To verify that the plugin is loaded, click "Manage plugins" in the opening dialog box. You should see "New Relic Synthetics Formatter #.# Installed" in the Plugins list.
@@ -45,7 +57,8 @@ Plugin (formatter) for Se-builder that generates javascript from Se-builder scri
4557
* Save the result to any name and location you want, so long as you can find it!
4658
* When saving, add ".js" to the end of the file name so that it looks pretty in your text editor of choice.
4759
3. Create a new Scripted Browser monitor in Synthetics
48-
* Click "Add New Monitor" in the main screen of Synthetics or visit https://synthetics.newrelic.com/accounts/[your_account_id].monitors/new
60+
* Click "Add New Monitor" in the main screen of Synthetics or visit
61+
https://synthetics.newrelic.com/accounts/[your_account_id]/monitors/new
4962
* Choose "Scripted Browser" as the monitor type, and then set the name, locations & frequency as you like.
5063
* In the "Script your steps" window, clear the contents there and paste the contents of your exported script.
5164
* Be sure to click "Validate" below this window pane to ensure that the script works properly.
@@ -63,13 +76,23 @@ Plugin (formatter) for Se-builder that generates javascript from Se-builder scri
6376

6477
Here are some common locations for the plugins directory:
6578

79+
#### SeBuilder v2
80+
6681
* Mac: `/Users/[you]/Library/Application Support/Firefox/Profiles/[your_profile]/SeBuilder/plugins`
6782
* Win: `C:/Users/[you]/Appdata/Roaming/Mozilla/Firefox/Profiles/[your_profile]/SeBuilder/plugins`
6883
* Linux/Unix: `~/.mozilla/firefox/[your_profile]/SeBuilder/plugins`
84+
85+
#### Selenium Builder 3
86+
87+
* Mac: `/Users/[you]/Library/Application Support/Firefox/Profiles/[your_profile]/SeBuilder3/plugins`
88+
* Win: `C:/Users/[you]/Appdata/Roaming/Mozilla/Firefox/Profiles/[your_profile]/SeBuilder3/plugins`
89+
* Linux/Unix: `~/.mozilla/firefox/[your_profile]/SeBuilder3/plugins`
6990

70-
##### Can't find the "Library" folder on your Mac? If you need to open it:
91+
#### Can't find the "Library" folder on your Mac?
92+
93+
It may be hidden from view in your Finder. Here's how to unhide it:
7194

7295
1. Open your Home folder in Finder.
7396
2. Right-click in the finder window and click "Show View Options", or open it by pressing ⌘-J.
7497
3. Check the box next to Show Library Folder.
75-
98+

build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
whereami=$(pwd)
3+
thisdir=$(dirname $0)
4+
cd $thisdir
5+
rm nr_synthetics_formatter.zip
6+
zip -r nr_synthetics_formatter.zip nr_synthetics_formatter
7+
cd $whereami

etc/folder_structure.png

44.9 KB
Loading

nr_synthetics_formatter.zip

11.4 KB
Binary file not shown.

nr_synthetics_formatter/nr-synthetics.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ builder.selenium2.io.addLangFormatter({
44
not: "!",
55
start:
66
"/**\n" +
7+
" * Script Name: {scriptName}\n" +
8+
" * \n" +
79
" * Generated script for New Relic Synthetics\n" +
810
" * Generated using se-builder with New Relic Synthetics Formatter\n" +
911
" *\n" +
@@ -13,10 +15,8 @@ builder.selenium2.io.addLangFormatter({
1315
" */\n\n" +
1416
"/** CONFIGURATIONS **/\n\n" +
1517
"// Theshold for duration of entire script - fails test if script lasts longer than X (in ms)\n" +
16-
"// Default is '0', which means that it won't fail.\n" +
17-
"var ScriptTimeout = 0;\n" +
1818
"// Script-wide timeout for all wait and waitAndFind functions (in ms)\n" +
19-
"var DefaultTimeout = 10000;\n" +
19+
"var DefaultTimeout = {timeoutSeconds}000;\n" +
2020
"// Change to any User Agent you want to use.\n" +
2121
"// Leave as \"default\" or empty to use the Synthetics default.\n" +
2222
"var UserAgent = \"default\";\n\n" +
@@ -29,15 +29,18 @@ builder.selenium2.io.addLangFormatter({
2929
" prevMsg = '',\n" +
3030
" prevStep = 0,\n" +
3131
" lastStep = 9999,\n" +
32-
" VARS = {};\n\n" +
32+
"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" +
3336
"var log = function(thisStep, thisMsg) {\n" +
3437
" if (thisStep > 1 || thisStep == lastStep) {\n" +
3538
" var totalTimeElapsed = Date.now() - startTime;\n" +
3639
" var prevStepTimeElapsed = totalTimeElapsed - stepStartTime;\n" +
3740
" console.log('Step ' + prevStep + ': ' + prevMsg + ' FINISHED. It took ' + prevStepTimeElapsed + 'ms to complete.');\n" +
3841
" $util.insights.set('Step ' + prevStep + ': ' + prevMsg, prevStepTimeElapsed);\n" +
39-
" if (ScriptTimeout > 0 && totalTimeElapsed > ScriptTimeout) {\n" +
40-
" throw new Error('Script timed out. ' + totalTimeElapsed + 'ms is longer than script timeout threshold of ' + ScriptTimeout + 'ms.');\n" +
42+
" if (DefaultTimeout > 0 && totalTimeElapsed > DefaultTimeout) {\n" +
43+
" throw new Error('Script timed out. ' + totalTimeElapsed + 'ms is longer than script timeout threshold of ' + DefaultTimeout + 'ms.');\n" +
4144
" }\n" +
4245
" }\n" +
4346
" if (thisStep > 0 && thisStep != lastStep) {\n" +
@@ -64,6 +67,10 @@ builder.selenium2.io.addLangFormatter({
6467
" return isTextPresentIn(text, $browser.findElement(By.tagName('html')));\n" +
6568
"}\n\n" +
6669
"/** BEGINNING OF SCRIPT **/\n\n" +
70+
"console.log('Starting synthetics script: {scriptName}');\n" +
71+
"console.log('Default timeout is set to ' + (DefaultTimeout/1000) + ' seconds');\n" +
72+
"console.log('Variables set in this script: ', VARS);\n" +
73+
"\n" +
6774
"// Setting User Agent is not then-able, so we do this first (if defined and not default)\n" +
6875
"if (UserAgent && (0 !== UserAgent.trim().length) && (UserAgent != 'default')) {\n" +
6976
" $browser.addHeader('User-Agent', UserAgent);\n" +

0 commit comments

Comments
 (0)