I have been reading many mails from various selenium groups where people asking for solution on uploading files through desktop in case sendkeys is not working where the input element is not associated with the browse button since a window's pop up is opened which only accepts a stand-alone file.
Some lines from Auto-it website:
Here you need to integrate Auto-it to make it work. Auto-it comes with various components and a complete workflow:
Steps to follow:
Step 1: Download Auto-it from here
Step 2: You will get an installer, just double click and run the executable file.
Step 3: Following components will be installed on your machine
SciTe Script Editor - Use for writing scripts & compiling programs.
AutoIT window info - Locate class & property of the window's based element etc.
Step 4: Write the script using the SciTe Script Editor. Copy and paste the below script in the editor and save it with .au3 format and then compile it by clicking on Tools menu --> Compile
Opt("MustDeclareVars", 1);0=no, 1=require pre-declare
Main()
Func Main()
Local Const $dialogTitle = $CmdLine[2]
Local Const $timeout = 5
Local $windowFound = WinWait($dialogTitle, "", $timeout)
$windowFound = WinWait($dialogTitle, "", $timeout)
Local $windowHandle
If $windowFound Then
$windowHandle = WinGetHandle("[LAST]")
WinActivate($windowHandle)
ControlSetText($windowHandle, "", "[CLASS:Edit; INSTANCE:1]", $CmdLine[1])
ControlClick($windowHandle, "", "[CLASS:Button; TEXT:&Open]")
Else
MsgBox(0, "", "Could not find window.")
Exit(1)
EndIf
EndFunc
Step 5: After compile the script you will get a .exe file that is created on the same location where the script is placed
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class testImageUpload {
public static void main(String[] args) throws IOException {
WebDriver driver = new FirefoxDriver();
driver.navigate().to("http://www.imageshack.us/");
driver.findElement(By.xpath("//*[@id='SWFUpload_0']")).click();
Process process = new ProcessBuilder("C:\\Users\\selenium\\auto.exe",
"C:\\Users\\selenium\\test.png", "Open").start();
}
}
Some lines from Auto-it website:
AutoIt v3 is a 3rd
party freeware BASIC-like scripting language tool designed for automating the
Windows GUI and general scripting. It uses a combination of simulated
keystrokes, mouse movement and window/control manipulation in order to automate
tasks in a way not possible or reliable with other languages (e.g. VBScript and
SendKeys).
Here you need to integrate Auto-it to make it work. Auto-it comes with various components and a complete workflow:
Steps to follow:
Step 1: Download Auto-it from here
Step 2: You will get an installer, just double click and run the executable file.
Step 3: Following components will be installed on your machine
SciTe Script Editor - Use for writing scripts & compiling programs.
AutoIT window info - Locate class & property of the window's based element etc.
Step 4: Write the script using the SciTe Script Editor. Copy and paste the below script in the editor and save it with .au3 format and then compile it by clicking on Tools menu --> Compile
Opt("MustDeclareVars", 1);0=no, 1=require pre-declare
Main()
Func Main()
Local Const $dialogTitle = $CmdLine[2]
Local Const $timeout = 5
Local $windowFound = WinWait($dialogTitle, "", $timeout)
$windowFound = WinWait($dialogTitle, "", $timeout)
Local $windowHandle
If $windowFound Then
$windowHandle = WinGetHandle("[LAST]")
WinActivate($windowHandle)
ControlSetText($windowHandle, "", "[CLASS:Edit; INSTANCE:1]", $CmdLine[1])
ControlClick($windowHandle, "", "[CLASS:Button; TEXT:&Open]")
Else
MsgBox(0, "", "Could not find window.")
Exit(1)
EndIf
EndFunc
Step 5: After compile the script you will get a .exe file that is created on the same location where the script is placed
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class testImageUpload {
public static void main(String[] args) throws IOException {
WebDriver driver = new FirefoxDriver();
driver.navigate().to("http://www.imageshack.us/");
driver.findElement(By.xpath("//*[@id='SWFUpload_0']")).click();
Process process = new ProcessBuilder("C:\\Users\\selenium\\auto.exe",
"C:\\Users\\selenium\\test.png", "Open").start();
}
}
Image upload example used for demonstration in this article is at:
http://imageshack.us/
Hi All,
ReplyDeleteBy using webdriver i am implementing mouse over functionality on my website-tjc.co.uk but it is not working correctly.can anyone help me out.
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class testMouseovermenu {
public static void main (String[]args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.tjc.co.uk");
driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
WebElement topmenu = driver.findElement(By.xpath("//*[@id='topnav']"));
WebElement menu = driver.findElement(By.xpath("//*[@id='topnav']/li[2]/a"));
Thread.sleep(5000);
Actions action = new Actions(driver);
action.moveToElement(menu).perform();
driver.findElement(By.xpath("//*[@id='topnav']/li[2]/div/ul[1]/li[3]/a")).click();
}
}
This is my code.can anyone tell me where i am wrong.
Hi all,
ReplyDeleteI want to run my code on ie9,
I downloaded the file what next i have to do.please tell me
Thanks
Tarun Mehrotra
Try this. It works fine all the time for me:
ReplyDeleteSystem.setProperty("webdriver.ie.driver", "c:/softwares/IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.tjc.co.uk");
driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
WebElement menu = driver.findElement(By.xpath("//*[@id='topnav']/li[2]/a"));
Actions action = new Actions(driver);
action.moveToElement(menu).perform();
driver.findElement(By.xpath("//*[@id='topnav']/li[2]/div/ul[1]/li[3]/a")).click();
I am not able to put "if else" condition for Drop down.
ReplyDeleteurl :https://www.thejewellerychannel.tv/register.aspx
(Use Drop down of Where did you hear about us)
suppose i have a dorp down box with multiple option of City name like : delhi,noida and other . here if we choose delhi and noida option in drop down than it move for submit button or when we choose "other" option in drop down then it move on text box for city name
how can solve this prob with RC by using Xpath
Hi all,
ReplyDeletecan anybody help me how to write in google search using webdriver.i tried different ways by xpath ,by name.but not getting any sloution
Thanks
Tarun mehrotra
Hi All,
ReplyDeletecan anyone tell me how can i find number of pages using webdriver.
Thanks
Tarun Mehrotra
Hi All,
ReplyDeleteI am getting error in this code.
I have imported all the jars.
POi
and excel jars still ia m not able to run.Can anyone tell me why i am getting error.
.public static Collection getData(){
if(excel == null){
// load the Excel sheet
excel = new Xls_Reader("D://seleniumtest/Test.xlsx");
}
String sheetName="Test";
int rows = excel.getRowCount(sheetName); // Get Row Count
int cols = excel.getColumnCount(sheetName); // Get Col Count
Object data[][] = new Object[rows-1][cols]; //-1
for(int rowNum = 2 ; rowNum <= rows ; rowNum++){ //2
for(int colNum=0 ; colNum< cols; colNum++){
data[rowNum-2][colNum]=excel.getCellData(sheetName, colNum, rowNum); //-2
}
}
Hi All,
ReplyDeletewhen i am running my code by using ant through command prompt at the time of run it is showing me this error"E:\selenium work\testjunit\build.xml:105: The for must inclu
de junit.jar if not in Ant's own classpath" can anyone help me out why i am getting this error.
hi your code working fine for me
ReplyDeletethanks
skype : subash.chanra.bose
Hi,
ReplyDeleteIf in run my script in firefox its working fine.Same script I run IE flickering Problem arises,can any body help me out.Iam using IE version8 and drivers IEDiverServer
Regards,
Lavanya
This comment has been removed by a blog administrator.
ReplyDeleteHi,
ReplyDeletewhen i try this on my computer it worked,
but when i run this on remote computer it failed with the error
java.io.IOException: Cannot run program "C:\grid\test1.exe": error=2, No such file or directory
please help
This comment has been removed by a blog administrator.
ReplyDeletehi i do the same thing in python !!!! could you help me calling the autoit .exe file from python ???
ReplyDeleteHi Raman,
ReplyDeleteI used the same code which you have posted for file upload,it works fine till capturing path.After capturing the path its not selecting the given file,please let me know how to resolve this issue at the earliest.
Thanks,
Pavitra
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteOh, that's Great Post Thanks for sharing with us. This Big data hadoop training in Bangalore Platform helped me to learn advanced concepts of all the trending technologies out there in the current IT market. really worth trying them.
ReplyDelete
ReplyDeleteI have read your blog very useful information to everyone.Thanks for sharing and keep updating more.If you are looking for python course visit our website.
Python Training Institute In Bangalore
Very helpful. Thanks for sharing it
ReplyDeleteexcellent...!
ReplyDeleteinternship in chennai for ece students
internships in chennai for cse students 2019
Inplant training in chennai
internship for eee students
free internship in chennai
eee internship in chennai
internship for ece students in chennai
inplant training in bangalore for cse
inplant training in bangalore
ccna training in chennai
An nice and excellent information.
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
Generally excellent review. I absolutely love this site. Much appreciated!tech updates
ReplyDeletesalesforce training in bangalore
ReplyDeletesalesforce course
Yeni perde modelleri
ReplyDeletesms onay
TÜRK TELEKOM MOBİL ÖDEME BOZDURMA
nft nasil alınır
ankara evden eve nakliyat
Trafik Sigortasi
dedektor
HTTPS://KURMA.WEBSİTE/
aşk kitapları
Smm panel
ReplyDeletesmm panel
iş ilanları
instagram takipçi satın al
Hırdavatçı burada
beyazesyateknikservisi.com.tr
servis
TİKTOK JETON HİLESİ