Ask a Question

os.chdir(myPath) is not working.

tc_2018
Contributor

os.chdir(myPath) is not working.

Hi,

I have the code below and it works fine with the IDLE; however, it is not working with T.C.

 

import os

myPath = 'O:\\myDir' #this is my mapped network drive

os.chdir(myPath)

 

Can someone please shed a light!

7 REPLIES 7
Marsha_R
Community Hero

What happens when you try it?


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

I got error message:

 

Python runtime error.

FileNotFoundError

[WinError3] The system cannot find the specific path specified: 'O:\\\\'

If you hard code the path in the os.chdir line, does it work?  That will tell you if it is a syntax problem with the second line or a permissions problem and TestComplete can't get to that directory.

 

 


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

Hardcoded is not working either. For example:

 

os.chdir('O:\\myFolder')

 

It works fine when running with IDLE, but not with T.C. and I don't know why.How do know if it's a permission problem with T.C?

Are you able to browse to that folder and open the file from the machine where TC is installed?


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

Yes, I can. I am an admin of the system where T.C. is installed.

 

I used IDLE on the same machine, and did not have any problem.

Can we see your actual code please?  It's hard to tell what's going on from made up examples.


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
cancel
Showing results for 
Search instead for 
Did you mean: