Reputation: 405
I am having trouble opening a .txt
file that is in a different set of folders than where I have my .rb test script. I have a file structure of different test categories and then one generic folder that holds data files like .txt
and Excel files.
Example:
Test Scripts -> Data This is where the data files are saved Test Scripts -> Home Page -> Checkout This is where the .rb test file is
I am using this to open the .txt
file now:
File.open("Data/activeSites.txt")
when the .rb
is in the same folder as the Data
folder.
Any suggestions?
Upvotes: 0
Views: 200
Reputation: 34071
If I correctly understand what you're asking, the issue is that you want to move your Ruby script from TestScripts/
to TestScripts/HomePage/Checkout/
and aren't sure how to refer to the activeSites.txt
file from there. Is that correct?
If so, you just need to know that ../
means "the parent directory", so you can use:
File.open("../../Data/activeSites.txt")
The first ../
refers to the Home Page folder, then the second takes you up one more level to the Test Scripts folder.
Upvotes: 1