How to use Telnet Library to control more host?

1,558 views
Skip to first unread message

磁针石

unread,
Mar 14, 2012, 12:14:07 AM3/14/12
to robotframework-users
Hi, all:

I want to use Telnet Library to interact with 3 Hosts at the same
time. I do not want to use Open Connection to switch host. Can I do it
like Python?

sessionA = telnetlib.Telnet(hostA)
sessionB = telnetlib.Telnet(hostB)

Thanks!



*** Setting ***
Test Setup
Test Teardown
Force Tags quickstart
Default Tags example smoke
Library OperatingSystem
Library Telnet

*** Test Case ***
Telnet
Open Connection 172.23.191.253
Login andrew 123456

磁针石

unread,
Mar 14, 2012, 2:20:32 AM3/14/12
to robotframework-users
I got a similar discuss in
http://groups.google.com/group/robotframework-users/browse_thread/thread/9de85eac91ada90b/ebd70e7a34ef837c?lnk=gst&q=telnet#ebd70e7a34ef837c

Is Robot Framework excecute __init__ when import Library. And the
imported Library is actually a instance of a class. So I should
import a class for 3 times if I need 3 instance and use
BuiltIn().get_library_instance('Telnet') to get the instance ?

Thomas Maier

unread,
Mar 14, 2012, 3:01:27 AM3/14/12
to xuron...@gmail.com, robotframework-users
On Wed, Mar 14, 2012 at 8:20 AM, 磁针石 <xuron...@gmail.com> wrote:
> I got a similar discuss in
> http://groups.google.com/group/robotframework-users/browse_thread/thread/9de85eac91ada90b/ebd70e7a34ef837c?lnk=gst&q=telnet#ebd70e7a34ef837c
>
> Is Robot Framework excecute __init__ when import Library. And the
> imported Library is actually a instance of a class. So I should
> import  a class for 3 times if I need 3 instance and use
> BuiltIn().get_library_instance('Telnet')  to get the instance ?

Reading this may help you:
http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html#test-library-scope

Thomas

>
>
> On Mar 14, 12:14 pm, 磁针石 <xurongzh...@gmail.com> wrote:
>> Hi, all:
>>
>>         I want to use Telnet Library to interact with 3 Hosts at the same
>> time. I do not want to use Open Connection to switch host. Can I do it
>> like Python?
>>
>>         sessionA = telnetlib.Telnet(hostA)
>>         sessionB = telnetlib.Telnet(hostB)
>>
>> Thanks!
>>
>> *** Setting ***
>> Test Setup
>> Test Teardown
>> Force Tags        quickstart
>> Default Tags      example    smoke
>> Library           OperatingSystem
>> Library           Telnet
>>
>> *** Test Case ***
>> Telnet
>>     Open Connection    172.23.191.253
>>     Login    andrew    123456
>

> --
> You received this message because you are subscribed to the Google Groups "robotframework-users" group.
> To post to this group, send email to robotframe...@googlegroups.com.
> To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.
>

Pekka Klärck

unread,
Mar 15, 2012, 4:14:59 PM3/15/12
to xuron...@gmail.com, robotframework-users
2012/3/14 磁针石 <xuron...@gmail.com>:

>
>        I want to use Telnet Library to interact with 3 Hosts at the same
> time. I do not want to use Open Connection to switch host.

Why not? That's exactly how using multiple connections has been designed.

> Can I do it like Python?
>
>        sessionA = telnetlib.Telnet(hostA)
>        sessionB = telnetlib.Telnet(hostB)

Not exactly like this, but importing the library multiple time and
giving it different name using `WITH NAME` syntax could work:
http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html#setting-custom-name-to-test-library

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

磁针石

unread,
Mar 16, 2012, 12:05:21 AM3/16/12
to robotframework-users
Pekka, thanks!
It works now
On Mar 16, 4:14 am, Pekka Klärck <p...@iki.fi> wrote:
> 2012/3/14 磁针石 <xurongzh...@gmail.com>:
>
>
>
> >        I want to use Telnet Library to interact with 3 Hosts at the same
> > time. I do not want to use Open Connection to switch host.
>
> Why not? That's exactly how using multiple connections has been designed.
>
> > Can I do it like Python?
>
> >        sessionA = telnetlib.Telnet(hostA)
> >        sessionB = telnetlib.Telnet(hostB)
>
> Not exactly like this, but importing the library multiple time and
> giving it different name using `WITH NAME` syntax could work:http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkU...
Reply all
Reply to author
Forward
0 new messages