change directory

1,808 views
Skip to first unread message

angelo

unread,
May 18, 2010, 7:15:44 PM5/18/10
to robotframework-users
I would like to avoid using below user library:
def Change_Directory(dir):
os.chdir(dir)
print "DST: ", os.getcwd()

Is there a Keyword to change directory?

--
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,
May 19, 2010, 9:49:16 AM5/19/10
to angelo...@yahoo.it, robotframework-users
2010/5/19 angelo <angelo...@yahoo.it>:
> I would like to avoid using below user library:
> def Change_Directory(dir):
>    os.chdir(dir)
>    print "DST: ", os.getcwd()

This looks fine so there's no real reason to avoid using it.

> Is there a Keyword to change directory?

RF itself doesn't have keyword for changing directory. The main reason
is that Jython 2.2 didn't support that. I just tested that it works
with Jython 2.5.1 at least on Linux, so adding `Change Directory` to
OperatingSystem library is possible. The keyword should probably also
return (and log) the old directory so that it's possible to change the
directory back. Additionally there could be `Get Current Directory`
that just returns and logs the os.getcwd().

Please submit an issue if you want these keywords to be added. The
changes of getting this into RF 2.5 rises if someone is willing to
create a patch including implementation, documentation and preferably
also tests. I can help with that if needed, but I have too much 2.5
work to do at the moment to take care of all the work.

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

Bill Barnes

unread,
Aug 2, 2021, 11:13:48 AM8/2/21
to robotframework-users
Good Day!

Has this been implemented, in some way?

Thanks!

Craig Despeaux

unread,
Aug 5, 2021, 6:43:41 PM8/5/21
to robotframework-users
Depending on what you are doing and why you need to do it, we have eliminated the need for this in some of our projects by doing this:

Run  cd  /dir; command

This changes the directory only for the command being executed and doesn't affect the current working directory.
 
Craig

Reply all
Reply to author
Forward
0 new messages