Tuesday 26 May 2015

Selendroid element swipe


             WebElement pages1 = driver.findElement(By.xpath (" //TextView[./parent:: ListView [@id='sitesListView']] [5]"));
             TouchActions flick1 = new TouchActions(driver). scroll(pages1, 6, 270);                                 //element, x, y co ordinates
             flick1.perform();
             Thread.sleep(5000);

Monday 25 May 2015

Selendroid Class run


package nativeui;

import io.selendroid.SelendroidDriver;
import io.selendroid.common.SelendroidCapabilities;
import io.selendroid.standalone.SelendroidConfiguration;
import io.selendroid.standalone.SelendroidLauncher;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class MobileAppAutomation {
  private static SelendroidLauncher selendroidServer = null;
  private static WebDriver driver = null;

  @Test
  public void testShouldBeAbleToEnterText() {
    WebElement inputField = driver.findElement(By.id("my_text_field"));
    inputField.sendKeys("Love u mom");
    Assert.assertEquals("Love u mom", inputField.getText());
  }

  @BeforeClass
  public static void startSelendroidServer() throws Exception {
    if (selendroidServer != null) {
      selendroidServer.stopSelendroid();
      System.out.println("Befor Server chaeck and stoped");
    }
    SelendroidConfiguration config = new SelendroidConfiguration();
    config.addSupportedApp("src/resources/selendroid-test-app-0.9.0.apk");
    selendroidServer = new SelendroidLauncher(config);
    selendroidServer.launchSelendroid();

    SelendroidCapabilities caps = new SelendroidCapabilities ("io.selendroid.testapp:0.9.0");

    driver = new SelendroidDriver(caps);
  }

  @AfterClass
  public static void stopSelendroidServer() {
    if (driver != null) {
      driver.quit();
      System.out.println("Driver quited");
    }
    if (selendroidServer != null) {
      selendroidServer.stopSelendroid();
      System.out.println("Server stoped");
    }
  }

}