Can you specify a 'relative' path for the data file using Sel-Blocks Selenium add-on? - selenium

Is it possible to specify a relative path, rather than an absolute one, when specifying the location of a data file when doing data driven development with the SelBlocks add-on?
I'm working on a small team and we'd love to be able to have our tests be portable and eventually become part of our production process. We are currently using the Selenium IDE to write the tests and we have some people on the team using Macs, some using Windows, etc. So, right now, the 'forXML' command requires an absolute path, like:
forXML|file:///C:/data.xml
This isn't terribly portable. It would be handy to just do something like:
forXML|file:///./data.xml
and that would pull up a data.xml file located in the same directory as the test case or the current test suite or something. I've played with various versions of the syntax and I can't figure out anything that will pull up a file via some 'relative' path. Is this even possible?
Thanks

Paths are relative to the running script itself. Examples:
forXML|data.xml
forXML|data_dir/data.xml
See documentation here: http://refactoror.wikia.com/wiki/Selblocks_Reference

Paths are relative to the running script itself. Examples:
forXML|data.xml
forXML|data_dir/data.xml
This is not working for me, works only using an absolute path like forXML|file:///C:/dataDir/data.xml
Having it relative, or at least configurable as a parameter ([yourpath]filename.xml)would be great

Related

Simple question about File class in kotlin

I'm trying to read from a file in kotlin using the File class. It's just a simple txt file with a list of names with each name occupying an independent row. This is my project structure:
and here's my function for pulling out a name depending on the day of the year:
private fun getNameOfTheDay(): String {
val cal = Calendar.getInstance()
val day = cal[Calendar.DATE]
return File("data${File.separator}names.txt")
.bufferedReader()
.lineSequence()
.elementAt(day - 1)
}
I keep on getting a FileNotFound exception so I would assume that my file path is somehow wrong... What am I doing wrong here? Sorry for the dumb question, I'm still learning. By the way the function shown above is called from the MainActivity. Thanks in Advance!
Filenames can be absolute or relative. Absolute filenames start from the top level (e.g. the root directory on Unix-like filesystems, which Macs have; or a drive letter on Windows), and so specify the filename unambiguously. Relative filenames don't, and so give a file in (or in relation to) the current working directory.
In this case, data/names.txt is a relative filename. It assumes that the current directory has a subdirectory called data, and refers to a file in that.
However, the file is actually in the directory app/src/main/java/com/example/mynameis/data/ within your project — so this would only work if the current directory was /<pathToYourProject>/app/src/main/java/com/example/mynameis/, which is highly unlikely! So that probably explains the failure.
I don't know about Android projects, but in normal JVM projects the standard practice is to put data files in a src/main/resources/ directory. Gradle (or Maven) knows to copy them into the classpath when building the project. You would then load it from the classpath, e.g. with:
javaClass.getResource("data/names.txt").readText()
See e.g. this question for more details and variations.
The advantage of loading from the classpath instead of a file path is that you don't need to know exactly where the file is; it could be loose on the filesystem, or bundled into a jar or other archive (even compressed), with ways to select between different versions depending on the run profile — all completely transparent to your code.
As I said, I don't know Android, and can't find any direct answers on StackOverflow. (This question seems to suggest using a android.resource:// URI, but I don't know if that would apply here.) Maybe these external sites can give you some hints.
You should try "data\names.txt". Oftentimes slashes don't work for file paths.

Callgrind: how to pass relative path to source code?

I'm using valgrind's callgrind to profile a program and then kcachegrind to view the profile data. I've copied callgrind's output file to a different machine and have a copy of the source code there, but apparently the path information of the source code is baked into callgrind's format. This means kcachegrind is looking in the wrong place:
Is there a way to pass a relative source code path so that I can profile the program on one machine but then transport the profiling data to another machine and still view the source code?
I had originally tried the sed route and that didn't work. But I looked at that solution again and the problem was that paths with '~' don't work with kcachegrind it seems.

is script autoloading possible in rebol or red-lang?

Is there a way to do so ? I searched Google but couldn't find any answer, so I guess the answer would be no. Is there anything close ? If not, would it be easy to extend red-lang to do so ?
From http://www.rebol.com/docs/setup.html
Startup Scripts
When REBOL starts it will automatically run the rebol.r and user.r files, if they exist.
The system looks for these files first in the current directory (or the directory of the script being run), then in the directory that contains the REBOL executable program.
Note that REBOL/Core runs fine without the rebol.r and user.r files. They simply provide an easy way to include additional code and data on startup, such as your network preferences.
If you compile your own Red interpreter you can add an autoloading file, maybe in console.red after system/console/init "Red Console" and before system/console/launch Best advice is to ask on the https://gitter.im/red/help site to ask for help. I guess this was already discussed.

how to setup tests for mocha-phantomjs

Every tutorial I have seen for mocha-phantomjs shows having a test harness html file, and a separate javascript file that gets included.
Is this the correct way to do this for each test? I want to create a separate test for each page in my website, but it seems like overkill/crazy to duplicate an html file for every test case.
Granged, this is my first time trying to use mocha-phantomjs, but still, it seems really odd to create an html file and a js for every test case.
What is the standard for doing this sort of thing? I have been googling for about an hour now and can't find any good examples.
I know it seems weird, but... yes.
You need fixture (or harness) files in the "/test" directory. By default, Mocha looks in this directory for filenames with a .html extension, starting with test.html.
Make sure to include the script (and css) tags for 1) mocha, 2) chai (or whatever other assertion library you want), 3) and your specific test suites.
Personally, I've found it helps to use it with a modular bootloader like RequireJS. That way all your fixture files can point to a single configuration file: less maintenance.

How to reference the absolute directory of a project in Autoconf (to call custom scripts in portable way)?

I'm writing a custom check for installed libraries in autoconf:
AC_DEFUN([AC_GHC_PKG_CHECK],[
...
GHC_PKG_RESULT=$($PYTHON autotools/check-ghc-version-range ....)
...
])
where my Python script that actually performs the check resides in the autotools/ sub-directory of the project.
However, this is not portable, for example make dist-check fails because then autoconf tools are called from a different directory. How can I reference the absolute path to my Python script so that it gets called properly no matter what the current directory is?
ac_top_srcdir or ac_abs_top_srcdir should work in this case:
AC_DEFUN([AC_GHC_PKG_CHECK],[
...
GHC_PKG_RESULT=$($PYTHON $ac_top_srcdir/autotools/check-ghc-version-range ....)
...
])
EDIT: I don't think this approach will work -- it seems that $ac_top_srcdir aren't evaluated until later (AC_OUTPUT?).
What I think might work in this instance is to do something similar to what the runtime C tests do: blast a configuration test to a temporary file (conftest.py instead of conftest.c in this case) and run it. Unfortunately, there's (yet) no builtin macros or for automake/autoconf other tools that directly assist with this task.
Fortunately it seems that a clever person has written at least a couple different ways to do this. The first one is GNU pyconfigure which seems to have facilities for writing Python test code as I described above. The second one is more of an ad hoc macro collection that he used for his project.
You can use $srcdir.
It's not necessarily an absolute path, but it's a path that points from the top of the build tree to the top of the source tree.