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.
Related
Example : the file "A.txt" contains several rows with phrases :
This is a phrase
Bla keyword blabla
This is another phrase
Desired results :
in A.txt :
This is a phrase
This is another phrase
in B.txt :
Bla keyword blabla
Then I use the option "Find" keyword then I use "Extract". It extracts the correct rows in a new document (B.txt) but how to also remove the full row(s) containing the selected keyword in "A.txt" ?
This can be easily done with EmEditor. I have provided two methods.
Method 1
Select a keyword, right-click on the selection, and select Filter Out.
Click Extract All on the Filter toolbar.
Save as a new file name.
Method 2
Select a keyword, right-click on the selection, and select Filter.
Make sure Block Multiline Changes is disabled on the Filter toolbar.
Press Ctrl + A to select all text.
Press Delete.
Click the Abort button on the Filter toolbar.
I do the same thing a lot in EmEditor and using only the keyboard, this is the quickest way I know.
Here are my steps:
Highlight the search string and open the Find dialogue Ctrl + F
Alt + T to Extract the lines into a new document/tab
Esc to close the Find dialogue (not needed if option Close when finished in the Find dialogue is active).
Go back to the original source document Ctrl + Tab
Re-open the Find dialogue Ctrl + F
Bookmark the lines Alt + B
Esc to close the Find dialogue (not needed if option Close when finished in the Find dialogue is active).
Delete the bookmarked lines Ctrl + Shift + Backspace
Steps 3 and 7 can be skipped if using the mouse to select the original source document. I just haven't figured how to activate it with the keyboard while the Find window is still open.
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.
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.
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).
I have a textpad file that has rows of text. For e.g.
Cat: Meaning - animal. The cat ran up the house
Rat: Meaning- rodent. The rat lives in the borough and feeds on leftovers
Word 3: Description
Word 4: Description
I have many such record in my file. I want to insert a line break at the end of every record for proper presentation. Doing it manually is tedious. Please help if you know an automated process to insert line break.
You can quickly do this by using a feature called "Regular Expressions" to find and add empty lines.
Open up the Find/Replace (Search menu > Replace)
In the "Find what" field, type the following: (^.+$)\n(^.+$)
In the "Replace with" field, type the following: \1\n\n\2
Tick the "Regular expression" checkbox
Click the Replace All button at least twice, but perhaps 3 times, until you get the message Cannot find the Regular Expression
Untick the "Regular expression" checkbox
Close the Replace dialog
Confirm the file is formatted as you are expecting
Save the file.
You can write a simple C# prgram that uses a loop that adds this code after every line :
But first add the namespace using System.Enviorment
Enviorment.NewLine;
If you have any more trouble i'll help with some code to get started
Open up the Find/Replace (Search menu > Replace)
In the "Find what" field, type the following so that the replace occurs at the end of each line: $
In the "Replace with" field, type the following. Note each 'n' represents a <return>. In this instance, I added a return at the end of a SQL statement, the word 'GO' on the next line and another <return>: \n\GO\n
Started with text file containing:
select * from <tablename>
select * from <tablename>
Ended with text file containing:
select * from <tablename
GO
select * from <tablename>
GO
Hope that helps.
from your text it is difficult to understand what you are intending to do. I'll give you some questions. The answers will help others to help you.
Do you really mean textpad as the product from company helios in UK or do you use this word as a general word for a class of tools (like notepad - but there is a general definition AND the tool as part of Windows).
Your file hase line breaks yet. You don't see them, but in the file itself they are present (in Unix systems line feed (hex code 0A) or in the windows world carriage return followed by line feed (hex code 0D 0A)).
Or would you like to publish your text in HTML? So you have to put the necessary tags around each line like paragraph, line break, list item etc.?