如何在 iOS 模拟器上启动 appium 测试? [英] How to start appium test on iOS simulator?

查看:44
本文介绍了如何在 iOS 模拟器上启动 appium 测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

问题是:

<块引用>

  1. 这个设置正确吗?
  2. 如何运行测试?

 import java.io.File;导入 java.net.URL;导入 java.util.HashMap;导入 java.util.List;导入 org.openqa.selenium.By;导入 org.openqa.selenium.WebDriver;导入 org.openqa.selenium.WebElement;导入 org.openqa.selenium.remote.CapabilityType;导入 org.openqa.selenium.remote.DesiredCapabilities;导入 org.openqa.selenium.remote.RemoteWebDriver;导入 org.testng.Assert;导入 org.testng.annotations.AfterMethod;导入 org.testng.annotations.BeforeMethod;导入 org.testng.annotations.Test;导入 org.openqa.selenium.WebDriver;导入 org.openqa.selenium.remote.CapabilityType;导入 org.openqa.selenium.remote.DesiredCapabilities;公共类 AppiumDriver {私有静态最终字符串JavascriptExecutor = null;公共 WebDriver 驱动程序 = null;@BeforeMethodpublic void setUp() 抛出异常 {//设置应用程序DesiredCapabilities 能力 = 新的 DesiredCapabilities();capability.setCapability(CapabilityType.BROWSER_NAME, "iOS");capability.setCapability(CapabilityType.VERSION, "8.1");Capability.setCapability(CapabilityType.PLATFORM, "Mac");功能.setCapability(设备",iPhone");capabilities.setCapability("app", "这里的路径,我已经用 appium 检查器启动了它并且它可以工作");driver = new RemoteWebDriver(new URL("http://127.0.0.1:4725/wd/hub"), capabilities);System.out.println("应用启动");}@测试public void test01() 抛出 InterruptedException {driver.findElement(By.name("Guest")).click();线程睡眠(5000);}@AfterMethod公共无效撕裂()抛出异常{驱动程序退出();}}

解决方案

是的,您的设置是正确的.看起来您正在使用 testng 框架,因此只需将其作为testng"运行即可.

I have the following setup and trying to start the test on iOS Simulator. I am a beginner and don't know how to start the test. I have already imported and installed appium from tutorials.

The questions are:

  1. Is this setup correct?
  2. How to run the tests?

    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();
    }

}

解决方案

Yes, your setup is correct. Looks like you are using testng framework so just run it as "testng" and you should be good to go.

这篇关于如何在 iOS 模拟器上启动 appium 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆