Automating Windows Alerts and Popups
warning
- AutoIt scripts work on windows only.
- Works with AutoIt3 only.
Selenium Agent is able to run native scripts with AutoIt. To run a native script use the command:
driver.executeScript("seetest:client.runAutomationScript("Your script")", [TIMEOUT_IN_MSEC]);
info
- Every line in the script should end with a "\n" character.
- Strings passed in the script should be in ' and not ".
- Timeout is the time frame in which the script should be done, default is 20 seconds.
The script will run on Selenium Agent's machine and will throw an error if the script fails or hit a timeout of 20 seconds.
Example Expand source
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
public class PerformanceTransaction {
private RemoteWebDriver driver;
@Before
public void setUp() {
DesiredCapabilities dc = new DesiredCapabilities();
URL url = null;
try {
url = new URL("<Cloud URL>");
} catch (MalformedURLException e) {
e.printStackTrace();
}
dc.setCapability("username", "<username>");
dc.setCapability("password", "<password>");
dc.setCapability("platformName", CapabiltyType.WINDOWS);
driver = new RemoteWebDriver(url, dc);
}
@Test
public void automationScriptTest() {
String script = "WinWaitActive('Windows Security')\nSend('[USER]')\nSend('[PASS]')\nSend('[ENTER]')";
String ret = (String) driver.executeScript("seetest:client.runAutomationScript", script, 20000);
System.out.println(ret);
}
@After
public void tearDown() {
driver.quit();
}
}