Skip to content

Instantly share code, notes, and snippets.

@sauceaaron
Created September 21, 2017 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sauceaaron/675afe80dca3c60b35497de53b7be0e3 to your computer and use it in GitHub Desktop.
Save sauceaaron/675afe80dca3c60b35497de53b7be0e3 to your computer and use it in GitHub Desktop.
Appium Inspector Sample Code
<XCUIElementTypeApplication name="TestApp">
<XCUIElementTypeOther>
<XCUIElementTypeWindow>
<XCUIElementTypeOther>
<XCUIElementTypeTextField name="IntegerA">
<XCUIElementTypeTextField name="IntegerB">
<XCUIElementTypeButton name="ComputeSumButton">
<XCUIElementTypeStaticText name="Answer">
<XCUIElementTypeButton name="show alert">
<XCUIElementTypeButton name="contact alert">
<XCUIElementTypeButton name="location alert">
<XCUIElementTypeStaticText name="AppElem">
<XCUIElementTypeSlider name="AppElem">
<XCUIElementTypeStaticText name="AppElem">
<XCUIElementTypeButton name="DisabledButton">
<XCUIElementTypeStaticText>
<XCUIElementTypeSwitch name="locationStatus">
<XCUIElementTypeButton name="Test Gesture">
<XCUIElementTypeButton name="Crash">
<XCUIElementTypeStaticText name="Access'ibility">
<XCUIElementTypeButton name="Check calendar authorized">
<XCUIElementTypeWindow>
<XCUIElementTypeWindow>
<XCUIElementTypeWindow>
import io.appium.java_client.MobileElement;
import io.appium.java_client.ios.IOSDriver;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
public class SampleTest {
private IOSDriver driver;
@Before
public void setUp() throws MalformedURLException {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("platformName", "iOS");
desiredCapabilities.setCapability("platformVersion", "10.2");
desiredCapabilities.setCapability("deviceName", "iPhone Simulator");
desiredCapabilities.setCapability("deviceOrientation", "portrait");
desiredCapabilities.setCapability("app", "sauce-storage:TestApp-iOS-10.2.zip");
URL remoteUrl = new URL("http://ondemand.saucelabs.com:80/wd/hub");
driver = new IOSDriver(remoteUrl, desiredCapabilities);
}
@Test
public void sampleTest() {
MobileElement el1 = (MobileElement) driver.findElementByAccessibilityId("IntegerA");
el1.sendKeys("1");
MobileElement el2 = (MobileElement) driver.findElementByAccessibilityId("IntegerB");
el2.sendKeys("2");
MobileElement el3 = (MobileElement) driver.findElementByAccessibilityId("ComputeSumButton");
el3.click();
List<MobileElement> els1 = (MobileElement) driver.findElementsById("Answer");
}
@After
public void tearDown() {
driver.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment