Package com.appium.cases;
Import Org.openqa.selenium.By;
Import org.openqa.selenium.remote.DesiredCapabilities;
Import Org.testng.annotations.AfterClass;
Import Org.testng.annotations.BeforeClass;
Import Org.testng.annotations.Test;
Import Io.appium.java_client.ios.IOSDriver;
Import io.appium.java_client.ios.IOSElement;
Import Io.appium.java_client.remote.IOSMobileCapabilityType;
Import Io.appium.java_client.remote.MobileCapabilityType;
Import Java.io.File;
Import Java.net.URL;
public class Iosdeijtong {
Iosdriver<ioselement> driver;
Command line Startup
@BeforeClass
public void SetUp () throws Exception {
File Appdir = new file (System.getproperty ("User.dir"));
Final file App = new file (appdir, "/app/toon.ipa");
Desiredcapabilities capabilities = new Desiredcapabilities ();
Capabilities.setcapability ("PlatformName", "IOS"); Mobile OS
Capabilities.setcapability ("Platformversion", "11.0.3"); The phone OS version to start
Capabilities.setcapability ("DeviceName", "IPHONEXQ"); Phone type or simulator type, such as Mi_2a/android Emulator/iphone Simulator
Capabilities.setcapability ("Udid", "0259411d3508a459149c8aec521ff5845a2e835b"); Physical Machine ID//using MAC platform a779c7953c50967fca89500e932981029e306659
Capabilities.setcapability ("Usenewwda", false); False
Capabilities.setcapability (Mobilecapabilitytype.automation_name, "xcuitest");
Capabilities.setcapability (mobilecapabilitytype.new_command_timeout, 3600);
Capabilities.setcapability (Iosmobilecapabilitytype.auto_accept_alerts, true); All iOS reminders appear selected to accept
Capabilities.setcapability ("Bundleid", "Com.systoon.beijingtong");
Capabilities.setcapability ("App", App.getabsolutepath ()); Get the App absolute path (a path under engineering if the installation is enabled, without booting if not installed)
Driver = new Iosdriver (New URL ("Http://127.0.0.1:4723/wd/hub"), capabilities);
}
@Test
public void Allinlogin () throws Interruptedexception {//Login
/** Allow */
Thread.Sleep (5000);
//system.out.println (Driver.getpagesource ()); Get element
//driver.findelement (By.name ("Allow")). Click ();
//login user name Xcuielementtypetextfield
driver.findelementbyname ("Please enter your mobile phone number"). Clear ();
driver.findelementbyname ("Please enter your mobile phone number"). SendKeys ("14725000001");
//password
driver.findelementbyname ("Please enter your password"). SendKeys ("1111");
//Login
driver.findelementbyname ("Login"). Click ();
Thread.Sleep (5000);
System.out.println ("This is the post-login page");
System.out.println (Driver.getpagesource ()); Get element
Final webelement Text = river.findelement (By.xpath ("//uiatextfield[1]");
}
@AfterClass
public void TearDown () throws Exception {
Driver.quit ();
}
}
Appium-ios Start Deome