AutoIt - Introduction - Get Auto It, Install, Components
AutoIT tutorial 2 Run from SciTe Editor
AutoIT tutorial 3 Open notepad
AutoIT tutorial 4 Wait For window to open
AutoIT tutorial 5 type a text
AutoIT tutorial 6 Save Notepad file using File Save Menu
AutoIT tutorial 7 focus file, type name, click on save button
AutoIT tutorial 8 Close Window
Full Source Code: for Notepad Automation
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is sample text")
WinMenuSelectItem("Untitled - Notepad","","&File","&Save")
WinWaitActive("Save As")
ControlFocus("Save As", "", "Edit1")
ControlSend("Save As","","Edit1","demo3.txt")
ControlClick("Save As","&Save","Button1")
WinWaitActive("demo3.txt - Notepad")
WinClose("demo3.txt - Notepad")
AutoIT tutorial 9 File Upload Dialog Automation
AutoIT tutorial 10 Integrate AutoIt Automation With WebDriver Automation
AutoIT tutorial 11 Parameterize AutoIt Script, Pass file path as argument
Full AutoIt Source Code: Upload Dialog Automation
WinActivate("Open") WinWaitActive("Open") ControlSend("Open","","Edit1",$CmdLine[1]); ControlClick("Open","&Open","Button1")
WebDriver & AutoIt integration code
Text:
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
* Upload file using Using AutIT
*
* @author vikas
*
*/
public class Example4 {
@Test
public void testCase1() {
System.setProperty("webdriver.chrome.driver", "e:\\drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://smallpdf.com/word-to-pdf");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebElement fileUploadElement = driver.findElement(By.className("omnibox-link"));
fileUploadElement.click();
// open the upload file / open file dialog
String filePath = "C:\\Users\\vikas\\Desktop\\input.docx";
ProcessBuilder pb = new ProcessBuilder("C:\\Users\\vikas\\Desktop\\S15\\uploadfile.exe", filePath);
try {
pb.start();
Thread.sleep(10000);
WebElement downlodFileElement = driver.findElement(By.xpath("//*[text()='Download File']"));
boolean isDownloadFileOptionDisplayed = downlodFileElement.isDisplayed();
Assert.assertTrue(isDownloadFileOptionDisplayed, "Download file link was not shown");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
No comments:
Post a Comment