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.
Related
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
I'm writing an automated test for a web application with Java + Selenium.
In that test I need to upload a certificate to login on the web application.
For uploading the file I use an AutoIt script like this:
Local $hWnd = WinWaitActive("Upload file")
WinActivate($hWnd)
ControlSend ($hWnd, "", "", "C:\my_cert.p12")
Sleep(5000)
Send("{ENTER}")
Exit
I run this script from Java test and it works perfect on my PC (Windows 10).
When I run my Java test from Jenkins on a remote PC (Windows 7) it works fine when I connected on that PC with remote desktop connection manager, and looking how it works.
BUT when I minimize the remote desktop manager (or shut it down) and run the test again it gets stuck the moment the AutoIt script needs to insert the file path to the upload window. It looks like the script didn't see the upload window and continues to wait for it.
I've tried to use java.awt.Robot, but it gave the same result.
If it helps: AutoIt detects that the upload file window has a class called SunAwtDialog.
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 RC java code is running successfully on firefox. Can anyone tell me how to run the same test case on internet explorer?
Change the browser start command string you pass to DefaultSelenium factory. It will be *iehta or *iexplore depending on your selenium version.
new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/");
Check out the docs for more info.
--Sai
Just replace *firefox with *iexplore. The exact code will vary depending on what language you're writing your test in or how you're actually launching the browser.
see: http://seleniumhq.org/docs/05_selenium_rc.html#from-selenese-to-a-program and click the button for your particular language.
If you hit the Script error while running tests on IE with selenium RC, it might be because of not running the selenium server with Administrator privileges. I had the similar issue and could get it running with by running the selenium server as an Administrator
Very simple: Use "*iexplore" instead of "*firefox"
In order to work the scripts on IE do the following steps
1.Navigate to ToolsInternet OptionsSecurityTrusted Sites
2.Click on “Sites” button and add the Urls of the application you are testing in “Add this website to the zone:” and clicking on “Add” button.
3.Navigate to ToolsInternet OptionsSecurity and disable the checkbox “Enable Protected Mode (requires restarting Internet Explorer)” and click on “Apply” and click “Ok”.
a. Navigate to ToolsInternet OptionsSecurity
b. Add all the URL’s of your application in the “Address of websites to allow” and click on “Add” button.
Navigate to ToolsInternet OptionsAdvanced options. Scroll down to the Security section, and select Allow active content to run in files on my computer. This will get rid of the pesky toolbar alert, and allow JavaScript to run automatically.