How to convert XLT scripts into Selenium?


#1

How can i convert XLT scripts into selenium ?
OR
Can I use this XLT code in test automation with Saucelabs ?

I am using the Saucelabs account for automating browsers.
Since XLT scripts exported in java, cannot be used to Saucelabs, can i convert XLT into Selenium, so that i can run it under Saucelabs.

Is there any quick way to convert xlt into selenium ?

For eg:-
XLT Scripts under AbstractWebDriverScriptTestCase subclass

     startAction("TcheckMenuItem_0");
     clickAndWait("//nav[@id='navigation']/ul[1]/li[4]/div/ul/li[1]/a");

How to convert this into selenium so that i can access like

     driver.click("//nav[@id='navigation']/ul[1]/li[4]/div/ul/li[1]/a");

#2

Scripts exported to Java test cases do not obey the @TestTargets annotation provided by the Multi-Browser extension, however, that does not mean you are not able to execute these tests using SauceLabs.

In the constructor of your exported test case you simply need to pass a properly configured instance of RemoteWebDriver. In the example below, we would run the test with an iphone7 simulator:

public class TAddToCart extends AbstractWebDriverScriptTestCase
{
    public TAddToCart() throws MalformedURLException
    {
        super(createSauceLabsDriver(), "");
    }

    private static WebDriver createSauceLabsDriver() throws MalformedURLException
    {
        String USERNAME = "YOUR_USERNAME";
        String ACCESS_KEY = "YOUR_ACCESS_KEY";
        String URL = "https://" + USERNAME + ":" + ACCESS_KEY + "@ondemand.saucelabs.com:443/wd/hub";
        
        DesiredCapabilities caps = DesiredCapabilities.iphone();
        caps.setCapability("appiumVersion", "1.7.1");
        caps.setCapability("deviceName","iPhone 7 Simulator");
        caps.setCapability("deviceOrientation", "portrait");
        caps.setCapability("platformVersion","11.0");
        caps.setCapability("platformName", "iOS");
        caps.setCapability("browserName", "Safari");

        return new RemoteWebDriver(new URL(URL), caps);
    }
    
    ...
}

#3

Thanks J,
it worked …

But how to pass multiple browsers as params so that i could test my scripts in different environment ?