Robot Input

Most robots executed through the API will be parametrized through input, such as a search keyword, or login credentials. Input to a robot is part of the request to RoboServer, and is provided using the createInputVariable method on the request. Let us look at a short code fragment.

var request = new Request("Library:/Tutorials/Input.robot");
request.CreateInputVariable("userLogin").SetAttributeEntry("username", "scott").SetAttributeEntry("password", "tiger");

Input using implicit RQLObjectBuilder

Here we create a Request and use CreateInputVariable to create an input variable named userLogin. We then use setAttribute to configure the username and password attributes of the input variable.

The above example is a common shorthand notation, but can also be expressed move verbosely by using the RqlObjectBuilder:

var request = new Request("Library:/NewsMagazine.robot");
RqlObjectBuilder userLogin = request.CreateInputVariable("userLogin");
userLogin.SetAttributeEntry("username", "scott");
userLogin.SetAttributeEntry("password", "tiger");

Input using explicit RQLObjectBuilder

The two examples are identical. The first utilizes the cascading method invocation on the anonymous RqlObjectBuilder and is therefore shorter.

When RoboServer receives this request the following occurs:

If a robot requires multiple input variables, you must create all of them in order to execute the robot. You only have to configure required attributes, any no-required attributes that you don't configure through the API will just have a null value. If we assume you have a robot that requires login to both Facebook and Twitter, you could define the input like this.

Request request = new Request("Library:/Input.robot");
request.CreateInputVariable("facebook").SetAttributeEntry("username", "scott").SetAttributeEntry("password", "facebook123");
request.CreateInputVariable("twitter").SetAttributeEntry("username", "scott").SetAttributeEntry("password", "twitter123");