Relative path in serenity properties file - properties-file

I want to provide a relative path in serenity.properties file. So that my project is OS independent.
When I am trying:
chrome_preferences.download.default_directory = /target
it is failing, means chrome's default directory doesn't change but when I give full path like this
chrome_preferences.download.default_directory = D:\\automation-practice-tests\\target
it works perfectly fine, but if I choose to use absolute path it will not remain OS independent.
How can I fix it?

I know is a little late, but this is how I resolved the problem:
chrome_preferences.download.default_directory=${user.dir}\\src\\test\\resources\\files\\downloads
In your case
chrome_preferences.download.default_directory = ${user.dir}\\target

This worked in my Mac and I am able to download the file
chrome.preferences.download.default_directory="${user.dir}\\target"
chrome.preferences.profile.default_content_settings.popupsy=0
chrome_preferences.pdfjs.disabled=true

Related

File upload path in a test

A geb test tests file upload in a grails application. According to the documentation the absolute path of the file has to be specified in the test. Is it possible to make the test a bit more portable between developers/machines by including a file in the grails source tree and then getting its absolute path from the geb test?
You may be interested in doing something like this
http://www.mkyong.com/java/how-to-get-the-filepath-of-a-file-in-java/
In the Get file path example he creates a temporal file and then gets its filePath. If you need a specific file then I recomend you to build / write on it after creating it, this way you have a User/enviroment free file to access from your app anytime.
I ran into a problem like this once, uploading a photo to a server with grails, and for test or repetitive actions I created it and added the base64 code on runtime.
Hope it helps. Good luck! :)
I just ended up using System.properties['base.dir'] to get real path to my application.
String cd = new File(".").getAbsolutePath().replace(".","");
String file = cd + "file.jpg"
println file
It's work for me, on windows an linux.
it's need for CI and local building test.

Get the path to the current application in node-webkit

In node-webkit, is there any way to find the path to the current application? In node.js, you can use __dirname to find the path to the current application, but in node-webkit, the variable __dirname appears to be undefined.
The following node.js script prints the file path correctly:
console.log(__dirname)
The following node-webkit script does not print the file path correctly:
<script type = "text/javascript">
alert(__dirname);
</script>
What is the correct way to find the path to the current application in node-webkit?
The accepted answer's link is no longer available, so here is a short answer:
nw.js extract the content of your app, to a temp directory, every time you run it.
If you want to access the path where nw.js extracted your app, use process.cwd()
In other causes, where you want to access the path of your executable app, use:
var path = require('path');
var nwDir = path.dirname(process.execPath);
The answer to this question was discussed here: https://groups.google.com/d/topic/node-webkit/IwGzluFC9iU/discussion
On Windows, use "process.execPath" to see the path of the executable that launched it. Then work from there, removing the executable's filename from the path to get the folder's path (assuming your app's .nw is relative to the executable or is combined with it).
This works for me whether it is running with the zipped 'app.nw' or where 'nw.exe' and 'app.nw' are combined into one executable file (app.exe).
If you are looking for the path to the App source (i.e. the folder that contains package.json) then you can use process.cwd().
No matter what the environment's true working directory is when the node executable is launched, it will set process.cwd() to the location of the App source. If the App is contained in an archive, cwd will point to the temporary folder where the source is extracted.
Importantly, note that process.cwd() can be changed during the application run by process.chdir(newPath) and potentially by other events as well, so you might want to store the initial value at application launch.
EDIT:
Just to clarify, process.cwd() is set to the folder that contains the actual package.json file that is used by the running app. So if you have packaged your app in an archive or executable (zip, exe, nwz, nw, etc), then nw.exe will extract the project files to a temporary directory before running the app. So process.cwd() will point to that temporary folder, not the location of the original archive or executable.
this should work:
var nw = require('nw.gui'); //This line is only required for NW.js 0.12.x and below
console.log(nw.__dirname)
window.location won't work if you're loaded an external uri, but the following seems reliable regardless:
var path = require('path');
,appPath = path.dirname(require.main.filename)
Not sure when this is added, but I believe the official way to get the start up path now is:
nw.App.startPath

Variable that refers to the project directory in Qt Creator?

I'm working on a cross-platform Qt application and the paths are different on Mac OS X and Windows. Since the project is on an external hard-drive, the drive letter also occasionally changes on Windows.
For that reason, I would like to refer to the project directory using a variable, preferably a built-in one. In particular, is there such a variable usable in:
The .pro file?
The build settings (in the Projects tab)?
To complete, #Bill's answer, the way to refer to the source path in the Build Settings is to use %{sourceDir}.
%{buildDir} is also available.
Since I struggled a bit to find it, I'm adding it here.
In addition to %{sourceDir} and %{buildDir}, you could use %{CurrentDocument:Path}, %{CurrentDocument:FilePath} and %{CurrentProject:Path} to refer to specific files and folders in the project directory.
The built-in _PRO_FILE_PWD_ variable contains the path to the directory containing the project file in use. That variable may be useful for you.
There are problems with $$_PRO_FILE_PWD_ on windows, because it contains forward slash allways. You need to fix slash using shell_path.
$$shell_path($$_PRO_FILE_PWD_)

Intellij Idea problem with text file impossible to read

I have a problem using Intellij Idea.
I am absolutely unable to load text file as InputStream - it doesnt matter where do I put the file (main/java, main/resources...) it just can't find the file - in Eclipse everything works just fine.
I tried setings->compiler->resource patterns and added ?*.txt but that doesn't seem to work either.
Any help is appreciated.
If you load it as a File, make sure that Working Directory is properly set in IDEA Run/Debug Configuration, since it's the default directory where Java will look for a file when you try to access it like new File("file.txt"). Working directory should be set to the directory of your project containing .txt files.
If you load files as a classpath resource, then they should reside somewhere under Source root and will be copied to the classpath according to Settings | Compiler | Resource Patterns.
If you can't get it working, upload your project somewhere including IDEA project files so that we can point to your mistake.
Look at the image, notice that the txt files are in the project root, and not the source folders (in blue).
If you open the Project Structure dialog, and click on Modules and select your module - are the correct folders marked as Source Folders on the sources tab?
Link for how to get to Project Structure dialog
Also, if you print out the absolute path of that file you are trying to read, is that anywhere near where you expect it to be?
An easy way to figure out the same would be to try creating a file in the same fashion and see where it gets created in your project. You can put your input file at the same location and it should work just fine (if it doesn't, you should check your resource pattern which might be causing the file to be not copied over in the build output).
This method actually gives you the working directory of your intellij settings which is pointed out in the accepted answer. Just sharing as I had similar trouble and I figured out this way. :)

Browse path / click-though issue

I have Raize 3.0 installed in D2007. For whatever reason, I can't seem to get the Ctr-click to work for loading up it's units, even though that feature works fine on all my other Delphi and Third-Party components.
Here's what I have for Raize on the Library Path:
$(ProgramFiles)\Raize\RC3\Lib6
$(ProgramFiles)\Raize\RC3\Source
...and the Browsing Path:
$(ProgramFiles)\Raize\RC3\Source
Lib6 contains *.dcu and *.dfm files, and Source contains, obviously, the source code. Adding Lib6 to the Browsing path doesn't seem to affect things one way or the other.
I don't get why this Ctrl-click unit-loading feature isn't working, just for this one component. Any ideas what I may be missing?
You shouldn't need Source path in your Library path. Lib6 should be added to Library Path, and Source to Browsing Path.
If you do so, and it still doesn't work, then you have a similar problem with me:
Problem with setting Browsing Path in Delphi option page
For lib path you generally don't need source files. I use:
C:\Program Files\Raize\RC4\Lib\BDS2007
For browsing path you need to specify the language directory, e.g.:
C:\Program Files\Raize\RC4\Source\Lang\English
If this doesn't fix it, does your unit compile without errors?