Page tree
Skip to end of metadata
Go to start of metadata

Important

  • 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]);

Please note

  • 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
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 ret = (String) driver.executeScript("seetest:client.runAutomationScript("
                        + "WinWaitActive('Windows Security')\n"
                        + "Send('[USER]')\n"
                        + "Send('[PASS]')\n"
                        + "Send('[ENTER]')"
                        + ")", 20000);

        System.out.println(ret);
    }

    @After
    public void tearDown() {
        driver.quit();
    }
}

  • No labels