Saturday, September 26, 2015

Notes

Funkload
holmiumcore  - page object models

Saturday, September 12, 2015

Robot framework + SSH Library + Monitor a log file until a string matches using Jython

SSH library installation.

1. Download SSH library and install using "jython setup.py install" command
2. Download Trilead-ssh2-1.0.0-build217.jar file and put it in a folder
3. Add that folder in the "CLASSPATH"

Eg: E:\Robot\trilead-ssh2-1.0.0-build217.jar;C:\Python27\Lib\site-packages

4. Similarly add "robot" folder in the JYTHONPATH

Eg: C:\Python27\Lib\site-packages\robot;C:\Python27\Lib\site-packages

5. Execute command jython -c "import SSHLibrary" for verification

Sample SSH Robot script

*** Settings ***
Documentation  Open Notepad using Sikuli and Robotframework

Library    SSHLibrary

*** Variables ***
${HOST}                192.168.10.135
${USERNAME}            test
${PASSWORD}            test

*** Test Cases ***
Open Connection And Log In
    Open Connection    ${HOST}
    Login    ${USERNAME}    ${PASSWORD}

Execute and expect a new session
    ${OUT}=    Execute Command    timeout 5 tail -f -n 1 /var/log/messages | awk '/vallikkv/;/vallikkv/ { exit }'
    BuiltIn.Log to console    ${OUT}
    BuiltIn.Should Not Be Equal    ${OUT}    \  
    

Closing the connections
    BuiltIn.Log to console    Test
    Close All Connections


ButiltIn.Log to console -> This is how, use the inbuilt keywords of robot(python) in jython scripts

Shell command to monitor log file until specific "word" matches, if not exit the script in 5 seconds


timeout 5 tail -f -n 1 /var/log/messages | awk '/vallikkv/;/vallikkv/ { exit }'  







Wednesday, September 9, 2015

Jython remote library

Remote library for Jython/Jybot with sikuli

Machine 1:
1. Installed jython 2.5.2, Jybot, Sikuli
2. Install robot remote server using command "jython setup.py install"
       Note: Download robotremoteserver.tgz file and install
3. Own library for sikuli


Machine 2:
1.Robot framework, jython 2.5.2, jybot
2. Test scripts (Eg: Notepad.robot)

STEPS:

1. Run the sikuli library using command "jython <sikulilibrary>"

It will start the Remote library for the interface configured in the library file and exposed keywords

2.  Now run the robot script from any network machines using command

"jybot <Notepad.robot>"


The testresults will be available in the local machine (i.e Machine2)

Tuesday, September 8, 2015

Robot framework: Remote library

How to use simple remote library in robot framework? (Only for Python)

Pre-requisities:
1. Robot framework should be installed
2. Pybot command should work fine.

STEP 1:
Install robot remote server using command.

pip install robotremoteserver

Refer: https://github.com/robotframework/PythonRemoteServer

STEP 2:
Create a file as mentioned in the above link


from robotremoteserver import RobotRemoteServer
from mylibrary import MyLibrary

RobotRemoteServer(MyLibrary())

Remotelib.py:

if __name__ == '__main__':
    import sys
    from robotremoteserver import RobotRemoteServer
    from Example import test

    RobotRemoteServer(test(), host='192.168.10.104', port=8270, allow_stop=False)

192.168.10.104 - Remote machine ip where remote library exists


Here i have created a sample Example library with class "test"

Example.py

#!/usr/bin/env python

class test(object):
    """ Sample doc"""

    def add(self,x,y):
        self.x = int(x)
        self.y = int(y)
        return str(self.x + self.y)

STEP 3:
Start the Remoteserver  - command python Remotelib.py



STEP 4:
Sample Robot script


*Settings*
Documentation               This is just a tutorial for Remote library

Library    Remote    http://192.168.10.104:8270

*** Test Cases ***
Check Remote library first keyword
    [Documentation]         Check ADD keyword of remote library
    ${ANS}=    Add    1    6
    Should Be Equal    ${ANS}    7



STEP 5:
Test execution: