Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 14 Next »

Selenium IDE is a standalone 3rd party tool for creating Selenium test cases. These test cases can be imported as script files into Synthetic Monitoring and used within Browser Checks to collect performance metrics for the scenario. In some cases, you will need to make changes to your Selenium IDE script before it can be used within ASM as a Scenario. This article explains how ASM handles Selenium IDE scripts so you can easily understand how to convert your scripts into Scenarios.

Supported Selenium IDE Commands

Use the following table as a reference when determining whether a certain Selenium IDE command is compatible with your ASM Scenario.

Actions

Keyboard &  Mouse interaction

Verification and Assertion

Waits

Scenario Flow

JS Execution

Stored Variables

Custom (ASM Specific) Commands

open

keyDown

assertElementPresent

waitForVisible

gotoIf

fireEvent

storeTitle

setPageBreak

clickAndWait

keyDownAndWait

assertTitle

waitForText

goto

runScript

storeXpathCount

insertPageBreak

clickAtAndWait

keyUp

assertLocation

waitForValue

label

getEval

storeCssCount

takeScreenshot

click

keyUpAndWait

assertVisible

waitForAttribute

close

runScriptAndWait

storeValue

startRecording

clickAt

keyPress

assertElementNotPresent

waitForNotText

pause

storeText

clearRecording

type

keyPressAndWait

assertNotVisible

waitForNotValue

setSpeed

storeLocation

stopRecording

sendKeys

mouseOver

assertAttribute

waitForNotAttribute

setTimeout

storeExpression

getDictionary

typeKeys

assertNotAttribute

waitForTextPresent

echo

storeEval

select

assertValue

waitForTextNotPresent

storeAttribute

selectAndWait

assertNotValue

waitForElementPresent

storeElementPresent

selectFrame

assertText

waitForEditable

store

selectWindow

assertTextNotPresent

waitForElementNotPresent

submit

assertTextPresent

waitForNotVisible

assertExpression

waitForTitle

assertNextConfirmation

waitForLocation

assertNextAlert

waitForAlert

assertAlert

waitForConfirmation

assertConfirmation

assertEval

verifyTitle

verifyLocation

verifyElementPresent

verifyVisible

verifyElementNotPresent

verifyNotVisible

verifyAttribute

verifyNotAttribute

verifyValue

verifyNotValue

verifyText

verifyTextNotPresent

verifyTextPresent

verifyExpression

Usage Assertion Modes

In order to assert a command within Selenium IDE, you can use the assert, verify, or waitFor commands; the assert command will stop the Selenium IDE script if the expected condition is not met, while the verify command will log an error message but not stop the script. ASM scenarios, in contrast, treat the assert and verify commands in the same way - if the expected condition is not met, both commands will result in a failure of the scenario.

By contrast, the behavior of the waitFor command is the same within Selenium IDE and ASM Scenarios. Within both tools, the waitFor command will wait for a specified element and will result in a script failure if the element is not found within the specified timeframe.

The ASM Dictionary

In Synthetic Monitoring, the concept of “Dictionaries” is a repository to store user names, passwords, internal access URLs, and other sensitive data. Dictionaries can be used to reuse data in multiple environments or to hide access information during monitoring. This allows users to utilize passwords in scenarios without displaying them in cleartext or reuse a single URL in several different scenarios without manually coding it.

The getDictionary Command

The Apica custom Selenium scripting command getDictionary allows users to access a user-defined dictionary from inside a check scenario script. The getDictionary fetches the entire Dictionary (with all key/value pairs) and stores it locally for when the script executes. 

Using the getDictionary Command

Step 1: Create the Dictionary

  1. Create/Add a Dictionary using our API POST command

  2. Name the Dictionary Key that will be used to access this dictionary. Some examples:

    1. "dictionary_key": "ExampleApicaKey","dictionary" {Name:value pairs}

    2. "dictionary_key": "ApicaKey","dictionary" {Name:value pairs}

    3. You will also provide string-pair values in the form of “targetstring1”: “targetvalue1” that will form the Keys that access the values needed.

      • e.g., “firstname”: “Doug”

      • e.g., “lastname”: “Smith”

      • e.g., “cardnumber”: “1234-1234-1234-1234”

      • e.g., “expdate”: “12/25”

  3. You must also provide a Description

    1. e.g. "description": "Test Dictionary"

  4. In this example, the POST command is

    1. POST scenarios/proxysniffer/dictionaries

  5. The POST body for one of the examples above would be

{
  "dictionary_key": "DougApicaKey",   
  "dictionary": {
     “firstname”: “Doug”,
     "lastname”: “Smith”,
     "cardnumber”: “1234-1234-1234-1234"
  },
"description": "Test Dictionary"
}

Step 2: Retrieve the Dictionary

Once the above dictionary has been defined, the Selenium scripting command getDictionary allows access to this information from inside a check scenario script. The getDictionary command fetches the entire Dictionary (with all key/value pairs) and stores it locally for when the script executes. It uses the Apica Dictionaries GET API to get these dictionary values. The GET call will be in the form of

https://api-wpm.apicasystem.com/v3/scenarios/proxysniffer/dictionaries/{dictionary_key}?auth_ticket={auth ticket value}

The getDictionary command then turns these key values into ASM variable names for use in the ASM script.

Using the getDictionary Command within a Selenium Scenario

When the getDictionary command fetches pre-defined variables from a dictionary, it expects two arguments:

  1. Target: User’s API Token or Authorization Ticket

  2. Value: The dictionary URL https://api-wpm.apicasystem.com/v3/scenarios/proxysniffer/dictionaries/{dictionary_key}

The following screenshot provides an example of the getDictionary command within a Selenium script:

Command

Target

Value

getDictionary

63F6E******************

{API URL}/DougApicaKey

The API token is masked for privileged users

This screenshot provides an example of the API GET command for the dictionary “DougApicaKey”

This screenshot provides another example of the API GET command for the dictionary “ApicaKey”. Note how each dictionary has different defined key-value pairs.

Selenium Example 1: The Dictionary Key "DougApicaKey" has 3 key values (excluding the sample value) that are used in the scenario.

Selenium Example 2: The Dictionary Key "Apicakey" has 2 key values (excluding the sampleKey value) that are used in this scenario.

In this case, the username and password values, from the dictionary will be used in the Selenium scenario; these values will not be hard-coded into the script.

insertPageBreak

ASM scenarios support a custom command called “insertPageBreak”. This command creates a new Page Break that separates different pages (which typically consist of multiple URL calls) from each other. The command expects one argument, the name/title of the page break, which will be shown on the Result Details page in ASM. Page breaks can be entered manually into scripts or automatically generated when recording web sessions. For example, If the login portion of a web page sequence takes place over two or three HTML pages, the Page break could define the set of HTML pages to be all part of a single group before the next logical page navigation, another Page Break, which could be “Check my account.” Typically, insertPageBreak is only necessary if you need to set a custom title or if requests which are triggered as a result of executing multiple different commands all end up as part of the same step, and you wish to split these requests into multiple steps.

takeScreenshot

The command takeScreenshot takes a screenshot that will be visible in the Check Details. The command will insert an additional screenshot onto the page in addition to whatever screenshots have been added in the Edit Check settings.

Apica Custom Script Extension

The Apica custom extensions can be downloaded from the https://wpm.apicasystem.com/ManageScenarios view in Synthetic Monitoring:

Download

The extension can only be integrated into an older version of Selenium IDE - version 2.9.1, which runs on Firefox v55 or older Firefox versions.

This extension is deprecated and limited documentation exists surrounding the extension.

To download the Apica Extension:

Install Extension

Install Apica Extension

In order to use the Apica Extension with Selenium IDE, you need to add it as an option and restart Selenium IDE.

Install Extension

To install the Apica extension:

Start in Firefox:

  • Open Selenium IDE

  • Open the Options menu

  • Select Options...

The Selenium IDE options dialog opens:

In the General tab:

  • Find the Selenium Core Extensions field

  • Click Browse

  • Find the downloaded plugin file (apicaExt.js)

  • Select the file

  • Click Open

  • Click OK

Reopen the IDE window to apply the changes.

  • Close Selenium IDE

Next time you open Selenium IDE, the plugin will be loaded.

Encrypted Selenium Variables


Please note: This described feature has to be enabled per customer account. If this is a feature that you require, please contact your Technical Account Manager or Support:


Don’t just Mask. Encrypt!

Emulating users clicking through your web application with scenarios is an important aspect of synthetic monitoring. Still, a downside of using these scenarios is that sensitive credentials or other data can be exposed to other Apica Synthetic users.  To improve the security and control of important data, we have added the ability to encrypt variables in your scenarios.  Any data stored in an encrypted variable is completely inaccessible except when the scenario is actually being run, so you can now safely add scenarios to even your most sensitive applications without the fear of your information getting into the wrong hands.

To add an encrypted variable to your scenarios, add a variable using the Selenium "store" command, and start the name of your variable with "encryptapica."  You can then use that variable safely anywhere in your scenario.

Step

Screenshot

  1. Edit a Check with a Selenium Scenario. Find this in the Check Information section, where you can select which Scenario to edit.

    1. Click the green Debug Scenario icon to the right of the chosen scenario.

  1. Identify the sensitive information that you want to encrypt.

In this example, we have a password being passed in the clear each time it is run. We’ll want to encrypt this password with the Apica crypto service that will pass a variable name in its place.

In monitoring, Apica recommends using test/dummy logins and passwords to reduce confidential and sensitive information exposure.

  1. Store the value as encrypted by adding/

storing a new variable to hold the encrypted value.

a. Near the top of your scenario, Add/Declare a new variable with the 'Store' Command in the dropdown box.

  1. ‘encryptapica’ is the string that calls/envokes the crypto service and precedes the name of the item you want to protect with encryption (in this case, the password), so “encryptapicapassword” is the value for what we still store.

Notice the red triangle to the right of the value. This will remain there until you provide a Target to encrypt in the column to the left.

Once you’ve added the target (in the next step), this will be replaced by a green lock.

  1. Enter the original Target Value

a. Double-click in the target field.

b. A new dialog box, “Update Encrypted Value” will appear to enter in your plaintext value. Be sure that you have a version of this plaintext securely stored somewhere because Apica will not retrieve the plaintext value.

Click the Update & Encrypt to begin the encryption.

  1. After the encryption has been completed, the green lock will appear, and the words “[ENCRYPTED BY APICA]” will be in the Target field.

  1. In the step where, in this example, the password originally appeared, you now will replace the plaintext password with the stored variable name that you selected. In this case, in step 25, the variable ‘encryptapicapassword’ will be entered as $(variable_name) or ‘$(encryptapicapassword)’

  1. You are finished. Please test your scenario to ensure it passes the encrypted values to your application, and then remember to click SAVE SCENARIO.

In the video tutorial below, we will demonstrate this process for a script with a plaintext password replaced using this crypto service.

This service may be used wherever the values are considered sensitive such as username, password, account numbers, etc.

Masking Selenium Values

When command values contain sensitive information, they can be masked by using the apica Prefixes. This will prevent the value from being displayed in results.

Example

Let’s assume you use a scenario with the following commands:

Command

Target

Value

open

/

selectWindow

null

type

id=username

user1

type

id=password

\{\{${maskapicaPassword}\}\}

clickAndWait

_input@value='Log in'

If you want to mask the value secretPa$$word in the Check Result page the following steps are required:

  • Add the command Store to store the password as a variable with the prefix maskapica

  • Use this variable with the actual command which uses the password.

Your commands should now look like this:

Command

Target

Value

store

secretPa$$word

maskapicaPassword

open

/

selectWindow

null

type

id=username

user1

type

id=password

\{\{${maskapicaPassword}\}\}

clickAndWait

_input@value='Log in'

When Synthetic Monitoring runs a check using this scenario the result will be saved with the executed scenario commands list as the example above. When Synthetic Monitoring shows the check result on the check results page Synthetic Monitoring will recognize that there is a command value which starts with maskapica.

The command’s target will be masked on the the check results page:

Command

Target

Value

store

*******

maskapicaPassword

open

/

selectWindow

null

type

id=username

user1

type

id=password

\{\{${maskapicaPassword}\}\}

clickAndWait

//input@value='Log in'

Prefixes

Synthetic Monitoring supports custom security prefixes for use in select scenario values where information may need more security.

‘apica’ to store information

Store a result with “apica”

Synthetic Monitoring will store the command result for later display when the "apica" prefix is used in a command value.

Display

The command value is shown in Details in the Details Result Scenario in the Value column.

Example

Command

Target

Value

storeCookieByName

ServerID

apicaServerID

This example will store the ServerID cookie value and show it as apicaServerID Extracted Value.

This prefix will work with any command that starts with “store."

 

‘maskapica’ hide a value

Maskapica

When the "maskapica" prefix is used in a command value, the web performance monitor will store the command target (the example Target below is '$(ExternalPassword) ') as is in the result but will mask it (as the example Value below, “maskapicaPassword“) on the check result page. 

Example

Limitations of Selenium IDE within ASM Scenarios

Key Codes

When using sendKeys in Selenium IDE, certain key codes are not available in Scenario Migration.

Overview

${KEY_ENTER}

${KEY_SHIFT}

${KEY_LEFT}

JavaScript Execution

WebDriver’s JavascriptExecutor will wrap all JS and evaluate it as an anonymous expression.

Impact on JavaScript execution

This means that you need to use the “return” keyword:

browserbot.getCurrentWindow().document.title

becomes

return document.title;

The same is true when evaluation expressions using storeEval or assertEval:

Selenium IDE

assertEval

\{\{${stored_var} > 0\}\}

true

WebDriver

assertEval

\{\{return ${stored_var} > 0\}\}

true

Note that there are multiple commands that will result in javascript evaluation: gotoIf, assertEval, getEval, storeEval

Key Strokes

If you need to simulate a keypress input event, such as pressing the enter key, you must use keyPress or keyPressAndWait (if the keystroke triggers a new page load), with the ASCII as an argument.

Overview

Example: Press enter key and wait for new page load

keyPressAndWait

id=gh-ac

\13

Response Times

Agents running Microsoft Windows may handle very short report times incorrectly.

Waterfall graph

Agents running Microsoft Windows sometimes report 0ms for URL calls with very quick response times (0-20ms).

Return Required

For Selenium commmands that execute javascript snippets, the command expects a returned value

Return Command In Scripts

The following commands result in javascript evaluation/expects a javascript snippet as argument, which must include the 'return' keyword:

GotoIf

RunScript

RunScriptAndWait

GetEval

StoreEval

StoreExpression

Type & sendKeys

Even though the "type" command should work in most cases, we strongly recommend that you use "sendKeys" instead.

Key Strokes

If you need to simulate a key press input event, such as pressing the enter key, you must use keyPress or keyPressAndWait (if the key stroke triggers a new page load), with
the ascii code as argument:

Example: Press enter key and wait for new page load
keyPressAndWait | id=gh-ac | \13

Script Variables

It is currently not possible to change the value of a variable from within a javascript.

##

This Selenium IDE code will change the value of $counter:

 storeEval

return (storedVars'counter' + 1)

counter

However the following example won't affect the value of $counter

 runScript

storedVars'counter' += 1;

  • No labels