Sample/howtos of advanced topics

The following short script shows more complex structures, such as conditional execution (if), and a numbered loop (for), along with assigning and using variables in Javascript and selenese.

comment ### LOOP EXAMPLE FROM 1 TO 10
store 1 loopVariable1
while storedVars.loopVariable <= 10
echo Value in between while and endWhile is ${loopVariable}
storeEval storedVars.loopVariable++
endWhile

comment ### CONDITIONAL EXAMPLE
gotoIf storedVars.loopVariable >= 1 SKIP
comment This command will not be executed, because loopVariable >= 1
label SKIP



POLYMER/WEBCOMPONENT SUPPORT

The webdriver protocol, and every browser but Google Chrome, do no support at all to test/manipulate those javascript frameworks.

Copado Recorder does its best to record/analyze the actions taken in the browser, but some actions are simply outside the standards. In that case, the only workaround is to right-click an element, add it to the Copado Recorder, and edit the command and value columns to something suitable.

RICH TEXT FIELDS

We offer limited support for rich text editors, allowing to "type" HTML in those kind of elements, but recording cannot work.

In Salesforce classic/lightning, you can right click in the label of a field (not the field itself) and add it to the copado recorder, then change the command to type, the locator to copado=field:XXX (instead of copado=label:XXX ) and put the text in the value column.

TESTING SLOW ACTIONS

Some actions are slow and might require hard to predict delays. A simple way to deal with that is by using the "pause <milliseconds>" command.
But that inserts a fixed pause, which might slow down every execution. A better alternative is to wait for something on the page to change. E.G.: if there is a Status field in a salesforce page, that will automatically change to Completed, and might take up to 5minutes ( 300000ms ) you could use:

setTimeout 300000
waitForValue copado:detail:Status Closed

This will wait for the value to change to  "Closed", for up to 5min. Bear in mind that if you want to reset the timeout to its default value ( 30 seconds ), instead of keeping it for 5 minutes you need to add another setTimeout after the waitForValue

HANDLING NUMERIC VALUES IN WEBPAGES

Selenese and html in general deals with text only, so, in order to perform any arithmetic operation or comparison, it's necessary to convert the text to a javascript number.

the following example shows, in bold, how to extract a fragment of text representing a number, how to convert it to a javascript number, and then how to perform arithmetic operations.

comment
Create an opportunity
open
/006/e?retURL=%2F006%2Fo
type copado=field:Opportunity Name {!RUN_ID}  test opp
type copado=field:Close Date {!TODAY}
select copado=field:Stage Prospecting
type copado=field:Amount 102.65
click
copado=button: Save
comment
Get the text in the locator, and store it in the variable ATEXT
storeValue copado=detail:Amount ATEXT
echo
the locator contains the text: ${ATEXT}
comment
Convert it to a number, removing any non-number character ($, %, comma, whitespaces, etc)
storeEval parseFloat(storedVars.ATEXT.replace(/[^0-9]+/g,"")) ANUMBER
comment
Now, you can treat storedVars.ANUMBER as a regular number in javascript
verifyEval storedVars.ANUMBER+1000 > 1100
TRUE
Comments