Robot framework textarea - robotframework

In robot framework how can I change line in textarea that text comes to new line . Now I have the following code:
: FOR ${INDEX} IN RANGE 1 10
\ Input Text id=edit-message TestMessage\n
but now "TestMessage" writes on the previous one
Thanks!

It is typical to first fetch the value, then concatenate what you want added and then to overwrite the field with the new value.
: FOR ${INDEX} IN RANGE 1 10
\ ${textvalue} Get Text id=edit-message
\ Input Text id=edit-message ${textvalue}\nTestMessage

Try like this.
https://drive.google.com/file/d/1tWcdWLSy0zFTgVpiucOgVnScJJ0rX8SY/view?usp=sharing
Insert the $ {INDEX} index of the for loop into the input text locator to change the line and write to it.

Related

How to put a variable value with semicolons and forwardslashes inside a list and get read by it

Here's my list
#{referentiel} N1(exemple)/N2(exemple) N2(exemple)/exemple
where i use it
Visca barca
[Arguments] ${index}
Click Element Using Javascript //div[#id='mat-select-value-5']
Click element of long page //span[#class='mat-option-text'][contains(.,'#{referentiel}[${index}]')]
And my testcase
we are the best
Visca barca 1
Error :
Value of variable '#{referentiel}[${index}]' is not list or list-like.
The issue you are describing here has nothing to do with the semicolons or slashes. The issue is actually that you are attempting to return the list item with wrong decorator.
To get a single item from a list you should use $ instead of #. When you use # Robot will attempt to return you a list which it cannot since the item on ${index} is a string.
See below:
#{referentiel} # == ['N1(exemple)/N2(exemple)', 'N2(exemple)/exemple']
or
${referentiel[0]} # == N1(exemple)/N2(exemple)

How can I show the data with comma(,) in drop down box on window?

I have written the program to show all the data on window but stuck in the case for showi a single record with comma(,) in drop down box. Let me share codes what i tried.
DEFINE TEMP-TABLE tt_seq_report
FIELD npai_output_expression AS CHARACTER FORMAT "X(50)".
/* Followings are written inside the drop down box using progress app builder */
/* ON VALUE CHANGED OF coCombo-4 Part Type(Label Name) */
DO:
DEFINE VARIABLE cPartTyp AS CHARACTER NO-UNDO.
CREATE tt_seq_report.
ASSIGN
tt_seq_report.npai_attribute_expression = "22+++,56-".
coCombo-4:ADD-LAST(tt_seq_report.npai_attribute_expression).
END.
When I run the window and select the drop down box then i can see the value upto before comma(,) i.e 22+++ but it should show the full value like 22+++,56-. May I get any help regarding this?
You can set the combo-box'es DELIMITER property to any other character. Comma is just a default.
"Delimiter character can have any ASCII value from 1 to 127. The default delimiter is a comma."

Robot Framework Input Text does not enter all text

I'm trying to enter a text into a message field using Input Key. Sometimes it enters all characters and other times it gets cut off. I've tried using Press Key but it does the same thing. Is there another solution?
Example:
Press Key id:noteMessage This is a note from the Robot Framework
What you could do, is insert a loop that runs for example a few times and tries each time to insert the text into the text field. During the loop you read the result of the text field, and if it matches the original text you try to input, you quit the loop.
For example something like:
${retries} = 3
${text} = "Some text that doesn't get fully displayed all the time."
${locator} = id:noteMessage
:FOR element IN RANGE 0 ${retries}
\ Input text ${locator} ${text}
\ ${inserted_text} = Get text ${locator}
\ ${result} = Evaluate ${inserted_text} = ${text}
\ Exit for loop if ${result} = True
Of course you can insert quite a few more failsafes, but this should be a good basis. And of course you should look into the problem why the field doesn't inserted sometimes the key or text.

How to get the count of a class with AppleScript?

Learning AppleScript I'm trying to practice and I wanted to see if I could get the count of a class in an .xhtml file.
In my BBEdit project I set a variable for the project with:
set this_project to file of project document 1
made sure to target all the .xhtml files with:
set total_xhtml to {search mode:grep, case sensitive:false, match words:false, extend selection:false, returning results:true, filter:{ID:"111232452", filter_mode:and_mode, filter_terms:{{operand:"xhtml", field:«constant ****FnSf», operator:op_is_equal}}}}
but when I try to count the class for each file I'm stumped..
I did try:
set varCount to count class=\"foobar\"" of (this_project in total_xhtml)
If I try set varCount to count class=\"foobar\"" it returns a number in the AppleScript Editor but how can I get the full count for each file in a project?
If I understand what you're asking, you want to find out how many times your class is listed in your different .xhtml files.
If that's what you're trying to accomplish, the below is a working example that should do what you're looking for.
on run
try
set foundItems to do shell script "grep -ri 'yourClassName' " & quoted form of "/Path/to/Your/directory"
on error
set foundItems to ""
end try
set oldDelims to AppleScript's text item delimiters -- save their current state
set AppleScript's text item delimiters to {return} -- declare new delimiters
set tempList to every text item of foundItems
set AppleScript's text item delimiters to oldDelims -- restore them
set foundCount to count of tempList
end run
Just realized I never accepted an answer to my question and I wanted to close out this Q&A. I didn't choose the provided answer because text item delimiters were firing an incorrect count from the file and I wanted an approach that didn't call on a do shell.
In AppleScript and BBEdit if you reference the Dictionary there is FIND:
and with a repeat loop I was able to step through each occurrence of class="foobar":
## beginning of file
select insertion point before first character of text document text document 1
set countClass to 0
repeat
## find pattern
set findClass to find "class=\"foobar\"" searching in text 1 of text document text document 1 options {options} with selecting match
## exit after no more patterns
if not found of findClass then exit repeat
## increment for every occurrence
set countClass to countClass + 1
end repeat
## return total count of pattern
return countClass
With the above repeat I was able to step through each file and total up every occurrence of class foobar. Hope this helps the next person.

Removing a block of text lines

Scenario:
#Start1
text
text
text
#Start2
text
#Start3
text
text
As shown above, the blocks are not certain with the number of lines contained with it. Question is how to utilize unix command to remove one of the block say #Start2.
I tried
less <file_name> | sed '/Start2/.+1d' | less
yes it probably works for this case if I can be sure how many lines are tailing the #Start2
But what if the number of lines tailing it is not constant each and everytime #Start2 happens? I might fail to remove all of it or accidentally remove some content of other block.
I need a more sophisticated way of knowing it hits the end of the block. Is there any?
Thanks
Using awk you can do this:
awk '/^#/ {f=0} /^#Start2/ {f=1} !f;' file
#Start1
text
text
text
#Start3
text
text
This awk prints all line as long as f=0 or not true.
f starts with default empty same as 0
If line starts with # set f to 0, so print line.
If line starts with #Start2 set f to 1, do not print.
This will make awk prints all line and stop if it finds #Start2, then continue again if it finds #
Another way to do it:
awk '!/Start2/' RS=# ORS=# file
#Start1
text
text
text
#Start3
text
text
This tell that a record starts with #
If record contains Start2, then do not print it. All other would be printed.
PatStart="#Start2"
PatBlockEnd="^#"
sed -n "/${PatStart}/,/${PatBlockEnd}/ {
/${PatStart}/ {x;s/.*//;x;}
x;p;}" YourFile
Use the 2 Pat... var for setting your block border (End assume this is a new block starting on a NEW LINE, not the end of current block in this case).

Resources