Login to citrix machine using Robot framework - robotframework

We are trying to automate a few Test Cases which require login to a Citrix machine using Robot framework.
Could someone please help provide a sample example to automate the same.
Thanks in advance.
Regards,
-kranti

You can create a keyword for Login into Citrix Machine which you can then call in your TestCases.
An example is shown as below:
*** Settings ***
Library SSHLibrary
*** Variables ***
${Citrix_machine} 192.168.0.1
${username} user
${password} password
*** Test Cases ***
Test1
Open Connection ${Citrix_machine}
Login ${username} ${password}
If you want to create a keyword of login then you can use the following steps:-
*** Settings ***
Library SSHLibrary
*** Variables ***
${Citrix_machine} 192.168.0.1
${username} user
${password} password
*** Test Cases ***
Test1
Login into Cluster
*** Keywords ***
Login into Cluster
Open Connection ${Citrix_machine}
Login ${username} ${password}

Related

How to telnet using Telnet library of Robot Framework where there is no login Password required for Telnet to server

How to telnet using Telnet library of Robot Framework where there is no login Password required for Telnet to server
My code is
*** Settings ***
Library Telnet
Test Teardown Close All Connections
*** Test Cases ***
Telnet to DUT
Open Connection 192.168.2.254
Login ls date login_prompt=# password_prompt=""
Execute Command ls
Just given ls and date to check since there is no username password required to connect. And by correct\expected prompt is #
And I am getting "ls" output as well but next time when it is expecting a Password prompt it is failing with the below error as there is no Password prompt
"No match found for '""' in 3 seconds. Output:"
Can someone pls help.. may be this is easy and I am not able to figure it out.
Thanks in advance
I got the answer, kindly ignore it.
Added prompt_is_regexp=yes prompt=# (This is expected prompt) in Open Connection and this worked.

Robotframework and SSHLibrary issue with a network router

I am now trying to use SSHLibrary to ssh into a virtual router running on my PC and execute a simple ping test on the router and then present the result of the test case.
I can login to the router and also execute the command outside of the robotframework, but when I try to do this using robotframework I get a fail with an error message and not sure how i solve for this error message:
Here is my robotframework test script:
*** Settings ***
Library SSHLibrary
Suite Setup Open Connection And Log In
Suite Teardown Close All Connections
*** Variable ***
${HOST} 172.31.1.250
${USERNAME} admin
${PASSWORD} admin
*** Keywords ***
Open Connection And Log In
Open Connection ${HOST}
Login ${USERNAME} ${PASSWORD}
*** Test Cases ***
Ping test
${output} = Execute Command ping 1.1.1.1
Should Contain ${result.stdout} 64 bytes from 1.1.1.1
Here is the output I get when I execute the above test case:
==============================================================================
Sros
==============================================================================
Ping test | FAIL |
ChannelException: (1, 'Administratively prohibited')
------------------------------------------------------------------------------
Sros | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
What is this error message and how do I solve this:
**ChannelException: (1, 'Administratively prohibited')**
Does it matter what type of the router that I am login into is?
Thanks for your help.
Based on the feedback I have changed from Execute Command to Write.
So my script looks like this now:
*** Settings ***
Library SSHLibrary
Suite Setup Open Connection And Log In
Suite Teardown Close All Connections
*** Variable ***
${HOST} 172.31.1.250
${USERNAME} admin
${PASSWORD} admin
*** Keywords ***
Open Connection And Log In
Open Connection ${HOST}
Login ${USERNAME} ${PASSWORD}
*** Test Cases ***
Ping test
${result} = Write ping 1.1.1.1 count 1
Should Contain ${result.stdout} 64 bytes from 1.1.1.1
But now I get following error message:
==============================================================================
Sros
==============================================================================
Ping test | FAIL |
Resolving variable '${result.stdout}' failed: AttributeError: 'str' object has no attribute 'stdout'
------------------------------------------------------------------------------
Sros | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Also not I have checked using Wireshark that robot script does actually ssh into the router and establish a ssh session. I think the connectivity part of working fine.
Consider using
Write ping 1.1.1.1
${output}= Read delay=0.5s
to get the output in a var. It will now have the same behavior you have while doing it manually !
I hope it will help you ;)

ROBOT FRAMEWORK - Create session with AUTH and Headers - Getting TypeError: __init__() takes exactly 3 arguments (2 given)

How ti create session with AUTH and Headers using Robot framework?
I tried the below code:
*** Variables ***
${user} ='user1api'
${passwd} ='password!'
&{headers} Content-Type=application/json Authorization=Basic ABCDEF==
*** Keywords ***
DO Status Get API
${auth}= Create List user passwd
Create Session DOStatus https://test.abc.com/api/status/7661/job headers=${headers} auth=${auth}
${resp}= Get Request DOStatus /basic-auth/user/passwd
and ran into this error:
TypeError: __init__() takes exactly 3 arguments (2 given)
*** Settings ***
Library String
Library Collections
Library Selenium2Library
Library RequestsLibrary
*** Variables ***
${user} = user1api
${passwd} = password!
&{headers} Content-Type=application/json Authorization=Basic ABCDEF==
*** Keywords ***
Get DO Status API
${auth}= Create List ${user} ${passwd}
Create Session alias=DOStatus url=https://test.abc.com/api/status/7661/job headers=${headers} auth=${auth}
${resp}= Get Request DOStatus /
Should Be Equal As Strings ${resp.json()['transaction']['status']} success
Should Be Equal As Strings ${resp.status_code} 200
If you are using basic auth, you need to pass a tuple, assuming you are using the requests library.
If you are importing variables from a .yaml file, I think you could remove my Convert To Boolean and Evaluate keywords
The code:
*** Settings ***
Library requests
*** Variables ***
${user}= "test_user"
${pass}= "test_pw"
${url}= https://special.domain/some/api/endpoint
&{headers}= content-type=application/json accept=application/json
*** Keywords ***
api check test
${false}= Convert To Boolean False
${user_pass}= Evaluate (${user}, ${pass},)
${resp}= Get ${url} auth=${user_pass} headers=${headers} verify=${false}
Log To Console ${resp.status_code}
The result:
Api Validation :: API Validation
==============================================================================
Test API
...<warning goes here>...
200
Test API | PASS |
------------------------------------------------------------------------------
Api Validation :: API Validation | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
I think the reason the OP's code didn't work as expected was because of the single missing space when setting the auth variable and consequently producing a Python requests.auth.HTTPBasicAuth call of just (self, 'username & password') rather than (self, 'user', 'password'). The constructor signature expects __init__(self, username, password) . This can be fixed by simply adding a single space to the original code which instructs RobotFramework to consider the variables as 2 separate values in the list. See the difference between the assign of auth_bad and auth_good in the code below.
*** Settings ***
Library RequestsLibrary
*** Variables ***
${user} ='user1api'
${passwd} ='password!'
&{headers} Content-Type=application/json Authorization=Basic ABCDEF==
*** Keywords ***
DO Status Get API
${auth_bad}= Create List user passwd
Log To Console A bad authentication variable: ${auth_bad}
${auth_good}= Create List user passwd
Log To Console A good authentication variable: ${auth_good}
Create Session DOStatus https://192.168.1.254/api/status/7661/job headers=${headers} auth=${auth_good}
${resp}= Get Request DOStatus /basic-auth/user/passwd
*** Task ***
Basic Task
DO Status Get API
I have the same problem as you and I solved it.
I remove the headers in Create session.
You can refer my source:
Variables
${jira_url} https://example.com
${jira_user} user1
${jira_password} password1
Test Cases
Get All Testcase Of SC Project
${auth}= Create Dictionary ${jira_user} ${jira_password}
Create session alias=Get_Jira_Request url=${jira_url} auth=${auth}
${response}= Get Request Get_Jira_Request /rest/atm/1.0/testcase/search?query=projectKey%20=%20%22SC%22
Even I struggled for one day to figure it out.
Define:
&{dict} accept=text/plain Authorization=Basic
#{auth} ${user} ${pwd}
If we use Create List/ Create Dictionary, it does not work.
#{auth} Create list ${user} ${pwd}
Create Session em url=${url} verify=false auth=${auth}
=========
*** Variables ***
${user} user1api
${passwd} password!
&{headers} Content-Type=application/json Authorization=Basic
*** Keywords ***
DO Status Get API
#{auth} ${user} ${passwd}
Create Session DOStatus https://test.abc.com/api/status/7661/job headers=${headers} auth=${auth}
I hope this will solve the problem of create session

SFTP SSHLibrary Unable to Connect

Im unable to connect to SFTP with below script, any ideas why?
*** Variables ***
${HOST} = mysite.com
${USERNAME} = username
${PASSWORD} = password
${PORT} = 22222
${keyfile} = /Users/victor/.ssh/
*** Test Cases ***
Open Connec
Open Connection stage1.globalcashcard.com alias=LaborReady port=22222
Enter Credentials
Login ${USERNAME} ${PASSWORD}
List Dir
List Directory /
Close ALL Conns
Close All Connections
Side NTOE:
I Even tried it with
Login with P. Key
Login With Public Key username /Users/username/.ssh/known_hosts
Results log
Status:
FAIL (critical)
Message:
SSHException: SSH session not active
00:00:00.004
KEYWORD SSHLibrary . List Directory /
Documentation:
Returns and logs items in the remote `path`, optionally filtered with `pattern`.
Start / End / Elapsed:
20170607 14:18:33.338 / 20170607 14:18:33.342 / 00:00:00.004
14:18:33.342
FAIL
SSHException: SSH session not active
I'm able to login with Filezilla without any issues. On thing I did notice is that I cannot login via terminal with below command
ssh username#stg1.mysite.com -p 22222
I get prompted to enter password when I enter then I get below message
shell request failed on channel 0
I able able to connect via Terminal with below command
sftp -o "Port 22222" username#stg1.mysite.com
Could this be the issue?
SSH and SFTP are different protocols. That is what you validated with your experiences.
When you use SSHLibrary you can use similar functions you get in SFTP, but not the exact commands.

get response header robot framework

I'm trying to get the response header that named com.coradiant.appvis in robot framework
there are no resources that can help ,, this is my code
*** Settings ***
Library HttpLibrary.HTTP
Test Setup Create HTTP Context ${HOST}
*** Variables ***
${PORT} 80
${HOST} http://vw-tlv-idnqa31${PORT}/EventsApps/EventsApps/WebForm.aspx
${APPVIS_HEADER}
*** Test Cases ***
Checking Appvis test
Get the appvis response header
*** Keywords ***
Get the appvis response header
${APPVIS_HEADER} = get response header com.coradiant.appvis
Log ${APPVIS_HEADER}
You must make a request before you can get the header. You can use the GET keyword to make the request, assuming you need the headers for a GET request.

Resources