Tell selenium to look in my C:/Downloads folder (Ruby) - ruby

me again!!
I have a question based around the download of a file. I was helped with setting up a Firefox profile to set a download to save a file directly without a pop up window. Now I need to tell Selenium to confirm that the said downloaded file is in my downloads folder on C drive to complete the test. Is there a way to do this? I've trawled for answers and have gotten nothing.
I first tried by setting a path like so on my env.rb file but didn't get very far with it:
$download_location = 'C:/Users/User/Downloads'
def download_location(path)
$download_location + path
end
Then telling cucumber to visit this location and confirm the name of the file.
Any help on pointing selenium to the location and confirming the name of a csv file would be hugely appreciated
Thanks

If you want to use ruby instead of selenium, you can use the exists? method to check the downloads directory for a given file, and it will return a Boolean result. For example:
File.exists?('C:\Users\User\Downloads\foo.txt')

I have found a solution that worked for me:
puts Dir["C:/Users/OSAT TESTING/Downloads/**/fleet_#{export}_export_all_*.csv"]
This confirmed the download of the file by looking in my downloads folder and returning the file path + name of any file that contained "fleet_#{export}_export_all_*.csv" in cmd prompt.
Thank you all for your help
:-)

Related

Why am I getting error code 135 when applying patch through opatch?

I am trying to write a script that automates opatch, but before I get into the actual scripting I want to test the commands directly through the command prompt. My oracle home is C:\oracle\Middleware, and my patch 23094292 folder is located in the Middleware folder. Here are the commands I am using to apply the patch:
cd C:\oracle\Middleware\23094292
C:\oracle\Middleware\OPatch\opatch apply
When I run the latter command I get this:
ZOP-51: The patch location is not valid for apply, because it doesn't have correct metadata, or it points to a patch directory.
Argument(s) Error... Patch location is not valid for apply
Please check the arguments and try again.
OPatch failed with error code = 135
Shouldn't oracle home be the valid patch location? I am not too familiar with Oracle's product's, so I'm not certain. Please let me know if I can provide any further information. Any help explaining what I am doing wrong would be greatly appreciated.
You're missing a directory in the 23094292 directory. There should be two directories in there, "files" and "etc". And then there should be a "README.txt" file there as well.
Edit: I'd just suggest removing the 23094292 directory and unzipping the zip file again, or re-download it if that doesn't work.

How to get a .exe packaged Ruby Shoes app to reference resources outside the package?

I'm trying to make a standalone .exe packaged Ruby Shoes app that uses images dynamically, meaning whichever images is found in the folder of the .exe file.
Shoes.app() {
background "bg.jpg"
}
This code works if the image is in the same folder when the .exe is packaged, and the image seems to be packaged into the .exe since it's not needed in the same folder as the .exe for it to display when running the exe. But when you want it to load the file in the same folder as the .exe, packaging the app without the image, it does not show. I've tried different ways at finding absolute path to the current directory where the .exe is launched from, but they all seem to point to some temporary directory under AppData and not where the .exe file is located.
Edit: my first answer was incomplete. Windows is a little odd in Shoes for packaged apps. Write a little test script.
Shoes.app do
stack do
para "DIR: #{DIR}"
para "LIB_DIR: #{LIB_DIR}"
cdir = Dir.getwd
para "CWD: #{cdir}"
end
end
Dir.getwd is probably what you want.
Calling pwd should get you what you want
Nope, Ok sorry get it now !:-)
Shoes is opening your exe/shy into AppData/temp so working directory and __FILE__ both point there !
Someone, some time ago proposed this : Trying to access the "current dir" in a packaged Shoes app
must be a better way !
EDIT:
you probably want custom packager (check "i want advanced install options")
check "Expand shy in users directory"
Do as you done for regular packaging.
Now when launching the exe, it will ask you( or the user) to choose where to install your app, proceed, note the directory.
Now before launching the installed app feed the noted directory with your resources and you should be ok
Some references : https://github.com/Shoes3/shoes3/wiki/Custom-Install-Scripts
(there's a lot more to it)
https://github.com/Shoes3/shoes3/issues/247#issuecomment-213919829

How get project parent directory in pom.xml

In maven set path to chrome driver as:
<driver.chrome>${project.basedir}/../repo</driver.chrome>
As result path is: D:\MyProj\..\repo
Answer: driver.chrome>file://${project.basedir}\..\repo</driver.chrome>
OK, I think I understand what you're asking. The resulting path you're getting is not minimized, but as far as I know, it is a valid path and it would work on any operating system.
In other words - D:\MyProj\..\repo is valid and equivalent to D:\repo. Go ahead and try to paste it into Windows Explorer and see if it opens it. Or cd to it in command prompt.

Use relative path in Firefox extension

I develop Firefox extension with bundled executable file which should be run on browser startup.
To run process I need get nsIFile or nsILocalFile instance which points to executable file.
I know one solution how to get it using directory service:
var file = Components.classes["#mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
file.append("extensions");
file.append("<extension id>");
file.append("<relative path>");
But this solution has two disadvantages:
It doesn't work in development mode, when instead of installed extension I have only text file with real extension path
I'm not sure that it will work on all Firefox configurations because of hardcoded "extensions" part of the path
So is there any nicer way to run executable file which comes with Firefox extension?
Thanks.
You are making way too many assumptions about the directory structure of the Firefox profile - don't. The Add-on Manager API lets you get the path of a file inside the extension, you should use it:
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("<extension id>", function(addon)
{
var uri = addon.getResourceURI("<relative path>");
var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file;
...
});
A restartless addon's startup function (in the bootstrap.js file) will receive, as its first parameter, the path where the addon is installed. You can then play various tricks to read files inside the .jar file, if any: see https://github.com/protz/GMail-Conversation-View/blob/master/bootstrap.js#L55 as an example.
In a non-restartless case, I must confess I don't have much of an idea :).
I found this thread looking for a way to reference a path to an image hosted in extension's directory from a content script. Here's a solution:
Include your files in web_accessible_resources in the extension's manifest.
"web_accessible_resources": [
"images/*"
]
Absolute paths to these resources contain randomly generated UUID, therefore we're using runtime.getUrl() giving it the path relative to manifest.json. Example:
let myImg = document.createElement('img');
myImg.src = browser.runtime.getURL("images/my-img.png")

How does MediaWiki calculate the file path to an image?

I'm just installing MediaWiki (loving it). I'm lookin at this for adding images. I can se the logic of
[[File:MediaWiki:Image sample|50px]]
but where so I set the filepath for "File" (nothing obvious in LocalSettings.php) ... or is there some other logic at work?
I'd appreciate any help
Thanks
File location is determined by $wgLocalFileRepo which by default depends on $wgUploadDirectory and $wgHashedUploadDirectory. The upload directory defaults to [MediaWiki base dir]/images (Adrian must be using an older version). If hashing is enabled, /x/xy will be appended to the path, where xy are the first two letters of the md5 hash of the filename.
The defaults from DefaultSettings.php are:
$wgUploadPath = "$wgScriptPath/uploads";
$wgUploadDirectory = "$IP/uploads";
If you want to change this, you should copy and paste this into LocalSettings.php
And make sure that $wgEnableUploads = true; is in LocalSettings.php too.
Your "Image sample" is the name of image, not the name of a file. By config file you can just set the root folder for image uploads.
Just for future reference in case someone else runs into this issue:
I installed MediaWiki on my Mac OS Sierra and when I attempted to upload an image I got the following message:
Failed:
Could not open lock file for "mwstore://local-backend/local-public/d/d9/babypicture.png".
I changed the permissions on the mediawiki_root/images folder to be owned by _www user and group.
chown -R _www:_www wiki/images
I was able to upload the image afterward.

Resources