Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

How to automate upload image functionality using Selinium IDE

View previous topic View next topic Go down

How to automate upload image functionality using Selinium IDE

Post by kaykay81 on Thu Nov 10, 2011 6:33 pm

Hi all,

I want to automate upload image functionality using Selinium IDE.
Can any one help me regarding it ????
The upload is similar to attach files in mail..


Thanks & Regards,
KayKay

kaykay81

Posts : 3
Join date : 2011-09-27

Back to top Go down

Re: How to automate upload image functionality using Selinium IDE

Post by freesky on Fri Nov 11, 2011 3:53 pm

I'm afraid selenium ide can't do that. maybe u can use selenium with AutoIT. I refer to somebody's article, hope to help you.
Recently,I had the challenge of writing some automation for a workflow
which includeduploading a file, and then downloading a file later in the
workflow. The team with whom I am working had used some Selenium
fortheir tests, and preferred to keep doing so, if possible, but their
effortsprior to my arrival on the team to get the upload/download
portions of the codeworking with Selenium had been unsuccessful.
The problem basically boils down to twopoints:
The JavaScript interpreters in mostbrowsers have specific protections built in to prevent
JavaScripts from filling in “file”fields, such that when they tried
“type” “filefield” “myfile.txt”, nothingwould happen in the browser.

When attempting to use the click commandon the “browse”
buttonof the field, moreover, causes a modal dialog which holds focus
such that theclick command does not return, because it is waiting for
feedback from thebrowser, until the modal file picking dialog closes.

So,
you can’t type into the file field,and you can’t click on it to open
the file dialog, because even if you can typeinto it, using native key
pressing, or another automation tool such as AutoItor AutoHotKey, which
can grab window focus, and send typing events, you’restill kind of
hosed, because until your script returns from the click event,which it
won’t because there’s this modal window stuck out there, blocking it.
KeyDown and KeyUp don’t triggerany action in the control, good or bad.
So what to do?
Well, there are solutions, evenfairly easy ones, but they are probably
going to involve at least a littleplatform and browser-specific kludges,
which you can hopefully write intofunctions, and then never worry about
again. In some browsers, I was ableto use the focus(locator) command,
and then do native system typing withKeyPressNative, or AutoIt, which
allows me to grab the appropriate windowfirst, and simply send the
desired text. However, in some browsers, thiswill not work, as the
field will bring up the dialog when you begin to typeinto the field.
Below, you can find my solution.

System.out.println(”focusingon file field”);
selenium.focus(”uploadfile”);
if(T1.Browser.startsWith(”*ie”))
{
System.out.println(”Doingthe ie tabbing”);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB+ “”);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB+ “”);
selenium.keyDownNative(java.awt.event.KeyEvent.VK_SHIFT+ “”);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB+ “”);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB+ “”);
selenium.keyUpNative(java.awt.event.KeyEvent.VK_SHIFT+ “”);
System.out.println(”Submittingfile: ” + fname);
Processfileup = Runtime.getRuntime().exec(”C:\\autoit\\install\\AutoIt3.exe C:\\testfiles\\scripts\\submitFileName.au3\”" + fname + “\”");
fileup.waitFor();
selenium.click(”ok”);
}else {
if(T1.Browser.startsWith(”*firefox”))
{
getSystemFocus(”PCMS”);
selenium.focus(”uploadfile”);
System.out.println(”Doingthe firefox tabbing”);
selenium.setSpeed(”200″);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB+ “”);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB+ “”);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB+ “”);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB+ “”);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_TAB+ “”);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_SPACE+ “”);
getSystemFocus(”PCMS”);
System.out.println(”SpacePressed”);
System.out.println(”Submittingfile: ” + fname);
Processfileup
= Runtime.getRuntime().exec(”C:\\autoit\\install\\AutoIt3.exe
C:\\testfiles\\scripts\\submitFileNameFF.au3\”"
+ fname + “\”");
fileup.waitFor();
selenium.focus(”ok”);
selenium.keyPressNative(java.awt.event.KeyEvent.VK_SPACE+ “”);
System.out.println(”Dismissingthe security warning”);
Processsecwarning
= Runtime.getRuntime().exec(”C:\\autoit\\install\\AutoIt3.exe
C:\\testfiles\\scripts\\secwarning.au3″);
secwarning.waitFor();
System.out.println(”Dismissingthe security warning”);
selenium.setSpeed(”1200″);
}
There are a couple of small problems withthis solution as a general solution, but it does work for multiple browsers onWindows.
Not the leastproblem is that this will fail when running on a non-local
RC server. That can be gotten around by calling psexec or some similar
command on thehostname of the rc server, but this works only in a
Windows setup. Fornon-windows machines, a similar strategy could be
done, and you could probablyeliminate AutoIt and any outside tool by
calling keyPressNative commands foreach character of the file string,
but you may run into difficulties withsystem focus of the window.

What
would be ideal is a java tool whichcan grab window focus, and then type
in the appropriate file string, given asparameters, but I wasn’t able
to find or implement both of these requirementsin sufficient time.

freesky
Amateur
Amateur

Posts : 72
Join date : 2011-04-13

Back to top Go down

Re: How to automate upload image functionality using Selinium IDE

Post by sunny patel on Wed May 09, 2012 1:03 pm

Command = storeEval
Target = prompt("Please Enter Image path") //specify image path manually
Value = flImage1


Command = type
Target = name=flImage1
Value = ${flImage1}

sunny patel
Active particpant
Active particpant

Posts : 11
Join date : 2012-05-03
Age : 31
Location : Ahmedabad , India

Back to top Go down

Re: How to automate upload image functionality using Selinium IDE

Post by rohit13 on Wed May 09, 2012 1:37 pm

Try out below code..pass your xpath of text box
into target area
Code:

command=type
target=xpath_of_text_box
value=Path_of_your_image file

then click on upload button

_________________
Radical QA
http://radical-qa.blogspot.in/

rohit13
Master
Master

Posts : 180
Join date : 2012-03-29
Age : 30
Location : INDIA

http://radical-qa.blogspot.in/

Back to top Go down

Re: How to automate upload image functionality using Selinium IDE

Post by Sponsored content Today at 3:22 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum