Skip to content

register_parameter

roei sabag edited this page Jul 12, 2020 · 1 revision

Description

Saves a parameter under application parameters collection (key/value collection), which allows other actions to access and use the saved value. This action supports locators, elements, attributes, regular expressions and macros.

Scope

Web, Mobile Web, Mobile Native or any other Web Driver implementation.

Properties

Property Description
argument Plugin conditions and additional information.
elementAttributeToActOn The element attribute from which to extract information for action execution. If not specified, information will be taken from the element inner text.
elementToActOn The locator value by which the element will be found.
locator The locator type by which the element will be found.
regularExpression A pattern by which the extracted information will be evaluated. Returns the first match.

Command Line Arguments (CLI)

key

Sets the [key] of the parameter. The [key] is the parameter name and will be used by other actions when calling this parameter.

value

Sets the [value] of the parameter. If this argument is provided, this plugin will ignore any element based value, even if element information was provided.

W3C Web Driver Protocol

None

Examples

Example no. 1

Save //tr[1]/td[2] inner text into [first_name] application parameter.

Action Rule (JSON)

{
    "actionType": "RegisterParameter",
    "argument": "first_name",
    "elementToActOn": "//tr[1]/td[2]"
}

Rhino Literal

register parameter {first_name} take {//tr[1]/td[2]}

CSharp

// option no.1
var actionRule = new ActionRule
{
    ActionType = CommonPlugins.RegisterParameter,
    Argument = "first_name",
    ElementToActOn = "//tr[1]/td[2]"
};

// option no.2
var actionRule = new
{
    ActionType = "RegisterParameter",
    Argument = "first_name",
    ElementToActOn = "//tr[1]/td[2]"
};

Python

action_rule = {
    "actionType": "RegisterParameter",
    "argument": "first_name",
    "elementToActOn": "//tr[1]/td[2]"
}

Java Script

var actionRule = {
    actionType: "RegisterParameter",
    argument: "first_name",
    elementToActOn: "(//table//a)[1]"
};

Java

ActionRule actionRule = new ActionRule()
        .setActionType("RegisterParameter")
        .setArgument("first_name")
        .setElementToActOn("(//table//a)[1]");

Example no. 2

Save //tr[1]/td[2] inner text into [first_name] application parameter.

Action Rule (JSON)

{
    "actionType": "RegisterParameter",
    "argument": "{{$ --key:first_name}}",
    "elementToActOn": "//tr[1]/td[2]"
}

Rhino Literal

register parameter {{$ --key:first_name}} take {//tr[1]/td[2]}

CSharp

// option no.1
var actionRule = new ActionRule
{
    ActionType = CommonPlugins.RegisterParameter,
    Argument = "{{$ --key:first_name}}",
    ElementToActOn = "//tr[1]/td[2]"
};

// option no.2
var actionRule = new
{
    ActionType = "RegisterParameter",
    Argument = "{{$ --key:first_name}}",
    ElementToActOn = "//tr[1]/td[2]"
};

Python

action_rule = {
    "actionType": "RegisterParameter",
    "argument": "{{$ --key:first_name}}",
    "elementToActOn": "//tr[1]/td[2]"
}

Java Script

var actionRule = {
    actionType: "RegisterParameter",
    argument: "{{$ --key:first_name}}",
    elementToActOn: "(//table//a)[1]"
};

Java

ActionRule actionRule = new ActionRule()
        .setActionType("RegisterParameter")
        .setArgument("{{$ --key:first_name}}")
        .setElementToActOn("(//table//a)[1]");

Example no. 3

Save [John] into [first_name] application parameter.

Action Rule (JSON)

{
    "actionType": "RegisterParameter",
    "argument": "{{$ --key:first_name --value:John}}"
}

Rhino Literal

register parameter {{$ --key:first_name --value:John}}

CSharp

// option no.1
var actionRule = new ActionRule
{
    ActionType = CommonPlugins.RegisterParameter,
    Argument = "{{$ --key:first_name --value:John}}"
};

// option no.2
var actionRule = new
{
    ActionType = "RegisterParameter",
    Argument = "{{$ --key:first_name --value:John}}"
};

Python

action_rule = {
    "actionType": "RegisterParameter",
    "argument": "{{$ --key:first_name --value:John}}"
}

Java Script

var actionRule = {
    actionType: "RegisterParameter",
    argument: "{{$ --key:first_name --value:John}}"
};

Java

ActionRule actionRule = new ActionRule()
        .setActionType("RegisterParameter")
        .setArgument("{{$ --key:first_name --value:John}}")

Example no. 4

Save the [href] attribute value of //tr[1]/td[6]/a[1] into [link] application parameter.

Action Rule (JSON)

{
    "actionType": "RegisterParameter",
    "argument": "link",
    "elementToActOn": "//tr[1]/td[6]/a[1]",
    "elementAttributeToActOn": "href"
}

Rhino Literal

register parameter {link} take {//tr[1]/td[6]/a[1]} from {href}

CSharp

// option no.1
var actionRule = new ActionRule
{
    ActionType = CommonPlugins.RegisterParameter,
    Argument = "link",
    ElementToActOn = "//tr[1]/td[6]/a[1]",
    ElementAttributeToActOn = "href"
};

// option no.2
var actionRule = new
{
    ActionType = "RegisterParameter",
    Argument = "link",
    ElementToActOn = "//tr[1]/td[6]/a[1]",
    ElementAttributeToActOn = "href"
};

Python

action_rule = {
    "actionType": "RegisterParameter",
    "argument": "link",
    "elementToActOn": "//tr[1]/td[6]/a[1]",
    "elementAttributeToActOn": "href"
}

Java Script

var actionRule = {
    actionType: "RegisterParameter",
    argument: "link",
    elementToActOn: "//tr[1]/td[6]/a[1]",
    elementAttributeToActOn: "href"
};

Java

ActionRule actionRule = new ActionRule()
        .setActionType("RegisterParameter")
        .setArgument("link")
        .setElementToActOn("//tr[1]/td[6]/a[1]")
        .setElementAttributeToActOn("href");

Example no. 5

Save the first [Abe] match, from element //tr[1]/td[1] inner text, into [regex] application parameter.

Action Rule (JSON)

{
    "actionType": "RegisterParameter",
    "argument": "regex",
    "elementToActOn": "//tr[1]/td[1]",
    "regularExpression": "Abe"
}

Rhino Literal

register parameter {regex} take {//tr[1]/td[2]} filter {Abe}

CSharp

// option no.1
var actionRule = new ActionRule
{
    ActionType = CommonPlugins.RegisterParameter,
    Argument = "regex",
    ElementToActOn = "//tr[1]/td[2]",
    RegularExpression = "Abe"
};

// option no.2
var actionRule = new
{
    ActionType = "RegisterParameter",
    Argument = "regex",
    ElementToActOn = "//tr[1]/td[2]",
    RegularExpression = "Abe"
};

Python

action_rule = {
    "actionType": "RegisterParameter",
    "argument": "regex",
    "elementToActOn": "//tr[1]/td[2]",
    "regularExpression" : "Abe"
}

Java Script

var actionRule = {
    actionType: "RegisterParameter",
    argument: "regex",
    elementToActOn: "//tr[1]/td[2]",
    regularExpression: "Abe"
};

Java

ActionRule actionRule = new ActionRule()
        .setActionType("RegisterParameter")
        .setArgument("regex")
        .setElementToActOn("//tr[1]/td[2]")
        .setRegularExpression("Abe");

Example no. 6

Save the current date into [date] application parameter with [yyyy-MM-dd] format.

Action Rule (JSON)

{
    "actionType": "RegisterParameter",
    "argument": "{{$ --key:date --value:{{$date --format:yyyy-MM-dd}}}}"
}

Rhino Literal

register parameter {{$ --key:date --value:{{$date --format:yyyy-MM-dd}}}}

CSharp

// option no.1
var actionRule = new ActionRule
{
    ActionType = CommonPlugins.RegisterParameter,
    Argument = "{{$ --key:date --value:{{$date --format:yyyy-MM-dd}}}}"
};

// option no.2
var actionRule = new
{
    ActionType = "RegisterParameter",
    Argument = "{{$ --key:date --value:{{$date --format:yyyy-MM-dd}}}}"
};

Python

action_rule = {
    "actionType": "RegisterParameter",
    "argument": "{{$ --key:date --value:{{$date --format:yyyy-MM-dd}}}}"
}

Java Script

var actionRule = {
    actionType: "RegisterParameter",
    argument: "{{$ --key:date --value:{{$date --format:yyyy-MM-dd}}}}"
};

Java

ActionRule actionRule = new ActionRule()
        .setActionType("RegisterParameter")
        .setArgument("{{$ --key:date --value:{{$date --format:yyyy-MM-dd}}}}");

Clone this wiki locally