Currently I am trying to deal with dynamic content that is being added via a JavaScript Method. I wish to retrieve which content actually is being dynamically displayed, to check it via RobotFramework.
The frame that is written into is defined as:
<frame src="/root/paperform/blank.htm" name="paperform" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" scrolling="auto" noresize="" framespacing="0">
Now, one of several methods might be called, for example the following:
<form name="goNoPluginForm" action="/servlet/PFServlet" method="POST" target="paperform">
<input type="hidden" name="template" value="paperform/error/noPlugin.htm">
</form>
The posted error is what I would like to retrieve. I tried to use the "Page Should Contain" and the "Page Should Contain Element" Keywords, which both did not bring the correct result. I do have the feeling on this keywords, that they do only check the initial web source code.
Now, how could I check which error message has been posted into the frame?
I select the Frame via the "Select Frame" Keyword already, which also succeeds. To retrieve the live content of the frame is, where I am currently stuck. I spend a while on researching this already, but I was not able to find an answer to my problem. Please let me know, if you need further information to answer my question. On manually calls of the webpage, all works as intended.
Addition:
I had already tried to use the "Wait Until Keyword Succeeds", one example:
Wait Until Keyword Succeeds ${ElementSearchTime} 1s Page Should Contain Element ${XPath_PluginElement}
Another example:
Wait Until Keyword Succeeds ${ElementSearchTime} 1s Page Should Contain You could still view your document
It unfortunately did not have the wanted result. For me it seems like if the firstly received code was not updated and the "Page Should Contain Element" might not be the keyword that should be used.
EDIT: Yes, I was correct. I should have used the "Current Frame Contains Element" keyword from the Selenium2Library.
have you tried using Wait Until Keyword Succeeds? I felt a bit wrong and dirty using it in the past but I've been told by many others more experienced than me, that this is the way to go. It also got me out of a pickled in a similar scenario to you where a user click generated a row collapse and javascript helped render anything we needed. I'll post my own example when I get into work but here's a basic form from the builtin docs (http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Wait%20Until%20Keyword%20Succeeds) :
If the keyword does not succeed regardless of retries, this keyword fails. If the executed keyword passes, its return value is returned.
Wait Until Keyword Succeeds 2 min 5 sec My keyword argument
${result} = Wait Until Keyword Succeeds 3x 200ms My keyword
All normal failures are caught by this keyword. Errors caused by invalid syntax, test or keyword timeouts, or fatal exceptions (caused e.g. by Fatal Error) are not caught.
Running the same keyword multiple times inside this keyword can create lots of output and considerably increase the size of the generated output files. Starting from Robot Framework 2.7, it is possible to remove unnecessary keywords from the outputs using --RemoveKeywords WUKS command line option. Support for specifying retry as a number of times to retry is a new feature in Robot Framework 2.9. Since Robot Framework 2.9, variable errors are caught by this keyword.
Real-world example as promised
${row_link_state}= Selenium2Library.Get Element Attribute ${STATIC_TABLE_XPATH}/tbody/tr/td/a@class
Run Keyword If '${row_link_state}' == '${TABLE_LINK_CLASS_COLLAPSED}' Click Element ${STATIC_TABLE_XPATH}/tbody/tr/td/a
... ELSE Fail The row link was not in the expected state
Wait Until Page Contains Element ${STATIC_TABLE_XPATH}/tbody/tr/td/div/p 10
Wait Until Keyword Succeeds 10s 5s Element Should Be Visible ${STATIC_TABLE_XPATH}/tbody/tr/td/div/p
${paragraph_text}= Get Text ${STATIC_TABLE_XPATH}/tbody/tr/td/div/p
Should Be Equal ${STATIC_TABLE_ROW1_TEXT} ${paragraph_text}
I'm aware the above code block looks pretty nasty. Essentially it is checking a table row is in an expected state which is handled by javascript. The link in question flicks its class between two values to depict its state. If it's in the expected state, we click on the table row which causes it to expand and reveal its contents. You will notice the Wait Until Page Contains is a bit obsolete but it was still a bit flakey, its presence seems to slow things down enough for it to give repeatable results. The wait until keyword succeeds then ensures the text I want to use is visible on the page before I attempt to get it and use it as a variable. It is the only way I was able to get the above working.
See if you have any success with the above, if you're having trouble, post the code and issues here and I'll help out.