How to have multiline keyword documentation in log.html - robotframework

If in a keyword you have the following:
[Documentation] First line
... Second line
... Third line
the HTML log shows "First line Second line Third line"
Is it possibile to have the HTML log show the multiline?

This should work for you:
[Documentation] First line${\n}
... Second line${\n}
... Third line
Let me know :)

Related

How to create a link to a header in restructuredtext?

I have a document in restructuredtest like:
Header 1
========
and from some any other point (might be the same 'rst' file or a different one) I want to create a hyperlink to that header. So that when a user clicks on it, he gets to the page with the header Header 1
How to do that?
I tried to put the following line in the other document (according to this documentation):
see :ref:`Header 1`
but what I get is the following:
see Header 1
without any link...
I also tried to follow this documentation:
What I put in to the rst file is the following
see `Header 1`_
and what I see is the following link:
see `Header 1`_
which does not look very nice ...
Your first link was almost correct. You need to add a label preceding the section header, separated by a blank line. See Inline markup, Cross-referencing arbitrary locations, using the :ref: directive.
In your case:
.. _header-1-label-name:
Header 1
========
Some text
Here is a section reference: :ref:`header-1-label-name`.
Here is a section reference with a title: :ref:`Header 1 with a title <header-1-label-name>`.
In addition to the accepted answer, the label you add (in this case .. _header-1-label-name:) is required to have a dash. So a simple .. _label: won't do. Took me a while to figure that out.

Read variable name from file and use as locator variable

I have a file with locators which I import in my test suite. The file has lines like these:
LOCATOR_ABC='id=abc'
LOCATOR_XYX='id=xyz'
I have another file which contains locator variable names and expected values, so something like this:
LOCATOR_ABC¤hello world
LOCATOR_XYZ¤goodbye world
Now I want to loop through the latter file and do something like this for each line:
${locator}= Fetch From Left ${line} ¤
${value}= Fetch From Right ${line} ¤
${ui_value}= Get Text ${${locator}}
... compare value and ui_value and expect them to match ....
The problem is I get the error:
Variable '${?LOCATOR_ABC}' not found. Did you mean:
${LOCATOR_ABC}
I know the part with ${${locator}} is probably not nice/correct, but changing my setup so the locator¤value file has lines like this:
${LOCATOR_ABC}¤hello world
${LOCATOR_XYZ}¤goodbye world
And then use this in my test instead:
${ui_value}= Get Text ${locator}
The error message is:
ValueError: Element locator '?${LOCATOR_ABC}' did not match any elements.
So I guess my question is if anyone can shed some light on the ? part of the error message? What am I doing wrong? And or is there another/better way to do this?
Problem with file encoding. Changing to ascii encoding solved the problem.

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

How to escape new line in man pages

I have refactored a man page's paragraph so that each sentence is it's own line. When rendering with man ./somefile.3 The output is slightly different.
Let me show an example:
This is line 1. This is line 2.
vs.
This is line 1.
This is line 2.
Are rendering like so:
First:
This is line 1. This is line 2.
Second:
This is line 1. This is line 2.
There is an extra space between the sentences. Note that I have made sure that there is no extra white space. I have more experience with Latex, asciidoc, and markdown and I can control that there, is it possible with troff/groff? I'd like to avoid that if possible. I don't think it should be there.
The troff input standard is to have a newline at the end of each sentence, and to let the typesetter do its job with filling. (Althought I doubt it was the intent, it does make it play nicer with source control.) Therefore, it considers sentence ends to be at the end of a line that ends with a period (or ? or !, and optionally followed by ',",*,],),or †). It also believes that sentences should have two spaces between them. This almost certainly derives from the typography standards at Bell Labs at the time; It's rather curious that this behavior is not settable through any fill modes.
groff does provide a way to set the "inter-sentence" spacing, with the extended .ss request:
.ss word_space_size [sentence_space_size]
Change the size of a space between words. It takes its units as one
twelfth of the space width parameter for the current font. Initially
both the word_space_size and sentence_space_size are 12. In fill mode,
the values specify the minimum distance.
If two arguments are given to the ss request, the second argument sets
the sentence space size. If the second argument is not given, sentence
space size is set to word_space_size. The sentence space size is used
in two circumstances: If the end of a sentence occurs at the end of a
line in fill mode, then both an inter-word space and a sentence space
are added; if two spaces follow the end of a sentence in the middle of
a line, then the second space is a sentence space. If a second
argument is never given to the ss request, the behaviour of UNIX troff
is the same as that exhibited by GNU troff. In GNU troff, as in UNIX
troff, a sentence should always be followed by either a newline or two
spaces.
So you can specify that the "sentence space" should be zero-width by making the request
.ss 12 0
As far as I know, this is a groff extension; heirloom troff supports it, but older dwb derived versions may not.
Example:
This is line 1. This is line 2.
This is line 1. This is line 2.
This is line 1.
This is line 2.
SET SENTENCE SPACING
.ss 12 0
This is line 1. This is line 2.
This is line 1. This is line 2.
This is line 1.
This is line 2.
Results:
$ groff -T ascii spaces.tr |sed -n -e/./p
This is line 1. This is line 2.
This is line 1. This is line 2.
This is line 1. This is line 2.
SET SENTENCE SPACING
This is line 1. This is line 2.
This is line 1. This is line 2.
This is line 1. This is line 2.
So the following will work, but I hope there is a better option.
This is line 1. \
This is line 2.
renders as
This is line 1. This is line 2.

"Element locator with prefix '| id' is not supported" error in Robot framework

I am using robot framework to test a GUI application ,
when I try to run the test case , got an error like
"Element locator with prefix '| id' is not supported " .
But I am using the latest version of selenium2library i.e.2.39.0 .
I will be thankful ,If somebody helps me out regarding the same .
and I have one more query ,i.e. how to click on the contents on GUI when working with robot framework
Thanks in advance
I think the only way you can get such an error message is if you mix two styles of cell separators in your test. For example, you may be mixing tabs and pipes, or multiple spaces and pipes.
Robot determines which format to use on a line-by line basis. First, it looks for a tab anywhere in the line being parsed, and if it finds it, it uses tabs to split the line. If it doesn't find a tab, it checks to see if the line begins with a pipe and space. If so, it uses the pipe for a separator. Failing that, it uses multiple spaces as the separator.
I can reproduce the exact error you are getting by mixing pipes with either a tab or multiple spaces. For example, the following will generate the exact same error you report:
# the next line begins with two spaces
click element | id=treeview_tv_active
Robot will detect the two leading spaces and decide to use spaces to split the line into cells. Thus, the first cell will be "click element" and the second cell will be "| id=treeview_tv_active". Selenium looks for everything before the "=" as the locator type, thus it's using "| id" as the locator, which is invalid and results in the error that you see.
Since you haven't shown us your code it's impossible to say for sure, but my guess is that the line causing the problem begins with a space or tab, or has a tab embedded somewhere else in the line, but later in the same line attempts to use pipes as cell separators.

Resources