Java tutorial
package com.nike.tests; /* * Copyright 2012-2014 eBay Software Foundation and selendroid committers. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import io.selendroid.client.SelendroidDriver; import io.selendroid.client.TouchAction; import io.selendroid.client.TouchActionBuilder; import io.selendroid.common.SelendroidCapabilities; import io.selendroid.standalone.SelendroidConfiguration; import io.selendroid.standalone.SelendroidLauncher; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.touch.TouchActions; import org.openqa.selenium.remote.DesiredCapabilities; public class MobileWebTest { private SelendroidLauncher selendroidServer = null; private WebDriver driver = null; @Test public void shouldSearchWithEbay() { // And now use this to visit ebay driver.get("http://m.ebay.de"); System.out.println("starting flick"); //WebElement pages = driver.findElement(By.id("vp_pages")); TouchActions flick = new TouchActions(driver).flick(100, 860); flick.perform(); TouchActions swipe = new TouchActions(driver).scroll(-200, 860); swipe.perform(); TouchAction ta = (new TouchActionBuilder()).pointerDown(200, 860).pointerMove(100, 10).pointerUp().build(); ta.perform(driver); System.out.println("done"); // Find the text input element by its id WebElement element = driver.findElement(By.id("kw")); // Enter something to search for element.sendKeys("Nexus 5"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Check the title of the page System.out.println("Page title is: " + driver.getTitle()); driver.quit(); } @Before public void startSelendroidServer() throws Exception { if (selendroidServer != null) { selendroidServer.stopSelendroid(); } SelendroidConfiguration config = new SelendroidConfiguration(); selendroidServer = new SelendroidLauncher(config); selendroidServer.launchSelendroid(); DesiredCapabilities caps = SelendroidCapabilities.android(); driver = new SelendroidDriver(caps); } @After public void stopSelendroidServer() { if (driver != null) { driver.quit(); } if (selendroidServer != null) { selendroidServer.stopSelendroid(); } } }