如何在iOS模拟器上启动appium测试?

2023-12-22

我有以下设置并尝试开始测试iOS Simulator。我是初学者,不知道如何开始测试。我已经导入并安装了appium来自教程。

问题是:

  1. 这个设置正确吗?
  2. 如何运行测试?
    import java.io.File;
    import java.net.URL;
    import java.util.HashMap;
    import java.util.List;


    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.remote.CapabilityType;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.testng.Assert;
    import org.testng.annotations.AfterMethod;
    import org.testng.annotations.BeforeMethod;
    import org.testng.annotations.Test;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.remote.CapabilityType;
    import org.openqa.selenium.remote.DesiredCapabilities;

    public class AppiumDriver {

    private static final String JavascriptExecutor = null;
    public WebDriver driver = null;

    @BeforeMethod
    public void setUp() throws Exception {
    // set up appium
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "iOS");
    capabilities.setCapability(CapabilityType.VERSION, "8.1");
    capabilities.setCapability(CapabilityType.PLATFORM, "Mac");
    capabilities.setCapability("device", "iPhone");
    capabilities.setCapability("app", "path here, i have started it with appium inspector and it works");
    driver = new RemoteWebDriver(new URL("http://127.0.0.1:4725/wd/hub"), capabilities);

    System.out.println("App launched");
    }

    @Test
    public void test01() throws InterruptedException {
        driver.findElement(By.name("Guest")).click();
        Thread.sleep(5000);

     }

    @AfterMethod
    public void tearDown() throws Exception {
    driver.quit();
    }

}

是的,您的设置是正确的。看起来您正在使用 testng 框架,因此只需将其作为“testng”运行就可以了。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在iOS模拟器上启动appium测试? 的相关文章

随机推荐