-1

I am posting the results of automated tests to an offline forum. It would be nice to include PASS/FAIL in the forum post title but I'm having some difficulties retrieving the ${TEST STATUS} value - (obviously a hard-coded value works fine) .

I've defined the following in common-variables.robot as:

${FORUM_TEST_RESULT}....${TEST STATUS}

then on publish-results.robot

Input Text....//*[@id="title"]....${FORUM_TEST_RESULT}

The error I get is: variable ${FORUM_TEST_RESULT} not found

I can see here: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#listener-interface that ${TEST STATUS} can only be used as part of Teardown.

I'm not sure how to collect the value of ${TEST STATUS} in the context of my RF script.

e.g the very last thing my script does is post to a forum:

Input Text....//*[@id="title"]....${FORUM_TEST_RESULT}

but before that I obviously need to populate ${FORUM_TEST_RESULT} with the value of ${TEST STATUS) which you can only get on Teardown? Hope this makes sense.

1 Answers1

0

Input Text is a keyword of Selenium2Library that types the given text into the text field of a web page. You need to start a browser session first and open the right page an then possibly wait for the element to become visible, for example like this:

Open Browser    [URL of your site]
Wait Until Element Is Visible    //*[@id="title"]
Input Text    //*[@id="title"]     ${FORUM_TEST_RESULT}

If you want to retrieve a text from a page (as your coment suggests) then you need to use the keyword Get Text which returns the text of the element identified by locator.

Get Text    locator
Würgspaß
  • 4,660
  • 2
  • 25
  • 41
  • Thank you but I think you have misunderstood my question. I cannot retrieve the value ${TEST STATUS} (Automatic variable) value. At the end of the test the final stage is posting a result on the forum and I want to get this value. – resourceful-idiot Oct 10 '18 at 12:44
  • then maybe you should edit your question in order to clarify. You are using Selenium2Library and get an exception. I explained why this exception occurs and how to avoid it. If you cannot run a browser for any reason then Selenium2Library is the wrong tool to use. – Würgspaß Oct 10 '18 at 12:45
  • It works perfectly hard-coded, so I don't think its anything to do with browser sessions of element visibility. – resourceful-idiot Oct 10 '18 at 12:53
  • Really? What does the error message in your question tell us? **the error I get is: ElementNotVisible Exception: Message: element not visible** – Würgspaß Oct 10 '18 at 12:59
  • Ok, I added your code and now this is problematic error occurred which was my original issue: variable ${FORUM_TEST_RESULT} not found. I will update the this post. – resourceful-idiot Oct 10 '18 at 13:07
  • Have you declared your varaible file in your test case file? – Würgspaß Oct 10 '18 at 13:20