Cypress: How to attachFile from different folder - cypress

I have to upload a file from a different folder than /fixtures.
If I use attachFile it always adds the path cypress/fixtures in front of it.
cy.get('input[type="file"]').attachFile(this.uploadFileName );
cy.get('#file-submit').click();
Where this.uploadFileName has an absolute path to the file.
The file is generated before, so it is not really a fixture anyway.

Currently, attachFile can only import file from the fixtures folder. Hence, the generated file has to be imported into the fixture file (via task and fs.copy()).

Related

Sass::Importers to load from an alternative fallback folder

I'm trying to use a frontend project as a git submodule so i can use it as fallback import path if there is no file in the current project.
On the config.rb of the assets/sass/ folder, one simple line is required:
add_import_path "../../frontend/assets/sass/"
This way, if no file exists on the assets/sass/ folder structure it will try to find it on frontend/assets/sass/ folder.
This works but every #import tries to load relatively to the file where the #import is. I'm thinking on developing a Sass Importer that first tries to load the same file from an "A" folder structure and if it doesn't exists tries to load from "B" folder structure.
So, if there is a "assets/sass/common/base/_!base.scss" with an
#import "fonts/fonts";
First it will try to load it from:
assets/sass/common/base/fonts/_fonts.scss
And if it doesn't exist it will try to loads from:
frontend/assets/sass/common/base/fonts/_fonts.scss
So the question is:
Is possible to accomplish that with a Sass importer?
Looking for documentation (http://sass-lang.com/documentation/Sass/Importers/Base.html) or examples i didn't found something like this but i think it is not a strange case. I'm not used writing Ruby code so i must confirm if it can be done before i try to write some code.

Copy to directory outside of project directory using Gradle 4.0.2

I have a gradle build which generates war file. I want to copy war file to my application servers' dropins directory which is somewhere outside of project directory. I have following copy task to do this.
task copyWarToDropins(type: Copy,dependsOn:[war]) {
from './build/libs/bds-service-token-1.0-SNAPSHOT.war'
into file('/apps/dropins') // want to copy to 'C:/apps/dropins' directory
rename { fileName -> 'bds-service-token.war' }
}
build.dependsOn copyWarToDropin
It evaluates /apps/dropins relative project directory and does copy there. I have tried many ways I can think of but could not make it copy to C:/apps/dropins directory.
Can someone please help?
First, please note that using into file(...) is redundant, as each call to into(...) will be evaluated via Project.file(...) anyhow.
As you can read in the documentation , file(...) handles strings in the following way:
A CharSequence, including String or GString. Interpreted relative to the project directory. A string that starts with file: is treated as a file URL.
So, one way to solve your problem could be using an absolute file URL.
However, if you continue to read the documentation, you will see that Java File objects are supported. So you could simply create such an object:
into new File('C:/your/absolute/path')

Get File Names in Resource directory

I have a Xamarin.Forms GetFiles.IOS project that has a "Resources" directory that's part of the project. I have placed 25 files into the Resources Directory. I now want to be able to go to the resource directory and get all the file names. I created some code to read the files in the directory but I'm getting a DirectoryNotFoundException. Here's the code I'm using.
String dir = Directory.GetCurrentDirectory();
var filePath = Path.Combine(dir,"Resources");
String[] files = Directory.GetFiles(filePath);
I just can't seem to get the path correct!
Thank you for helping me.
There are two things necessary to have the files be copied into the app folder:
They need to be set with Build Action Content with Copy to Output Directory Copy Always in the Properties window.
They must be in a different custom folder than Resources.
Number 2. is because Resources is a special reserved directory name and even if you put some content files in it, it is never copied in the app bundle's folder. You can check for yourself, if you put the files in a folder Test, your code will work as intended.

Include docx file in asciidoc?

I am using asciidoc with asciidoctor to create documentation for a current project.
I notice there is a markup to include files in the documentation like so:
link:index.html
or
link:protocol.json[Open the JSON file]
Is it possible to include a docx file as a link so that it would open externally or be able to downloaded?
Also can I put this file in a folder inside my asciidoc directory (for the sake of organization) and still be able to properly reference it?
You write something like this:
Open this link:somefile.docx[Word file] should work.
Or this link:file:///C:/Users/xxx/docs/otherfile.docx[second file].
It works with relative path or absolute path.
You need to ensure that the path to your file will be correct for the reader of your document.
Example: if you put the HTML files produced by Asciidoctor on a webserver (public or intranet), having a path referencing your local C: is not a good idea.
It is hard to tell you what to do without knowledge of your publication/distribution toolchain.

Path for images folder in GWT project

I have the following line of code to set the URL of an image I want to display
img.setUrl("images/img1.jpg");
Where should I place my images folder in order for it to get picked up correctly. Currently I have it in my WEB-INF folder but this does not appear to work. I get the error on my console "WARNING: No file found for: /images/img1.jpg"
I created my project using Eclipse and I have not changed any folder structure.
You should make a folder named images under your war/project_folder and place the images there.
And while setting the Url you shoud do
image.setUrl(GWT.getModuleBaseURL()+"images/im1.jpg");
You can use either GWT.getModuleBaseURL() or GWT.getHostPageBaseURL().
Create a public folder (named "public") alongside with folders "client" and "server". The content of the public folder will be copied into the war.
>src
>com
>test
>client
--->public
>images
>server
>shared
Voilà!
It is always better to use absolut URL rather than relative URL by using GWT.getModuleBaseURL(). If you want to use relative path, then your image should be in the war as described by your relative path.
In your case it is
war->images->img1.jpg
You need to put the images in the web app directory.
You can check your web app directory here
Proeect --> Properties --> Google --> web Application
Here you will find the WAR directory
So in this directory , you need to put your images.
You can put the image directly or else you can make folders as you want
sample -
image path --> WebContent/img/pics/recent/data/1/1.jpg
String imagePath = "/img/pics/recent/data/1/1.jpg" ;
Image img = new Image(imagePath);
NOTE :- How ever GWT Image does not understand absolute file path , you need to use relative file path

Resources