How to upload Appium tests to StormRunner Functional

Before uploading a Appium test to SRF, ensure that you first define the following in your test:

  • The SRF server and port
  • The SRF client secret ID (app) and secret

Then, upload Appium tests to SRF from the SRF SCRIPTS tab.

Appium code samples for upload
The following code samples use the Advantage Online Shopping demo app. Use these samples as guides when preparing Appium tests for upload.

Appium JavaScript code sample

var wd = require(‘wd’);
var serverURL = process.env.SELENIUM_ADDRESS;
var b = require(‘wd’).promiseChainRemote(serverURL);

wd.configureHttp({
timeout: 60000,
retries: 3,
retryDelay: 100
});

b.on(‘status’, function (info) {
console.log(‘\x1b[36m%s\x1b[0m’, info);
});

b.on(‘command’, function (meth, path) {
console.log(‘ > \x1b[33m%s\x1b[0m: %s’, meth, path);
});

b.on(‘error’, function (meth, path) {
console.error(‘ > \x1b[33m%s\x1b[0m: %s’, meth, path);
});

describe(‘Selenium Test Case’, function () {
it(“should find an element”, function (done) {
console.error(‘before b.init’);
b.init({
SRF_CLIENT_ID: process.env.SRF_CLIENT_ID,
SRF_CLIENT_SECRET: process.env.SRF_CLIENT_SECRET

})
.elementByClassName(“android.widget.Button”)
.click()
.elementById(“up”)
.click()
.quit(() => { done(); })
.catch(err => {
console.error(err);
b.quit(() => { done(err); })
});
});
});

Appium Java code sample


prinimport io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.By;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.TimeUnit;

import java.net.MalformedURLException;
import java.net.URL;

public class remoteSRF {

AndroidDriver wd = null;

public static final String SRF_SERVER = System.getenv(“SELENIUM_ADDRESS”);
public static final String SRF_CLIENT_SECRET = System.getenv(“SRF_CLIENT_SECRET”);

@Before
public void openMobile() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“SRF_CLIENT_SECRET”, SRF_CLIENT_SECRET);
wd = new AndroidDriver(new URL(SRF_SERVER), capabilities);
wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}

@After
public void closeMobile() throws MalformedURLException {
wd.closeApp();
}

@Test
public void login() throws MalformedURLException {
wd.findElement(By.id(“loginButton”)).click();
System.out.println(“Login Completed!”);

WebElement menu = wd.findElement(By.id(“up”));
menu.click(); //Expand menu
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
menu.click(); //Collapse menu
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
menu.click(); //Expand menu again
}
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s