How to start java remote server from robot scripts

239 views
Skip to first unread message

nishadispr...@gmail.com

unread,
May 26, 2018, 8:05:32 AM5/26/18
to robotframework-users
Hi Group,

I'm able to create remote server using java and from command line I'm executing "java -jar xxx.jar". after executing jar file I'm able to call the java keywords from my robot scripts.
Now I want run "java -jar xxx.jar" from my robot scripts so it can automatically start my server and I should be able to import remote server library.

I have tried using Run Process and Start Process these  keyword are executing the command successfully but I'm not able to access remote server from robot scripts.

Any help would be really appreciated. 

-Nishad

adam.wyp...@gmail.com

unread,
May 26, 2018, 5:34:21 PM5/26/18
to robotframework-users
Hi,

I think is worth to check where you are importing Remote library - if it is Settings then most probably you are trying to connect before your JVM process is being executed. Here you have example, which should clarify it more: https://github.com/robotframework/RemoteApplications/blob/master/robot-tests/xmlrpcservice/xmlrpcservice.txt - the first just start application and wait for it to be running (I think is worth to check if port is available on the system) and then you should import Remote library.

-Adam.

Anne kootstra

unread,
May 27, 2018, 4:17:49 AM5/27/18
to robotframework-users
As mentioned by Adam, I'm pretty sure that you will run into the situation where the Library Import will fail because the server has not yet been started.

That said, even if it were possible I'd like to think that this falls into the category: "Just because you can, does not mean you should." Starting applications that are needed for your test is something that I consider to be part of the Test Orchestration level, and not the actual test. So, in my view your CI system would have a step that starts and verifies the availability of an application prior to your test is started.

However, if you you use a shell script to start robot, extend it with command that starts the Remote Server prior to starting Robot Framework. If that fails, then there's really no point to start robot. 

-Anne


Op zaterdag 26 mei 2018 14:05:32 UTC+2 schreef nishadispr...@gmail.com:

nishadispr...@gmail.com

unread,
May 28, 2018, 5:40:00 AM5/28/18
to robotframework-users
Thanks Adam.
I was not calling in setup, but in the specific keyword where I need to call keywords from jar file, but it still fails to import.
I was trying with Start process also. attached the screen shot of the log
log.png

nishadispr...@gmail.com

unread,
May 28, 2018, 5:42:46 AM5/28/18
to robotframework-users
I'm working on windows I will try with batch script.
Thanks for the suggestion!!

-Nishad

I Sashank

unread,
May 28, 2018, 5:44:06 AM5/28/18
to nishadispr...@gmail.com, robotframework-users
Hi 

Please try in below fashion it is working successfully for me 
Begin Web Test
    [Arguments]   ${BROWSER}
    @{list} =     Create List    disable-web-security       allow-running-insecure-content      ignore-certificate-errors    Chrome PDF Viewer    
    ${args} =     Create Dictionary    args=${list}    download.default_directory=${EXECDIR}${/}RobotDownload 
    ${desired caps} =     Create Dictionary    chromeOptions=${args}
    Open Browser    ${URL.${ENV}}    remote_url=http://127.0.0.1:4444/wd/hub     browser=${BROWSER}    desired_capabilities=${desired caps}    
    Maximize Browser Window
    

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.



--

Thanks & Regards,

Sashank.Itharaj

www.flatworldsolutions.com

 


cid:image008.png@01CF6B0F.BAFC4490

Description: Description: Description: Description: Description: Description: icon-fbDescription: Description: Description: Description: Description: Description: icon-inDescription: Description: Description: Description: Description: Description: icon-tw

 


Sashank
SeniorTechLead-Automation Testing

Description: Description: Description: Description: Description: Description: Description: icon-skypeSkype ID: sashank.fws

Mob:+918019373545

Email: sash...@flatworldsolutions.com

adam.wyp...@gmail.com

unread,
May 28, 2018, 9:11:42 AM5/28/18
to robotframework-users
Ok I know what is your problem now. If you need to provide policy setting for JVM to allow communication. In my test I used example code from Thomas blog: https://blog.codecentric.de/en/2016/01/robot-framework-tutorial-2016-remote-server-keywords-in-java/ .

*** Settings ***
Library           Process

*** Test Cases ***
T1
    @{jvm_args}    Create List    -Djava.security.manager    -Djava.security.policy=C:\\Users\\Adam.Wypych\\Downloads\\policy.txt
    ${result}    Start Process    java    @{jvm_args}    -jar    C:\\Users\\Adam.Wypych\\Downloads\\sample-remote-library-1.0-server.jar    stderr=STDOUT
    Log    ${result}
    Wait For Process    ${result}    timeout=5s    on_timeout=continue
    Import Library    Remote    http://localhost:8270    timeout=10s    WITH NAME    TSOEmulator
    TSOEmulator.Print Message    Testnachricht

My policy.txt file looks like below:

grant {
    permission java.security.AllPermission "", "";
        permission java.net.SocketPermission "*", "connect,accept,listen";
};

I hope it will help you with your problem.

nishadispr...@gmail.com

unread,
May 28, 2018, 1:49:36 PM5/28/18
to robotframework-users
Hey Adam, Thanks for your response.
I'm still facing the same error. 
the variable ${result} contains value 1, I'm assuming it's failed to run the process.
How to debug why it's failed, stdout msg doesn't give much info in the log.
test.png

adam.wyp...@gmail.com

unread,
May 29, 2018, 3:24:37 AM5/29/18
to robotframe...@googlegroups.com
our problem is related due to fact that your JVM die before import library Remote keyword is even executed. Just take a look into Wait For Process keyword, which waits for process to be terminated - it should leave your process running. In your case it says that process was successfully terminated:
Capture.PNG
Reply all
Reply to author
Forward
0 new messages