Can some one tell me how can i add attachment in Gmail/Yahoo mail using selenium RC/Webdriver.
Please help me out in this situation.
Thanks in advance.
Install Autoit in your machine.
Write an AutoIT script as shown below.
WinWaitActive("Choose file") \\specify the name of the choose window
Send("C:\attach\samplefile.txt") \\location of the file you want to attach
Send("{ENTER}")
After writing the code, save a the file as attach.exe
Add the below line to your selenium code(if using java)
Runtime.getRuntime().exec("c:\\path\\attach.exe");
The above will be helpful in adding an attachment. Hope it helps!
I found the answer for this question using robot api. Thanks for ppl who responds this question.
Related
]1
There are many examples on what to do with file upload, however I could not find anything in selecting folder. Any ideas how to handle this ?
UPDATE:
I have tried 3 different ways but none worked :
the first is using sendkeys(). This does not work because there is no input field. This dialog opens when you click a button.
The second is using AutoIt, which is used in the uploading files dialog. It causes an error when i use it because I am not uploading a file but just selecting a folder.
the third is robot, where I copy the path I want to the clipboard and try to paste it with robot. It did not work for me.
Update 2:
If you open chrome://extensions/ on chrome browser and tick developer mode you will see a load unpacked extensions buttons. This is the button that when you click you get this windows dialog:
There are different ways by which you can handle File Upload :
Way 1:
WebElement fileInput = driver.findElement(By.name("uploadfile"));
fileInput.sendKeys("C:/path/to/file.jpg");
Way 2:
By using Robot Class API:
driver.findElement(By.By.name("uploadfile")).click();
Robot r = new Robot();
r.keyPress(KeyEvent.VK_KP_DOWN);
r.keyRelease(KeyEvent.VK_KP_DOWN);
r.keyPress(KeyEvent.VK_KP_RIGHT);
r.keyRelease(KeyEvent.VK_KP_RIGHT);
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
Hope it will help you
Selenium support is for Web browser and not for windows dialogs.
the only option for you is to write automation using coded UI or Autoit.
Selenium only works on Web browser, You can use AutoIT but I see you already tried it. In that case I would suggest you to use Sikuli.
Greetings !
I use selenium WebDriver to automate the browser , and in one of the particular flow when i click on a button it opens a PDF file in the UI...This PDF file i wont be able to handle with the webdriver commands..... fine.. So i go with the option of AutoIT to close this PDF file window and to proceed further with the webdriver commands present in the same java class....
But it looks not working for me , the autoIt script which i execute is not closing the pdf window..
I tried it many times by trying diff options,for ex: with scripts something below ..but no luck... Please share me if you are aware of how to handle this...
WinWait("[CLASS=AcrobatSDIWindow]") WinActivate("[CLASS=AcrobatSDIWindow]")
WinClose("[CLASS=AcrobatSDIWindow]")
Many Thanks in advance ~Musaffir
It looks working well for me now , autoit script with almost same line of codes as i posted in the question
WinWaitActive("[CLASS:AcrobatSDIWindow]")
WinActivate("[CLASS:AcrobatSDIWindow]")
WinClose("[CLASS:AcrobatSDIWindow]")
we need to run this script first in selenium java class, so when a pdf window comes in the UI,it just closes it
To run in the java code use: Runtime.getRuntime().exec("E:\\Auto_IT_Scripts_New\\Close_PDF_File.exe");
This will run the script in the system... and the script run stops once the file has been closed
Thanks,
Musaffir
In Selenium IDE, the application has got image as button. The click event for that is not capturing. Is there any alternative Selenium Commands available for that or otherwise, is there any JavaScript user extensions can be added?
Please help.
Thanks
Yes.. the image will act as a button..
Found a solution for that!!
Simply added a JavaScript code which supports clickAt() commands.
To detect button as image you can use one of the below solution
xpath=//img[#src='/images/logo_home.png']
xpath=//img[#alt='Home']
//img[#src='/images/logo_home.png']
I searched around and couldn't find how to test a file download box using capybara/cucumber?
The following image asks the question much clearer.
This was similar to another question I just answered, hope it helps Anybody have idea how to test file download using cucumber?
#Millisami Capybara::NotSupportedByDriverError Fixed for me!
What i had to do is removing the #javascript tag from my cucumber test, which was included. I mean:
#search
Scenario: Recieving a file
...
instead of
#search
#javascript
Scenario: Recieving a file
...
Hope it helps :-)
The download box is a function of the browser. Capybara simulates a browser but without all the UI etc.. (e.g. it looks like a browser to your application, so using it you'd mostly skip over the whole file download UI stuff. It would look to the browser like someone did whatever they needed to in order to tell the browser where to put the file and start the download)
If you are trying to test a download box, (beyond clicks needed to start the download) you are now testing the browser, not your application. As yourself if that's part of your charter and worth your time.
To actually test the download box you are going to have to have a browser instance going, and use a tool like Firewatir/Watir or Selenium, to actually 'drive' the browser, and some other gem to actually automate up at the OS UI level (on windows we usually use autoit) in order to click things and fill in values of the browser's file download UI.
I am new in Selenium automation. Could you please explain me how to use this (if one exists) tag? It would be really helpful if you can give example.
The scenario where I am facing problem is: there is a save button, if we click on it a dialog box pops up. I need to enter some text in two text boxes and press save/cancel button on the same dialog. I am using Selenium as a tool and Python as a scripting language. Any help on this will be appreciated.
Thanks in advance!
sel.click("idOfSaveButton")
sel.wait_for_pop_up("popupWindowName", "30000")
sel.select_window("name=popupWindowName")
sel.type("idOfTextBox1", "someText")
sel.type("idOfTextBox2", "someText")
sel.click("idOfCloseButton")
sel.select_window("null")
You can also select the popup window using title=.
You can wait for the confirm box, then switch to it and do whatever you want. I asked familiar question before and the answer is here. Hope it helps.