Keyword 'BuiltIn.Exit For Loop If' expected 1 argument, got 2 - selenium

I am new learner of RobotFramework, I tried to run this code, but this error shows: Keyword 'BuiltIn.Exit For Loop If' expected 1 argument, got 2. Thank you in advance!
Select the Card
[arguments] ${cardName}
${elements} = Get WebElements css:.card-title
${index}= Set Variable 1
FOR ${element} IN #{elements}
Exit For Loop If '${cardName}' == '${element.text}'
${index}= Evaluate ${index} + 1
END

You have two spaces after ==. Robot uses two or more spaces as argument separators so it sees '${cardName}' == as one argument and '${element.text}' as a second argument.
The solution is to make sure the entire expression doesn't have any sequences of two or more spaces.
Exit For Loop If '${cardName}' == '${element.text}'

Related

How can I save a column in a table and check if there is Text in each of the cells in the Robot Framework Selenium?

I plan to create a For for the cell of the table and save the content, to preguantar with an IF if it has Text or not.
But I do not know how a For and an IF within a Table work.
Verificar Recibo Pagado
${Texto} = Get Table Cell ${Tabla} 11 9
Run Keyword If ${Texto}
log ${Texto}
Nice to see Spanish usage in your test case. :)
To verify table data, we need to do nested loop logically. But we can't write nested loop directly in Robot Framework. We can make separate keyword for innerloop and we can call it in main for loop.
For.e.g.,
If your variable ${Tabla} refers to xpath as //table[#id='some id'] and all rows has same columns, Then test case to verify no empty data in cells will be as below,
*** Variables ***
${Tabla} //table[#id='some id']
*** Test Cases ***
Verificar Recibo Pagado
${fila} = Get Element Count ${Tabla}/tbody/tr # Get row count
:FOR ${rowindex} IN RANGE 1 ${fila + 1}
\ All Column Should Not Be Empty ${Tabla} ${rowindex}
*** Keywords ***
All Column Should Not Be Empty
[Arguments] ${Tabla} ${fila}
${columna} = Get Element Count ${Tabla}/tbody/tr/td # Get Column count
:FOR ${colindex} IN RANGE 1 ${columna + 1}
\ ${Texto} = Get Table Cell ${Tabla} ${fila} ${colindex}
\ Should Not Be Empty ${Texto}

Iterate on OrientRecord object

I am trying to increment twice in a loop and print the OrientRecord Objects using Python.
Following is my code -
for items in iteritems:
x = items.oRecordData
print (x['attribute1'])
y=(next(items)).oRecordData #Here is the error
print (y['attribute2'])
Here, iteritems is a list of OrientRecord objects. I have to print attributes of two consecutive objects in one loop.
I am getting the following error -
TypeError: 'OrientRecord' object is not an iterator
Try using a different approach to it:
for i in range(0,len(iteritems),2):
x = iteritems[i].oRecordData
print (x['attribute1'])
y = iteritems[i+1].oRecordData
print (y['attribute2'])
The range() function will start from 0 and iterate by 2 steps.
However, this will work properly only if the total amount (range) of records is an even number, otherwise it'll return:
IndexError: list index out of range
I hope this helps.

Perl6 split function adding extra elements to array

my #r = split("", "hi");
say #r.elems;
--> output: 4
split is adding two extra elements to the array, one at the beginning and another at the end.
I have to do shift and pop after every split to correct for this.
Is there a better way to split a string?
If you're splitting on the empty string, you will get an empty element at the start and the end of the returned list as there is also an empty string before and after the string.
What you want is .comb without parameters, written out completely functionally:
"hi".comb.elems.say; # 2
See https://docs.raku.org/routine/comb#(Str)_routine_comb for more info.
The reason for this is when you use an empty Str “” for the delimiter it is the same as if you had used the regex /<|wb>/ which matches next to characters. So it also matches before the first character, and after the last character. Perl 5 removes these “extra” strings for you in this case (and in this case only), which is likely where the confusion lays.
What Perl 6 does instead is allow you to explicitly :skip-empty values
'hi'.split('') :skip-empty
'hi'.split('', :skip-empty)
split("", "hi") :skip-empty
split("", "hi", :skip-empty)
Or to specify what you actually want
'hi'.comb( /./ )
'hi'.comb( 1 )
'hi'.comb
comb( /./, 'hi' )
comb( 1, 'hi' )

removing blank line when using IF in microsoft word using mail merge

I am actually using conga composer with word template to generate word doc fill with data from my database. There is a section where I have to display from a loop a single line that meet a requirement. This also works fine, but when looping, for each line that do not match the requirement words is leaving a blank line. I don't want blank lines to appear :
Here is my IF condition :
A : {{TableStart:TiersPrestataires}}
{ IF "<<variable>>" = "S1" "<<variable1>> <<variable2>>" ""}
{{TableEnd:TiersPrestataires}}
If in my TiersPrestataires variables I have 5 lines , with the 3rd line that respect the condition, this will print :
A :
<blank_line>
<blank_line>
some text represented by variable 1 some text represented by variable2
<blank_line>
<blank_line>
I want to print :
A:
some text represented by variable 1 some text represented by variable2
and that's all.How can I prevent word to replace the unmet condition with a blank line ? Is there something I can specify in my else condition?
It will be the way you position your brackets.
So I am assuming is another conditional, therefore you would do it like:
A:
{ IF (CONDITION 1) "true
"}{ IF (CONDITION 2) "true
"}{ IF "<<variable>>" = "S1" "<<variable1>> <<variable2>>
"}{ IF (CONDITION 4) "true
"}{ IF (CONDITION 5) "true
"}
If you only want to show content when condition is met then you only need to do one set of " " after the condition as false will be blank anyone.
Doing it this way ensures there are no blank lines left from the IF.
Hope this helps.

Python while loop index error

I've made a reverse function, it reverses the sentence, however it generates index error.
what the program does is append the last word from s and puts it into rev[],
it then deletes the word s[-1].
s = "This is awesome"
def Reverse1(s):
s = s.split(" ") #reverses the word instead of letters
rev = []
while True:
rev.append (s[-1])
del s[-1]
print (rev)
return
reverse1(s)
its returning index error as it tries to continue when s is empty
so I think its the while loop statement.
any ideas?
You need to stop the while loop, you can use something like this
while n in range(len(s)):