Can I use links in setValue in file upload using nightwatch - testing

Can I use links in different site in setValue in file upload using nightwatch? I look up a link in stackoverflow and see this: File Upload Testing in Nightwatch.js but the answer said that it will not work if the file is coming from 'http://localhost:3000/testfile.txt'. Is this not possible?

The simple answer is no you can not specify the web server path.
You can read more about here.
What you can do is First download file and then use its absolutes or relative paths to upload.

Related

Relative path issue test cafe during file upload test using set files to upload()

I am trying to validate a file upload using test cafe.the things are fine when I give absolute path of the file with in the t.setFilesToUpload() but when I give relative path its not finding the files and says could not find the required file. Can anyone help with this?
I tried using relative path of the file to be uploaded.
It's not clear how you validate file upload. Please refer to the related help topic in the TestCafe documentation. If you still have issues after reviewing it, please share an example that reproduces the issue.

browse a file from my PC with selenuim

I want to write a selenium program on a site which I need as part of the process to browse a file from the operating system. How can I do that?
If you mean to use Selenium to open a html file on local, it's easy to do.
1. open the html file on browser
2. copy the url in browser address, it should be like:
file:///C:/workspace/js-projects/tey/protractor-cucumber-tey/reports/cucumber_report.html
3. put above url in browser.get()
Better way it's to caclcute the html file absolute path in your scritp dynamically (rather than hard code), then prefix with file://// on the path, possible need to replace '\' to '/' in path.
I don't know what you mean by "browse a file from the operating system."
If you mean choosing file to upload, you can.
see link below
https://www.programcreek.com/java-api-examples/index.php?api=org.openqa.selenium.remote.LocalFileDetector
If you want to browse a file in the local machine with the OpenFileDialog (not sure if this is what you are looking for), in my case, I created an autoIt script, building it as .exe and then call it from Java code (or any programming language you are using with Selenium).
I found an exmaple, it might works: https://github.com/ellysh/autoit-examples/blob/master/Helpfile/FileOpenDialog.au3

How to download a file through a link with its extension type with scrapy

I am using scrapy to scrape a website and I can download the file from the page, however everything that is being download is a plain text file. How do I download it with it's extension type? I am downloading scripts and as such, having the proper extension type on my download is necessary.
For example, if I am downloading exploits from exploit-db, the link that I go to to download them would be for example: https://www.exploit-db.com/exploits/19832/
and the link i would extract from there to download from is https://www.exploit-db.com/download/19832 which will, if I click on it normally, download a ruby file. But through scrapy it gets saved as a text file. Is there a way to download it as a .rb through scrapy?
Just save it as filename.rb. All files are text/binary files. Extension is there just to tell your operating system what to use to understand that file.
(In some operating systems extension isn't even required since files have headers at the beginning of the file telling what they are)
You can do try this:
scrapy shell https://www.exploit-db.com/download/19832
Then in the shell or your spider just do:
with open('ruby_file.rb', 'wb') as ruby_file:
ruby_file.write(response.body)

Tcl/tk uploading files

I'm doing a package manager for Pure Data externals in which the user may have the option to upload the created package in a repository.
Unfortunately, I was not able to find a good example from which i can develop a file uploader in tcl.
Can someone help me with an easy to understand code?
Something simple that only needs the file (given by path), url, name and password from the user.
Take a look at these Tcl Wiki pages about upload.

automatically place downloaded files in folder bsed on downloads extension suffix

I’m making a simple web browser for work eeh, what I’d like to know is if its possible to save a file of a particular extension to a particular file.
I currently use google chrome when downloading a file it places this (regardless of extension) in a downloads folder without asking where I ant to download this too.
I want to achieve the same except that downloads with the extension .dwg are placed automatically in a folder named DWG DOWNLOADS…
How to achieve this in vb.net?
In any browser you have a config section.
In Firefox you have browser.download.useDownloadDir;true and browser.download.folderList;1
you can add your own config to allow different saved folder paths and dynamically modify them depending on the extension of the file you uploaded.
See a complete list of the web browser config with about:config in address bar.
Not real sure what you are asking, but if you are actually making a web browser just check the extension of the file you are requesting to download. If the extension is ".dwg" then save the file to the folder you want.
If you are wanting to automatically move Google Chrome downloads to a different directory, you can use a FileSystemWatcher to monitor for new files in Chrome's download directory and move them to another folder based on each file's extension.