Prerequisite:
- Eclipse IDE
- Point Position Tool
- Autoit V3
- AutoIt window info
Selenium is not able to identify the element or "Browse" button to click.
Example:
<input name="BROWSECV" id="browsecv" size="37"> </input>
or
you can go to below link and inspect the browse button.
Link: http://my.naukri.com/manager/createacc2.php?othersrcp=11499&wExp=N
or see the screen shot to know more
To handle such situation in Selenium we have to use third Party Tools such as Point Position, Autoit etc...
Below is the example to handle above "Browse" button from above link.
First we can create a file in Autoit v3 to handle browse button.
open the SCiETE Script Editor
write the below code into it.
Code:
ControlFocus("Open","","Edit1")
ControlSetText("Open","","Edit1","D:\Avinash\FileUpload.txt")
ControlClick("Open","","Button1")
- Save above file named as - NaukriFileUpload.au3
- Go to file stored location and compile it.
- it will produces the NaukriFileUpload.exe
The parameters name "Open", "Edit1" , "Button1" in above code has been inspect it by using Autoit Window info tool.
We drag The option "Finder tool" from Autoit window info to "File Name" text box then "open" button to read Title. class &Instance parameter information of each control on OpenfileDialog Window popup.
because we need these parameter information to AutoIt functions such as ControlFocus, ControlSettext etc...
See below screen shot to know more details:
Next:
Point Position:we use point position tool to identify the X & Y coordinate of Browse button from Naukri.com or above link.
then we will click it on that X,Y coordinate by using javas robot class.
See the screen shot, how to use Point Position tool
Next:
Open Eclipse IDECreate a Java project
Create a package under Src folder.
Create a Testcase
write the below code in that TestCase
package fileupload;
import static org.junit.Assert.*;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.io.File;
import java.io.IOException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FileUpload
{
WebDriver driver = null;
WebElement element = null;
JavascriptExecutor js = null;
@Before
public void setUp() throws Exception
{
driver = new FirefoxDriver();
driver.manage().window().maximize();
}
@Test
public void test() throws AWTException, InterruptedException, IOException
{
driver.get("http://my.naukri.com/manager/createacc2.php?othersrcp=5424&wExp=N&id=");
Thread.sleep(5000);
((JavascriptExecutor)driver).executeScript("window.scrollTo(0,700)");
int x = 537;
int y = 331;
Robot r = new Robot();
r.mouseMove(x, y);
r.mousePress(InputEvent.BUTTON1_DOWN_MASK);
r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
r.mouseMove(545, 345);
r.mousePress(InputEvent.BUTTON1_DOWN_MASK);
r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(3000);
Runtime.getRuntime().exec("G:\\Autoit\\NaukriFileUpload.exe");
}
@After
public void tearDown() throws Exception
{
driver.close();
element = null;
}
}
I can reduce the image size using html but this concept is really new to me.These coding also explain clearly.Thank yo friends..
ReplyDeleteLoadrunner Training in Chennai
I am very impressed with the article I have just read,so nice.......
ReplyDeleteManual Testing Training in Chennai
QTP Training in Chennai
selenium Training in Chennai
loadrunner Training in Chennai
ETL Testing Training in Chennai
jmeter Training in Chennai
appium Training in Chennai
Best Oracle Training In Chennai
This post is really nice and informative. The explanation given is really comprehensive and informative..
ReplyDeleteSAS Training In Chennai
Greens Technology's. the leading software Training & placement centre Chennai & (Adyar)
ReplyDeletethe best sas training in chennai
This post is really nice and informative.
ReplyDeleteoracle training in chennai
nice.......
ReplyDeleteinformatica training in chennai
Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.
ReplyDeleteangularjs Training in marathahalli
angularjs interview questions and answers
angularjs Training in bangalore
angularjs Training in bangalore
angularjs online Training
Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
ReplyDeleteJava training in Bangalore | Java training in Kalyan nagar
Java training in Bangalore | Java training in Kalyan nagar
Java training in Bangalore | Java training in Jaya nagar
I am sure this post has helped me save many hours of browsing other related posts just to find what I was looking for. Many thanks!
ReplyDeletepython training Course in chennai
python training in Bangalore
Python training institute in bangalore
Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information.
ReplyDeleterpa training in chennai
rpa training in bangalore
rpa course in bangalore
best rpa training in bangalore
rpa online training
Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information.
ReplyDeleterpa training in chennai
rpa training in bangalore
rpa course in bangalore
best rpa training in bangalore
rpa online training
Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
ReplyDeleteBest Devops training in sholinganallur
Devops training in velachery
Devops training in annanagar
Devops training in tambaram
This looks absolutely perfect. All these tiny details are made with lot of background knowledge. I like it a lot.
ReplyDeleteData Science training in kalyan nagar
Data Science training in OMR | Data science training in chennai
Data Science training in chennai | Best Data science Training in Chennai
Data science training in velachery | Data Science Training in Chennai
Data science training in tambaram | Data Science training in Chennai
Data science training in jaya nagar | Data science Training in Bangalore
thank you for sharing this
ReplyDeleteBEST ANGULAR JS TRAINING IN CHENNAI WITH PLACEMENT
https://www.acte.in/angular-js-training-in-chennai
https://www.acte.in/angular-js-training-in-annanagar
https://www.acte.in/angular-js-training-in-omr
https://www.acte.in/angular-js-training-in-porur
https://www.acte.in/angular-js-training-in-tambaram
https://www.acte.in/angular-js-training-in-velachery
Nice tips and it is very informative.
ReplyDeleteAngularJS training in chennai | AngularJS training in anna nagar | AngularJS training in omr | AngularJS training in porur | AngularJS training in tambaram | AngularJS training in velachery
Nice Post! Thank you for sharing very good post, it was so Nice to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteJava training in Chennai
Java Online training in Chennai
Java Course in Chennai
Best JAVA Training Institutes in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Training
Java Online Training
Your technical information related with java programming is very useful and interesting. Also share updated details about java in your website. Thanks for sharing this article.
ReplyDeleteAngular js Training in Chennai
Angular js Training in Velachery
Angular js Training in Tambaram
Angular js Training in Porur
Angular js Training in Omr
Angular js Training in Annanagar
"Uploading files using Selenium WebDriver in Java with AutoIt simplifies automation tasks, much like understanding how much George Foreman worth reveals the value of smart investments. Both showcase the importance of leveraging the right tools—whether in tech or business—to maximize efficiency and achieve successful outcomes."
ReplyDeleteLearning how to upload files using Selenium WebDriver with AutoIt in Java is a game-changer for automating complex workflows. Just like streamlining tasks in automation, choosing premium products can simplify your vaping journey. Check out Elux Liquids for a hassle-free and satisfying experience. Thanks for sharing this helpful tutorial!
ReplyDelete