Can't Assign Value of Excel cell To variable in Robot Framework [duplicate] - robotframework

I'm writing a test case in robot framework. I'm getting the response in below json string:
{"responseTimeStamp":"1970-01-01T05:30:00",
"statusCode":"200",
"statusMsg":"200",
"_object":{"id":"TS82",
"name":"newgroup",
"desc":"ttesteste",
"parentGroups":[],
"childGroups":[],
"devices":null,
"mos":null,
"groupConfigRules" {
"version":null,
"ruleContents":null
},
"applications":null,"type":0
}
}
From that I want to take "_object" using:
${reqresstr} = ${response['_object']}
... but am getting the error "No keyword with name '=' found" error
If I try the following:
${reqresstr}= ${response['_object']}
... I'm getting the error "Keyword name cannot be empty." I tried removing the '=' but still get the same error.
How can I extract '_object' from that json string?

When using the "=" for variable assignment with the space-separated format, you must make sure you have no more than a single space before the "=". Your first example shows that you've got more than one space on either side of the "=". You must have only a single space before the = and two or more after, or robot will think the spaces are a separator between a keyword and argument.
For the "keyword must not be empty" error, the first cell after a variable name must be a keyword. Unlike traditional programming languages, you cannot directly assign a string to a variable.
To set a variable to a string you need to use the Set Variable keyword (or one of the variations such as Set Test Variable). For example:
${reqresstr}= Set variable ${response['_object']}

${reqresstr}= '${response["_object"]}'
wrap it inside quotes and two spaces after =

There is a syntax error in your command. Make sure there is a space between ${reqresstr} and =.
Using your example above:
${reqresstr} = ${response['_object']}

Related

Robot "should be equal as strings"

I've got some code in a Robot script that will check a field value is as expected:
${search_box}= Get Value fullSearchBox
Should Be Equal As Strings ${search_string} ${search_box}
When I run the script, a failure is recorded against that verification step. However, when I look at the two strings, I can see no differences between them at all (I've also tried using Should Be Equal).
If the two strings are the same - why am I seeing this failure?
If there is some whitespace on one of the variables, you can strip the whitespace by calling .strip() using the extended variable syntax:
Should Be Equal As Strings ${search_string.strip()} ${search_box.strip()}

How to resolve this error "No keyword with name 'and' found"

When I execute this keyword, 'No keyword with name 'and' found error is displayed.
Test this keyword
[arguments] ${YearDiff} ${MonthDiff}
Run Keyword If ${YearDiff}>=0 and ${MonthDiff}>=0 Click Element id=Left_Calendar_Icon
Run Keyword If ${YearDiff}<=0 and ${MonthDiff}<=0 Click Element id=Right_Calendar_Icon
Correct me if i have used wrong syntax.
You are using the space-separated format, which means that robot uses two or more spaces to separate keywords. You have two spaces on each side of "and" so robot thinks "and" is a keyword. The entire expression needs to fit in a single cell of the test case table.
The solution is to put only one space on each side of "and":
Run Keyword If ${YearDiff}>=0 and ${MonthDiff}>=0 Click Element id=Left_Calendar_Icon

ORM expr evaluate empty string

I have been using and still learning query expr(). I have a complex query where I cannot use if first to check if a parameter is '' - empty string.
I have to check it inside andX with nested orX using something like:
->andWhere($expr->orX($expr->eq(':sid', ''), $expr->neq('s.id', ':sid')))
Note: I know this line can be done by using if check first, I am using it just for an example, I got error says:
Error: Expected Literal, got ' OR '
I really need to compare empty string inside expr(), how?
Because '' is not an empty string. It's nothing and so it evaluates to nothing in DQL/SQL. Normally doctrine expects an named parameter. Either you create one to get quoted empty string or supply an empty string quoted by yourself.
Named parameter:
$qb->expr->eq('foo', ':foo');
$qb->expr->setParameter('foo', '');
quoted by yourself:
$qb->expr->eq('foo', "''");

R error: regular expression is invalid in this locale

I am trying to gather all instances of "Walloni\xeb" within a data-frame column in order to remove "\" using the grep function. However, I'm getting the following error message as shown below:
grep("Walloni\xeb", InvoAndinfo2$Regio)
Error in grep("Walloni\xeb", InvoAndinfo2$Regio) :
regular expression is invalid in this locale
Does anyone know what to do to resolve this?
The backslash is a special character in regexp, if you want to look for a string that has a backslash, you should escape it by adding another backslah in front of it.
Try:
grep("Walloni\\xeb", InvoAndinfo2$Regio)

Association Rules Error

I am running the formula that is given below in R
rules <- apriori(B4_Temp,
parameter = list(minlen=2, supp=0.001, conf=0.6,target="rules"),
appearance = list(rhs=c("Location Info=Level1"),default="lhs"),
control = list(verbose=F))
I am getting this error as:
Error in asMethod(object) :
Location Info=Level1 is an unknown item label,
Location Info=Entrance is an unknown item label
But I have those values in the data set. What is the problem?
I was with the same problem. Take a look at B4_Temp and be sure that your dataset is represented like you are naming there on rhs=c("Location Info=Level1"). Maybe this data's representation is not consistent with your dataset in B4_Temp.
Just remember: the meaning of "item label" is all about the "stuff" you have stored in your data set. If this "stuff" is not equal to the parameter you are trying to set on rhs an error will happen.
It happened with me because my equivalent B4_Temp was with an error in the way I put the "stuff" inside it. My separator was a semi-colon but inside of my equivalent B4_temp there were some characters that was not consistent with the context; for example, there was also the character ".
When I remade my equivalent B4_Temp correctly, I fixed it.

Resources