Hello im attempting to use WebDriver extensions for selenium, however, at the point of trying to upload a file im becoming unstuck. Locally the file uploads through use of robot e.g: robot.keyPress(KeyEvent.VK_ENTER);
However on the grid the robot is not working as intended. How am I to file upload to the webapp using Selenium with WebDriver extensions?
I hope you are trying to upload a file from your local machine to the app?
The robot commands you are firing will be applied to the machine that the script is running on (where java is executing), they are not passed over to the node machine.
From Documentation:
All you need to do is use the sendKeys command to type the local path of the file in any file field. This works like a charm in all drivers. When moving this test to a remote server (such as, for example, our Selenium 2 Cloud), all you need to do is use the setFileDetector method to let WebDriver know that you're uploading files from your local computer to a remote server instead of just typing a path. Almost magically, the file will be base64 encoded and sent transparently through the JSONWireProtocol for you before writing the fixed remote path.
driver.setFileDetector(new LocalFileDetector());
...
WebElement upload = driver.findElement(By.id("fileupload"));
upload.sendKeys("/path/to/file.jpg");
driver.findElement(By.id("upload")).click();
See the tutorial
Related
I am Automating a Scenario for Web Application Over Windows which includes the File And Images to be Uploaded to a website, and on my local it is working fine through robot class **
but when i execute my tests over Jenkins my jobs get failed. I need to Upload my file to a web site executing over Remote machine.
**
For File Upload :-
I cannot simply upload the file using send keys method since The Input tag doesn't have File Type i.e. input[type!='file'].
Are there any other solutions to achieve this without using Robot Classes and Auto-It.
**
For File Download:-
**
And I also need to download the File from a web Application over remote and verify that it has been downloaded successfully provided there is no API for this.
When the file gets downloaded over the remote, I am not able to verify that whether it has been downloaded or not since Remote Machine execution is not visible.
Is there any way to achieve this, kindly please suggest.
As you are using remote desktop for execution of scripts which would fail robot class action calls as it needs screen to be unlocked.
For the better results try using AutoIt is a free ware tools used for such purposes.
AutoIt will identify browse file objects and perform actions on it as Selenium does on Web applications.
Identify the Windows control, through AutoItV3 Windows Info tool.
More detailed steps to use AutoIt is present in the below link:
https://www.softwaretestinghelp.com/autoit-tutorial-to-download-write-autoit-script/
Thanks and regards,
Sandeep Jaju
I want to try creating a program that can automate the storing of web address that is available on every downloaded file on a web browser.
My problem is I don't know where to start.
What am I planning to do is just save all the downloaded file's web addresses in a excel file.
Sample image using google chrome
I think Firefox stores the download history in the places.sqlite file in your Profile folder. You would need to open and read that file, but you probably can't while Firefox is open (it has the file open).
http://kb.mozillazine.org/Places.sqlite
From there, you can process the data in your Java app and then write an Excel file, perhaps using Apache POI (the Java API for Microsoft Documents)
https://poi.apache.org/
Where and how, download history is stored varies from browser to browser . In case of Chrome on Mac it is store in the path
~/Library/Application\ Support/Google/Chrome/Default/DownloadMetadata
as SQLite format.
You need to write an application to parse the data and create xls
I would like to have a link or button on my web site that launches
vim (an editor) on a specific file (e.g., myfile.txt) on my local machine.
I want to launch C:\Vim\Vim74\gvim.exe on C:\Users\paulco\myfile.txt form any browser.
I want this to work on all (realistically most) browsers.
I actively use Chrome, Opera, FireFox and IE (in that order of preference).
In order for it to work across all of these browsers,
I think the script has to Java-based.
Does anyone know how to do this?
Does anyone have a Java-based script that does this?
Here are some resources I found on the topic.
But either they are IE specific or don't work.
Launch application from a browser
http://msdn.microsoft.com/en-us/library/aa767914%28VS.85%29.aspx
I have tested the following on Internet Explorer, Chrome, Opera and Firefox.
The browser has to run on a Windows operating system, Linux and Mac require different aproaches.
Solution is to define a protocol handler for a custom protocol.
1) Take this HTML example, it should open the specified text file using notepad.exe:
Open Textfile
2) You need to define the protocol handler in the windows registry, save the following to a file named testing.reg and execute it (double click on it), or enter the values manually using regedit:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\test]
#="URL:Editor test"
"URL Protocol"=hex(2):00,00
[HKEY_CLASSES_ROOT\test\DefaultIcon]
#="\"C:\\Windows\\system32\\notepad.exe\""
[HKEY_CLASSES_ROOT\test\shell]
[HKEY_CLASSES_ROOT\test\shell\open]
[HKEY_CLASSES_ROOT\test\shell\open\command]
#="\"C:\\temp\\editor.bat\" %1"
3) As you can see, I am not calling notepad.exe directly, but a c:\temp\editor.bat batch file. This is because the file-parameter has to be modified. using the %1 as a parameter will pass the complete URL including the test: custom protocol name to the shell. In the script, I use a simple substring pattern to extract the specified file name and call the editor:
REM editor.bat
set param=%1
notepad %param:~5%
That's all!
I want to launch a exe file when click on the button from my appliction and that should be from client machine. I tried with following solutions.
Runtime.getRuntime().exec(".....\\somefile.exe");
when I follows the above solution then it was opened server machine exe file.
I applied one more solution in script code
i.e
**var ws = new ActiveXObject("WScript.Shell");
ws.Exec("...\\somefile.exe");**
the above code working fine but I need to enable ActiveX related script enble mode in client browser window manually and it is only applied for IE only.
Let me know any solution that is browser independent and without activex enable option.
My selenium based test-suite works fine while I was controlling just the browser.
A new test case I need to add into the suite which requires interacting with Windows Browse/Upload file explorer after selenium has clicked upload button in under test page on the browser.
I couldn't find anything in Selenium RC documents about how to write filename in the (windows GUI) browse's "file name" field and click (windows GUI)Open button. Any ideas? Thanks!
Just to let you know in advance.
The test-suite executes test on 100s of remote machines concurrently. So auto-it-script workaround won't work for me.
Selenium RC supports file upload, but not using the browser mechanism directly. Check out the AttachFile() method, which takes a URL for the file and downloads it to the browser machine before then uploading it to the application.