The command that the <process> element runs can access the value of an
environment variable using standard ways to do so for the language that
the command is written in. For example, if the <process> element was
running a simple .bat file, named C:\stax\getenv.bat it could do so as
follows:
Here's the contents of C:\stax\getenv.bat that echos the value of the
STAXJOB environment variable:
C:\stax>type getenv.bat
echo "STAX Job ID=%STAXJOB%"
Here's an example of setting the STAXJOB environment variable to 1 and
running getenv.bat via the command line getting its value:
C:\stax>set STAXJOB=1
C:\stax>getenv.bat
C:\stax>echo "STAX Job ID=1"
"STAX Job ID=1"
Here's an example of a STAX Job that runs getenv.bat via a <process>
element in a STAX job to get the value of the STAXJOB environment
variable:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">
<stax>
<defaultcall function="test"/>
<function name="test">
<sequence>
<script>command = 'C:/stax/getenv.bat'</script>
<process>
<location>'local'</location>
<command mode="'shell'">command</command>
<envs>['STAXJOB=%s' % (STAXJobID)]</envs>
<stderr mode="'stdout'"/>
<returnstdout/>
</process>
<if expr="RC == 0">
<script>
msg = 'Output from "%s" command:\n%s' % (command,
STAXResult[0][1])
</script>
<else>
<script>
msg = 'Command "%s" failed with RC=%s, STAFResult=%s,
STAXResult=%s' % \
(command, RC, STAFResult, STAXResult)
</script>
</else>
</if>
<log message="1">msg</log>
<return>msg</return>
</sequence>
</function>
</stax>
Then when this STAX job is run, you can see that the STAXJOB environment
variable is accessible via setenv.bat as follows:
C:\>STAF local STAX EXECUTE FILE C:/stax/getSTAXJobID.xml WAIT
RETURNRESULT
Response
--------
{
Job ID : 24
Start Date-Time: 20130729-07:22:23
End Date-Time : 20130729-07:22:24
Status : Normal
Result : Output from "C:/stax/getenv.bat" command:
C:\>echo "STAX Job ID=24"
"STAX Job ID=24"
Job Log Errors : []
Testcase Totals: {
Tests : 0
Passes: 0
Fails : 0
}
}
If the <process> element is a Java program (instead of a .bat file), Java
provides APIs to get the value of an environment variable as does other
programming languages. Simply google for how to do this via the
programming language that you are using.
Or you can pass the STAXJobID variable's value to your command as a
parameter. For example, if your command was the following passParm.bat
file:
C:\stax>type passParm.bat
echo "STAX Job ID=%1%"
Here's an example of running passParm.bat via the command line and passing
it STAX Job ID 1 and how passParm.ba gets the value of this argument
passed to it:
C:\stax>passParm.bat 1
C:\stax>echo "STAX Job ID=1"
"STAX Job ID=1"
C:\stax>
Your STAX job could pass the STAXJobID variables value to
C:\stax\passParm.bat as follows:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">
<stax>
<defaultcall function="test"/>
<function name="test">
<sequence>
<script>command = 'C:/stax/passParm.bat %s' % (STAXJobID)</script>
<process>
<location>'local'</location>
<command mode="'shell'">command</command>
<stderr mode="'stdout'"/>
<returnstdout/>
</process>
<if expr="RC == 0">
<script>
msg = 'Output from "%s" command:\n%s' % (command,
STAXResult[0][1])
</script>
<else>
<script>
msg = 'Command "%s" failed with RC=%s, STAFResult=%s,
STAXResult=%s' % \
(command, RC, STAFResult, STAXResult)
</script>
</else>
</if>
<log message="1">msg</log>
<return>msg</return>
</sequence>
</function>
</stax>
Then when this STAX job is run, you can see that the STAXJobID variable
passed to passParm.bat is accessible via it as follows:
C:\>STAF local STAX EXECUTE FILE C:/stax/getSTAXJobID2.xml WAIT
RETURNRESULT
Response
--------
{
Job ID : 25
Start Date-Time: 20130729-07:33:53
End Date-Time : 20130729-07:33:53
Status : Normal
Result : Output from "C:/stax/passParm.bat 25" command:
C:\>echo "STAX Job ID=25"
"STAX Job ID=25"
Job Log Errors : []
Testcase Totals: {
Tests : 0
Passes: 0
Fails : 0
}
}
If the <process> element is a Java program (instead of a .bat file), Java
provides access to the arguments passed to it as does other programming
languages. Simply google for how to do this via the programming language
that you are using.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
From: sandeep bhosale <sandeep.bhos...@gmail.com>
To: Sharon Lucas/Austin/IBM@IBMUS,
Cc: staf-users@lists.sourceforge.net
Date: 07/29/2013 06:33 AM
Subject: Re: [staf-users] Need help to send message back to STAF
Hi SHaron.
Thank You very much for the information. I have tried putting the
STAXJobID in environment variable but I am not able to get its value.
Below is the xml snippet which i am using to get the STAXJOBID
<function name="GetJobID">
<sequence>
<script>
staxvar = 'STAXJobID'
</script>
<process>
<location>'local'</location>
<command mode="'shell'"></command>
<envs>['STAXJOB=%s' %(staxvar)]</envs>
</process>
<log message="1">
'Current JobID is RC=%s STAFResult=%s' % (RC, STAXJobID)
</log>
</sequence>
</function>
Can you please tell me how do I get only STAXJOBID ? I need this staxjobid
for log information in my selenium test cases.
Thank you,
Regards,
SAndeep
On Fri, Jul 26, 2013 at 5:32 PM, Sharon Lucas <luc...@us.ibm.com> wrote:
STAX provides a variable named STAXJobID in a STAX job that contains the
job ID of the currently running STAX job (as talked about in section "STAX
Variables" in hte STAX User's Guide at
http://staf.sourceforge.net/current/STAX/staxug.html#Header_StaxVariables
). You could provide its value to your Selenium testcase when starting it
via a <process> element in your STAX job (e.g. by passing its value as a
parameter or by setting it as an environment variable via the <env>
sub-element of the <process> element).
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
From: sandeep bhosale <sandeep.bhos...@gmail.com>
To: Sharon Lucas/Austin/IBM@IBMUS,
Cc: staf-users@lists.sourceforge.net
Date: 07/26/2013 05:57 AM
Subject: Re: [staf-users] Need help to send message back to STAF
Hi Sharon,
Thank you for the quick response and the valuable information. I have
created a handle and using the LOG service I am able to send message to
STAX Monitor.
The log's Submit request needs a STAX job id to whom the message would be
send. Now is there any way from where i can get this job id (on the client
machine where my selenium test cases run)from the STAX Monitor (hosted on
different machine)?
Right now for testing purpose I am manually putting the job id in my code
by seeing it on STAX Monitor.
Below is my code snippet
string Where = "10.211.105.106";
string Service = "STAX";
string Request = "SEND JOB 42 MESSAGE \"Selenium Test Started\"";
string Request1 = "SEND JOB 42 MESSAGE \"Selenium Test FInished\"";
STAFHandle log = new STAFHandle("STAFProc.exe");
log.Submit(Where, Service, Request);
System.Threading.Thread.Sleep(10000);
log.Submit(Where, Service, Request1);
Now in above example the JOB ID 42 is hard-coded. Now when the Job is
submitted from the STAX Monitor, is there any way from where I can get the
current Job ID?
Thank You very much for your help.
Regards,
Sandeep
On Thu, Jul 25, 2013 at 6:57 PM, Sharon Lucas <luc...@us.ibm.com> wrote:
You could use the STAF MONITOR service to log a message that the STAX
Monitor displays for a process running in a STAX job.
For each <process> element represented in the "Active Job Element" panel
in the STAX Monitor, if the process generates STAF Monitor Service
messages (see section "8.11 Monitor Service", subsection "8.11.4 LOG" of
the STAF User's Guide at
http://staf.sourceforge.net/current/STAFUG.htm#HDRMONSRV), the current
monitor message is displayed to the right of the process name and elapsed
time. The monitor information is periodically refreshed while the process
is running. If the process has not written any STAF Monitor information,
the text "No STAF Monitor information available" is displayed.
Your Selenium test case could create a STAF Handle and use it to submit a
LOG MESSAGE request to the MONITOR service to send messages to the STAX
Monitor. STAF provides APIs to submit STAF service requests for Java,
Perl, Python, C/C++, and Tcl. Or you can submit a STAF service request
using the STAF command line executable.
Or instead of using the MONITOR service to provide a message to the STAX
Monitor, you could use the STAX service's SEND MESSAGE request to send a
message to the STAX Monitor. See section Request Syntax"", sub-section
"SEND MESSAGE" in the STAX User's Guide at
http://staf.sourceforge.net/current/STAX/staxug.html#Header_Send for more
information. Your Selenium test case could create a STAF Handle and use
it to submit a SEND MESSAGE request to the STAX service to send a message
to the STAX Monitor. STAF provides APIs to submit STAF service requests
for Java, Perl, Python, C/C++, and Tcl. Or you can submit a STAF service
request using the STAF command line executable
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
From: Sandeep <sandeep.bhos...@gmail.com>
To: staf-users@lists.sourceforge.net,
Date: 07/25/2013 12:42 AM
Subject: [staf-users] Need help to send message back to STAF
Hi all,
I am evaluating staf framework for my project. I am using STAX along with
STAF.
I have written some selenium test cases in c#. I am running the selemium
test
cases on remote machine. I am running the selenium test cases using the
STAX
Job Monitor. While running the selenium test cases on remote machine, I am
not
able to get any information on my STAX Job Monitor.
Here I want to send message to the STAX Job Monitor console from my
selenium
test cases. Is this possible to send message back to STAX Job Monitor from
the
selenium code? Can anybody help me how to do this?
Thank You,
Regards,
Sandeep
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users