Tuesday, March 31, 2015

Robotframework Jmeter testcase example with assertion

*** Settings ***
Library           JMeterLib.py
Library           Collections

*** Test Cases ***
tc1_justRunJMeter
    run jmeter    C:/Users/USER/Desktop/apache-jmeter-2.12/apache-jmeter-2.12/bin/jmeter.bat    C:/Users/USER/Desktop/apache-jmeter-2.12/apache-jmeter-2.12/bin/vallikkv/Soap.jmx    E:/Robot/jmeter/log/output_tc1.jtl

tc2_analyseAndConvertExistingJtlLog
    ${result}    analyse Jtl convert    E:/Robot/jmeter/log/output_tc1.jtl
    log    ${result}
    : FOR    ${ELEMENT}    IN    @{result}
    \    log dictionary    ${ELEMENT}
    \    ${check}    Get From Dictionary    ${ELEMENT}    samplesSuccessRateInclAssert
    \    log to console    ${check}
    Should Be Equal As Integers    ${check}    100

tc3_runJMeterAndAnalyseAndConvertLog
    ${result}    run jmeter analyse jtl convert    C:/Users/USER/Desktop/apache-jmeter-2.12/apache-jmeter-2.12/bin/jmeter.bat    C:/Users/USER/Desktop/apache-jmeter-2.12/apache-jmeter-2.12/bin/vallikkv/Soap.jmx    E:/Robot/jmeter/log/output_tc3.jtl
    log    ${result}
    :FOR    ${ELEMENT}    IN    @{result}
    \    log dictionary    ${ELEMENT}

Thursday, March 26, 2015

Robot framework - Notes

Robot framework: To read datas from a row in excel sheet

Add more users
    Open Excel    ${Excel_File_Path}
    @{ROW1}    Get Row Values    Sheet1    0
    ${RUN}=    Get From List    ${ROW1}    0
    ${LIST}    Convert To List    ${RUN}
    log to console    ${LIST[1]}
 
Explanation

Get Row Values - Collects all values from row and assign it to ROW1
 @{ROW1}    Get Row Values    Sheet1    0 ->Output will be tuple -> Eg [(1,2),(3,4)]
 Get From List    ${ROW1}    0 -> To get the first value, i.e  (1,2)
To convert it as [1,2] -> use Convert to List keyword
 ${LIST[1]} - To access 2nd value from the list

Reading values from excel

Add more users
    Open Excel    ${Excel_File_Path}
    ${COLCOUNT}    Get Column Count    Sheet1
    @{ROW1}    Get Row Values    Sheet1    0
    ${RUN}=    Get From List    ${ROW1}    0
    ${LIST}    Convert To List    ${RUN}
    :FOR    ${COUNT}    IN RANGE    ${COLCOUNT}
    \    @{ROW1}    Get Row Values    Sheet1    ${COUNT}
    \    Fetch Column Data

Fetch Column Data
         :FOR    ${ColIndex}    IN RANGE    ${COLCOUNT}
         \    ${VarList}    Create List
         \    ${RUN}=    Get From List    ${ROW1}    ${ColIndex}
         \    ${LIST}    Convert To List    ${RUN}
         \    ${Value1}=    Get From List    ${List}    1   
         \    Insert Into List    ${VarList}    ${ColIndex}    ${Value1}
         \    Log to console    ${VarList}


Tuesday, March 24, 2015

Monday, March 23, 2015

Robot Framework

Installation







Read data from Excel


Manual Installation

To install robotframework-excellibrary manually, install all dependency libraries before installing robotframework-excellibrary.
1) Install Robot Framework installed.
2) Download source distributions (*.tar.gz / *.zip) for the library and its dependencies.
robotframework-excellibrary and dependencies:
Note: Internet Connection is required

command
python setup.py install


***Settings***
Library    ExcelLibrary

***Variables***
${Excel_File_Path}    C:\Test.xls

***Test Case***
Read Data from Excel and fill in text box Open Excel ${Excel_File_Path} ${username}= Read Cell Data By Name Sheet1 B1 ${password}= Read Cell Data By Name Sheet1 B2 Input Text id=Username ${username} Input Text id=Password ${password}

Tuesday, March 3, 2015

Robot framework - Selenium2Library test execution


*** Settings ***
Documentation  Test suite-2 Verify the connect webpage is logged in with valid logon credentials
Library  Selenium2Library

*** Variables ***
${HOMEPAGE}     http://192.168.10.132:8080/connectserver
${BROWSER}  FireFox
${DELAY}    1
${USERNAME}    admin
${PASSWORD}    connect


*** Test Cases ***
connect login
    open connect webpage
    enter login credentials
    click login

connect logout
    logout connect webgui


*** Keywords ***
Open connect webpage
    open browser    ${HOMEPAGE}    ${BROWSER}
    Maximize Browser Window
    Set Selenium Speed    ${DELAY}

enter login credentials
    Input Text    id=username    ${USERNAME}
    Input Text    id=password    ${PASSWORD}

click login
    Click Button    id=loginAction_login_submit

logout connect webgui
    Get Location
    Select Frame    xpath=//div[1][@class='ui-layout-north ui-layout-pane ui-layout-pane-north open']
    Click Button    xpath=//div[1]/table/tbody/tr/td[3]/table/tbody/tr[2]/td/a[@class='siLink1']