I've tried to make some keywords in Robot Framework which has arguments embedded in the keyword name, according to (Robot Docs), but unfortunately I'm always getting None when I'm checking what is under the variable. Did you meet such behaviour? What have I done wrong??
My keyword example:
Set ${object} state to ${state}
Log To Console ${object}
Log To Console ${state}
Let's assume that ${object} and ${state} are strings, so the call of this keyword looks like this:
${status}= Run Keyword And Return Status Set camera state to locked
Your code is fine. Here is a complete working example:
*** Keywords ***
Set ${object} state to ${state}
Log To Console ${object}
Log To Console ${state}
*** Test Cases ***
Example test case
${status}= Run Keyword And Return Status Set camera state to locked
Should be True ${status}
Related
When I execute spss syntax commands from a .sps script, each command is written to the output window before it executes giving me a clear log of exactly how an output was created.
Even if the command is an INSERT command executing a different script - I get a log of the commands from that script.
This is very useful for many reasons:
sanity checking - I can always see exactly what went in to creating a specific output (which filters I used, etc.)
recreation - I (or someone else with this output) can easily re-run the same commands because they're right there.
debugging - if there's an error, I can see which commands caused it
However, when I run commands using spss.Submit inside a python block (in a BEGIN PROGRAM-END PROGRAM block), the actual commands called aren't logged into the output window.
I know I can find a full log in a log file - but that's not helpful.
Is there a way to tell spss to continue to log all the commands in the output window?
You can use set mprint on. before the begin program statement to have the syntax that is run via spss.Submit()show up in the output window. I like simpy putting it on the very top of my syntax file as a "set it and forget it".
For example like so:
set mprint on.
begin program python3.
import spss
vars = list(range(1,11))
for var in vars:
spss.Submit(f'compute v{var} = 0. ')
end program.
In one of my projects weare using Robot Framework and a special listener to push results via XRAY to Jira.
Now, we want to call Robot Framework in two different modes named A or B, and different labels need to pushed via XRay to Jira.
I don't want to set some environment variables prior to call robot, as they are really hard to track.
What might be the easiest way to make a global variables of a Robot Framework run accessible in a Robot Framework listener.
I just want to call robot something like this:
robot --listener XRayListener.py --variable Mode:A
How, can I now access the variable Mode inside of XRayListener.py
As detailed in this article , from the listener python code you can use BuiltIn().get_variables() to obtain a given variable value.
from robot.libraries.BuiltIn import BuiltIn
ROBOT_LISTENER_API_VERSION = 2
def end_test(name, attributes):
print("BROWSER = '%s'" % BuiltIn().get_variables()['${BROWSER}'])
Then run it as:
robot --listener ShowVariable simple.robot
The robot file, just for mere reference was:
*** Settings ***
Library SeleniumLibrary
*** Variables ***
${URL} https://www.google.com/
${REMOTE_URL} http://192.168.56.1:4444/wd/hub
${BROWSER} Chrome
*** Test Cases ***
Confirm login popup is accessable
#Go To ${URL}
open browser ${URL} ${BROWSER}
set window size 350 800
[Teardown] Close Browser(base
I am trying to minimize my Robot Keywords and in my URL testing I sometimes have to build up a URL from a group of inputs, that can vary depending on the test. The length can be anywhere from 4 to 7 input parameters that I am catenating to pass back one URL with whatever input parameters are passed in.
If I have a keyword that does the following:
inputs: ${location01} ${location02} ${location03}=${EMPTY} ${location04}=${EMPTY}
${my_url} = Catenate SEPARATOR=/ ${location01} ${location02} ${location03} ${location04}
[Return] ${my_url}
What is the best method to test if ${location03} is empty, and I can therefore skip the rest?
When I have tried to test for ${EMPTY}, so that the following will be false
${my_url} Run Keyword IF '${location03}'!='${EMPTY} Catenate SEPARATOR=/ ${location01} ${location02} ${location03} ${location04}
I still get a catenated string but end up with extra /'s at the end, so ${my_url} looks like:
${my_url} = ${location01}/${location02}//
When I want:
${my_url} = ${location01}/${location02}
I may be missing how Robot is doing checks, and initializing my variables, I'm sure there is a way to do this that is eluding me at the moment.
Sounds like you need to use #{args} to handle variable number of parameters:
*** Keywords ***
Create URL
[Arguments] #{args}
${url}= Catenate SEPARATOR=/ #{args}
*** Test Cases ***
Test Url
Create URL http://stackoverflow.com questions robotframework
Create URL http://stackoverflow.com questions
I am writing a small program in Progress that needs to write an error message to the system's standard error. What ways, simple if at all possible, can I use to print to standard error?
I am using OpenEdge 11.3.
When on Windows (10.2B+) you can use .NET:
System.Console:Error:WriteLine ("This is an error message") .
together with
prowin32 2> stderr.out
Progress doesn't provide a way to write to stderr - the easiest way I can think of is to output-through an external program that takes stdin and echoes it to stderr.
You could look into LOG-MANAGER:WRITE-MESSAGE. It won't log to standard output or standard error, but to a client-specific log. This log should be monitored in any case (specifically if the client is an application server).
From the documentation:
For an interactive or batch client, the WRITE-MESSAGE( ) method writes the log entries to the log file specified by the LOGFILE-NAME attribute or the Client Logging (-clientlog) startup parameter. For WebSpeed agents and AppServer servers, the WRITE-MESSAGE() method writes the log entries to the server log file. For DataServers, the WRITE-MESSAGE() method writes the log entries to the log file specified by the DataServer Logging (-dslog) startup parameter.
LOG-MANAGER:WRITE-MESSAGE("Got here, x=" + STRING(x), "DEBUG1").
Will write this in the log:
[04/12/05#13:19:19.742-0500] P-003616 T-001984 1 4GL DEBUG1 Got here, x=5
There are quite a lot of options regarding the LOG-MANAGER system, what messages to display, where the file is placed, etc.
There is no easy way, but in Unixen you can always do something like this using OUTPUT THROUGH (untested):
output through "cat >&2" no-echo unbuffered.
Alternatively -- and this is tested -- if you just want error messages from a batch-mode program to go to standard out then
output through "tee" ...
...definitely works.
Hii ppl I am trying to pass parameter thro msiexec in command prompt . The problem is eventhough the parameter is passed properly the value doesnt get reflected in the OnBeforeInstallEvent. Therefore the msi doesnt get installed.
The OnBeforeInstall is written C#.net framework 2.09 (VS 2005) and the event call is given below,
string serverName=Context.Parameters["SERVERNAME"].
For example, In the custom action the parameter is properly declared as /SERVERNAME=[SERVERNAME] so as to access the server name.
There is no problem when I install thro normal UI mode when I pass the parameter thro Msiexec the value doesnt get reflected at the OnBeforeInstall event. I even tried logging the flow of installation thro MSIEXEC /Log , the value gets changed in log ( shown below)
PROPERTY CHANGE: Adding SERVERNAME property. Its value is 'machine1'.
I have given below the msiexec command which I use to pass values,
msiexec.exe /i "C:\Server.msi" /l*v "C:\Server.txt" ALLUSERS=1 REBOOT=ReallySupress TARGETDIR="C:\Program Files\Server" SERVERNAME="machine1" PORT="9090"
but on reaching ONBeforeInstall the value is empty (show below).
Error 1001. An exception occurred in the OnBeforeInstall event handler of Server.ServicesInstaller. --> Installation cannot be continued as some of the installation parameters are not given.
More Info -Server Name cannot be empty.
DEBUG: Error 2769: Custom Action _542E7AC5_7403_434A_874B_DE2872A4848D.install did not close 1 MSIHANDLEs.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2769.
Moreover, the Operating system is Win 2003 . I even tried the Msiexec in Win XP too Still no go. The SERVERNAME is the property name of one of the textboxes in the TextBox2 Dialog box of setup kit. While observing the installation log , the property change event is recognizing the value change for SERVERNAME but It becomes null while reaching the OnBeforeInstall event don kno wy.
As said earlier it works perfectly in normal UI mode. I even tried modifying the property table of Server.msi thro ORCA(as given below).
Table :Property
Row :SecureCustomProperties Property -> SecureCustomProperties Changed value from NEWERPRODUCTFOUND to NEWERPRODUCTFOUND;SERVERNAME
Still no go
Please Help.
Many thanks,
byfour
Hii PPl,
I fixed it myself I jus removed the rows like CustomTextA_SetProperty_EDIT1 from customaction table and their refferences in other tables using ORCA and it solved the issue.
Many thanks,
byfour