Appium appium-mac-idea-java-ios/android 安装和初期使用记录-直至跑通 (增加真机调试)

gloria · 2017年01月23日 · 最后由 Baozhida 回复于 2017年02月21日 · 2945 次阅读

一.用命令行做了一部分准备工作

  • 1. 爬墙
    因为后续安装过程中可能会碰到墙的问题,所以首先得解决爬墙的问题。

  • 2. Java 环境
    java -version
    Java version "1.8.0_05"
    Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

  • 3. Git 自行搜索安装
    git --version
    git version 1.8.5.2 (Apple Git-48)

  • 4. ruby
    ruby -v
    ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]

  • 5. brew
    brew -v
    Homebrew 0.9.5
    说下 brew 的安装,brew 是 Mac OS 不可或缺的套件管理器
    执行下面命令
    ruby -e"$(curl -fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"

  • 6. node
    有了 brew 安装 node 就方便了
    brew install node

  • 7.后续需要用到 pom,maven 环境需要配好

二.环境准备好后,直接下载的 app dmg

1.首先去 Appium 官网上下载 appium.dmg。官网地址:http://appium.io/downloads.html
2.安装完成后运行监测

3.发现 android home 没配 强迫症要把环境配好

4.下载 android studio 它自己就把安卓 sdk 下载好了

5.找到 sdk 位置 在/etc/profile 中配置 android home

export ANDROID_HOME=/Users/gloria/Library/Android/sdk
export M2_HOME=/Users/gloria/jobs/apache-maven-3.3.9
export PATH=$PATH:$M2_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

6.后再运行检测
提示 xcode 已经安装 但是自己没找到 又下了一个 xcode 4g...( 注意 8x 以上的 xcode, appium1.5.3 不支持 下 7x,踩了个坑)

再运行检测看起来没什么问题了。

三.下载官方 demo 编译

下载 appium 的测试例子:
git clone https://github.com/appium/sample-code

  1. 使用 terminal 命令行形式运行例子

a. 启动 appium;

b. 输入下面的命令编译生成示例程序:

cd sample-code/sample-code/apps/TestApp
xcodebuild -sdk iphonesimulator

c.目录下通过如下命令编译生成示例程序:xcodebuild -sdk iphonesimulator 当看到BUILD SUCCEEDED则说明编译成功。这行命令在 TestApp 项目底下创建了一个 build/Release-iphonesimulator 目录,并且声称一个可以透过 Appium 服务器交流的.app 封装包,该包为 appium gui 中 App Path 的路径。

d.直接执行启动

  • 此处发现报错 不支持 xcode8x 再次下载 7x 后启动成功

四.设置配置

配置如下

🚩 注意地址 型号和版本 错了会起不来报错

设置里修改部分配置

  • *成功 *

出图

上面按钮可定位 recode 可录制(但是录制的脚本基本跑不成 问题还挺多)

-------------此处 appium 的安装启动就完毕了--------------

--------下面是工程时间----------

  • 1.新建自己的测试工程

1.步骤: New Project -- Maven -- 输入 Project name -- Project location -- Next -- Next
2.加入 pom 依赖

<dependencies>
      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.11</version>
          <scope>test</scope>
      </dependency>
      <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-java</artifactId>
          <version>LATEST</version>
          <scope>test</scope>
      </dependency>
      <dependency>
          <groupId>io.appium</groupId>
          <artifactId>java-client</artifactId>
          <version>1.0.2</version>
      </dependency>
      <dependency>
          <groupId>com.googlecode.json-simple</groupId>
          <artifactId>json-simple</artifactId>
          <version>1.1</version>
          <scope>test</scope>
      </dependency>
      <dependency>
          <groupId>commons-lang</groupId>
          <artifactId>commons-lang</artifactId>
          <version>2.6</version>
          <scope>test</scope>
      </dependency>
      <!-- Includes the Sauce JUnit helper libraries -->
      <dependency>
          <groupId>com.saucelabs</groupId>
          <artifactId>sauce_junit</artifactId>
          <version>1.0.18</version>
          <scope>test</scope>
      </dependency>
      <dependency>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
          <version>2.2.4</version>
      </dependency>
  </dependencies>

  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
          </plugin>
          <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                  <source>1.5</source>
                  <target>1.5</target>
              </configuration>
          </plugin>
      </plugins>
  </build>

  <repositories>
      <repository>
          <id>saucelabs-repository</id>
          <url>https://repository-saucelabs.forge.cloudbees.com/release</url>
          <releases>
              <enabled>true</enabled>
          </releases>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
      </repository>
  </repositories>
  • (注意 pom 有两个配置需要修改,先这么配)

配置好 ,建立新的文件 贴进代码

/**
 * Created by gloria on 17/1/22.
 */


import io.appium.java_client.AppiumDriver;


import io.appium.java_client.MobileElement;
import org.openqa.selenium.By;
import org.openqa.selenium.DeviceRotation;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;


import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;

public class apptest1 {
        public static void main(String[] args) throws MalformedURLException {
            WebDriver wd;
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("appium-version", "1.0");
            capabilities.setCapability("platformName", "iOS");
            capabilities.setCapability("platformVersion", "9.3");
            capabilities.setCapability("deviceName", "iPhone 6s Plus");
            capabilities.setCapability("app", "/Users/gloria/jobs/appiumtest/sample-code/sample-code/apps/TestApp/build/release-iphonesimulator/TestApp.app");
            wd = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities) {
                public void rotate(DeviceRotation deviceRotation) {

                }

                public DeviceRotation rotation() {
                    return null;
                }

                public MobileElement scrollTo(String s) {
                    return null;
                }

                public MobileElement scrollToExact(String s) {
                    return null;
                }
            };
            wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
            wd.findElement(By.name("TextField1")).sendKeys("4");
            wd.findElement(By.name("(null)")).sendKeys("5");
            wd.switchTo().alert().accept();
            wd.findElement(By.name("show alert")).click();
            wd.findElement(By.name("(null)")).click();
            wd.findElement(By.name("ComputeSumButton")).click();
            wd.findElement(By.name("locationStatus")).click();
           // wd.shake();
//            wd.findElement(By.name("DisabledButton")).click();
//            (JavascriptExecutor)wd.executeScript("mobile: swipe", new HashMap<String, Double>() {{
//                put("touchCount", (double) 1); put("startX", (double) 125);
//                put("startY", (double) 389); put("endX", (double) 283);
//                put("endY", 390); put("duration", 1.3539453125); }});
            wd.findElement(By.name("show alert")).click();
            wd.findElement(By.name("contact alert")).click();
            wd.close();
        }


}

  • 发现报错 1 版本不一致 修改 pom
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.42.2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>2.2.0</version>
</dependency>

能正常启动模拟器了 但是启动后 还是没有正常跑 testcase

  • 2.再报错

搜搜搜 更新 appium-client 3.2.0 解决

<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>3.2.0</version>
</dependency>

  • 3.然后遇到第三个错误。。。。。。 by.name 报错了 (此处表示无语)

搜了半天 发现是 Appium1.5.0 的问题,于是,到 github 去搜了一下,果然,已经有人提交了 issue

npm install appium on windows not support driver.findElement(By.name("Add Contact"))

by.name 的方法在 1.5.0 中被移除了。。。移除了。。。移除。。了。。除。。了

  • 4.然后改用 xpath 的定位方式 启动报了第四个错 (。。。)

搜搜搜 搜搜搜 增加两行 貌似解决了
capabilities.setCapability("appPackage", "com.company.AppName");
capabilities.setCapability("appActivity", "com.company.AppName.AppMainActivity");

  • 5.然后再跑 果然又有新的错 (啊啊啊啊.........)

此问题报错位置在 wd.close();代码释放的最后一行 (至少到了最后一行)

搜搜搜 搜搜搜 搜不着。。。- -!

  • 再搜搜搜 搜 webdriver api,发现

  • quit() 详细信息: “Quits this driver, closing every associated window”,执行这个方法后,driver 会关闭所有关联窗口

  • close() 详细信息:Close the current window, quitting the browser if it's the last window currently open ,此方法是关闭当前窗口,或最后打开的窗口

  • 1. webDriver.Close() - Close the browser window that the driver has focus of //关闭当前焦点所在的窗口

  • 2. webDriver.Quit() - Calls dispose //调用 dispose 方法

  • 3. webDriver.Dispose() Closes all browser windows and safely ends the session 关闭所有窗口,并且安全关闭 session

  • 猜想因为我代码里弹出了个弹窗,close 可能关闭不了弹窗才报这个错

  • 遂把 close 改成 quit 问题解决

至此 终于一个完整的小 case 可以跑过了。
最终的代码被注释掉大部分。没有打开 但是至少。。。跑通了

代码如下:


/**
 * Created by gloria on 17/1/22.
 */


import io.appium.java_client.AppiumDriver;


import io.appium.java_client.MobileElement;
import org.openqa.selenium.By;
import org.openqa.selenium.DeviceRotation;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;


import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;

public class apptest1 {
        public static void main(String[] args) throws MalformedURLException {
            WebDriver wd;
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("appium-version", "1.0");
            capabilities.setCapability("platformName", "iOS");
            capabilities.setCapability("platformVersion", "9.3");
            capabilities.setCapability("deviceName", "iPhone 6s Plus");
            capabilities.setCapability("appPackage", "com.company.AppName");
            capabilities.setCapability("appActivity", "com.company.AppName.AppMainActivity");
//            capabilities.setCapability("locationServicesAuthorized", true);
//            capabilities.setCapability("waitForAppScript", "$.delay(5000); $.acceptAlert(); true;");
            capabilities.setCapability("app", "/Users/gloria/jobs/appiumtest/sample-code/sample-code/apps/TestApp/build/release-iphonesimulator/TestApp.app");
            wd = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities) {
                public void rotate(DeviceRotation deviceRotation) {

                }

                public DeviceRotation rotation() {
                    return null;
                }

                public MobileElement scrollTo(String s) {
                    return null;
                }

                public MobileElement scrollToExact(String s) {
                    return null;
                }
            };
            wd.findElement(By.xpath("//UIAApplication[1]/UIAWindow[2]/UIAButton[2]\n")).click();

            wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

            wd.quit();
            //wd.findElement(By.xpath("//UIAApplication[1]/UIAWindow[2]/UIAButton[3]\n")).click();

//            wd.findElement(By.name("TextField1")).sendKeys("4");
//            wd.findElement(By.name("(null)")).sendKeys("5");
//            wd.switchTo().alert().accept();
//            wd.findElement(By.name("show alert")).click();
//            wd.findElement(By.name("(null)")).click();
//            wd.findElement(By.name("ComputeSumButton")).click();
//            wd.findElement(By.name("locationStatus")).click();
            //wd.shake();
//            wd.findElement(By.name("DisabledButton")).click();
//            (JavascriptExecutor)wd.executeScript("mobile: swipe", new HashMap<String, Double>() {{
//                put("touchCount", (double) 1); put("startX", (double) 125);
//                put("startY", (double) 389); put("endX", (double) 283);
//                put("endY", 390); put("duration", 1.3539453125); }});
//            wd.findElement(By.name("show alert")).click();
//            wd.findElement(By.name("contact alert")).click();


        }


}

班门弄斧了 写一个 mac+java+idea+iOS 的 能跑通的实践记录。。。。。

后面还请大家多多指导:)

----------------------------------------------实践补充-------------------------------------------------------

  • 设置自动关闭 alerts 的配置如下:
capabilities.setCapability("autoAcceptAlerts",true);
apabilities.setCapability("waitForAppScript", "$.delay(6000); $.acceptAlert(); true;");
  • 遍历整页的元素写法,找不到元素时可用,一点点查
System.out.print(wd.getPageSource());打印全部页面元素
  • swipe 的方式

使用 1.5 版本相比 1.4 swipe 的方式从 ‘xy 起始坐标’ 变成了 ‘xy 起坐标,xy 偏移量’。。。。。(又踩到了坑)
所以滑动的方法需要修改:

传入 driver,during 是滑动时间,num 是次数

左滑代码:(由于是左滑,偏移量为负)


public static void swipeToLeft(AppiumDriver<WebElement> driver, int during, int num) {
    int width = driver.manage().window().getSize().width;
    int height = driver.manage().window().getSize().height;
    System.out.println(width);
    System.out.println(height);
    for (int i = 0; i < num; i++) {
        driver.swipe(width*6/7, height / 2, -(width*4/7), 0, during);
    }


}

滑动代码亲测可用(适用版本 1.5.3)

import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.WebElement;

/**
 * Created by gloria on 17/2/7.
 */
public class SwipUtils {

    /**
     * 向左滑动
     *
     * @param driver
     * @param during
     * @param num
     */
    public static void swipeToLeft(AppiumDriver<WebElement> driver, int during, int num) {
        int width = driver.manage().window().getSize().width;
        int height = driver.manage().window().getSize().height;
        System.out.println(width);
        System.out.println(height);
        for (int i = 0; i < num; i++) {
            driver.swipe(width*6/7, height / 2, -(width*4/7), 0, during);
        }

    }


    /**
     * 上滑
     *
     * @param driver
     * @param during
     * @param num
     */
    public static void swipeToUp(AppiumDriver<WebElement> driver,int during, int num) {
        int width = driver.manage().window().getSize().width;
        int height = driver.manage().window().getSize().height;
        for (int i = 0; i < num; i++) {
            driver.swipe(width / 2, height * 3 / 4, 0, -(height*2/ 4), during);

        }
    }

    /**
     * 下拉
     *
     * @param driver
     * @param during
     * @param num
     */
    public static void swipeToDown(AppiumDriver<WebElement> driver,int during, int num) {
        int width = driver.manage().window().getSize().width;
        int height = driver.manage().window().getSize().height;
        System.out.println(width);
        System.out.println(height);
        for (int i = 0; i < num; i++) {
            driver.swipe(width / 2, height / 4, 0, height * 3 / 4, during);

        }
    }


    /**
     * 向右滑动
     *
     * @param driver
     * @param during
     * @param num
     */
    public static void swipeToRight(AppiumDriver<WebElement> driver,int during, int num) {
        int width = driver.manage().window().getSize().width;
        int height = driver.manage().window().getSize().height;
        for (int i = 0; i < num; i++) {
            driver.swipe(width / 4, height / 2, width * 3 / 4, 0 , during);

        }
    }
}

###
###
###
###

----------------------------------------------真机调试---------------------------------------------------

  • 先说下 appium 要想用真机调试的 前置条件:

  • 1.在真机上跑 APPIUM 的前提是,手机应该注册成开发者手机,这样就可以在 Settings 的页面看到 Developer(开发者) 这个选项了。(拜托你的开发给你加入)

developer 选项里的 Enable UI Automation 开启,不然会报错:

selenium.common.exceptions.WebDriverException: Message: u'A new session could not be created. (Original error: Instruments crashed on startup)'

(这个错误 可能还和 app 签名有关 ,如果换手机:只要把用这个手机的签名重新编译一个 APP,就可以了。)

  • 2.装的 必须是 debug 包

  • 3.需要有 BundleID 找开发要

  • 4.UDID :手机的 id 可以用 itunes 看,当然 xcode 也是可以看的

  • 5.mac 能监听到手机的 app 包 :

ideviceinstaller -l

显示如下:

‘空的’

很可能 你的 ideviceinstaller 版本太低 或者 没有 ,会报错找不到 这个 ideviceinstaller
删除老的并下载最新的 :

brew uninstall ideviceinstaller

brew install ideviceinstaller

就 OK 了

  • 然后这时候 还可能监听不到:ideviceinstaller Could not connect to lockdownd. Exiting.

appium 会报的错误为: 安装 app 失败 大概就是: install xxx app faile

这时候 运行:sudo chmod 777 /var/db/lockdown/

再次执行 ideviceinstaller -l

出现你机器上的 app 包显示,就 ok 了

  • 6.修改配置

如果手机上有预装 不需要填写 app path 地址

启动后点击 Inspector 如果 Inspector 不能启动 脚本也会报错。

----------------------------------------------Android 真机调试---------------------------------------------------
步骤 见 https://testerhome.com/topics/153

下载了一个 demo 配置设置如下

这里 device name 直接使用 add devices 出来的结果就可以

----------------------------------------------android 的滑屏---------------------------------------------------

实验证明 android 的滑屏和 ios 不一样,android 仍然使用起止点的方式定义 swipe 方法,使用安卓时需要换 swipe 方式。
坑真多啊 摊手



/**
 * 向左滑动 安卓
 *
 * @param driver
 * @param during
 * @param num
 */
public static void swipeToLeftAndroid(AppiumDriver<WebElement> driver, int during, int num) {
    int width = driver.manage().window().getSize().width;
    int height = driver.manage().window().getSize().height;
    System.out.println(width);
    System.out.println(height);
    for (int i = 0; i < num; i++) {
        driver.swipe(width*6/7, height/2, width*1/7, height/2, during);
    }

}

  • 安卓的关闭键盘写法

((AppiumDriver<WebElement>) wd).hideKeyboard();

共收到 38 条回复 时间 点赞

好好排版下,文章更漂亮

#1 楼 @Lihuazhang 强迫症表示已排完

capabilities.setCapability("app", "/Users/gloria/jobs/appiumtest/sample-code/sample-code/apps/TestApp/build/release-iphonesimulator/TestApp.app");

楼主请问一下实际项目中这里是不是可以直接找开发要编译过的在 Release-iphonesimulator 这个文件夹下的.app 文件就行啊?是否必须有完整的项目工程呢?比如路径我就填 download 下可以吗

#4 楼 @yefnegjun 可以 没问题 实际项目里直接用开发编译出来的模拟器版的 app 包就可以 如果是真机包模拟器的话可能会起不来

#5 楼 @gloria0610 感谢!我去试试~

#5 楼 @gloria0610 hi 楼主 还有个问题请教下

capabilities.setCapability("appPackage", "com.company.AppName");
capabilities.setCapability("appActivity", "com.company.AppName.AppMainActivity");

app 的包和 activity 是怎么查到的呢?这个不是安卓的才需要设置这两个吗?

#7 楼 @yefnegjun 这个是我搜到的- - 直接贴进去了 xpath 报错就解决了。。原因我也不清楚

这边的脚本应该是 js 的吧,有没有 python 的脚本

gloria #10 · 2017年02月07日 Author

#9 楼 @xlth1947 是 java 的 抱歉 python 没有 不过脚本都大同小异 找一个例子把内容稍做改动就可以

谢谢,我现在找不到关于 python 的脚本 demo,只能参照其他语言的先看看自己改改!

swipe 无法滑动,appium 1.5.3

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
System.out.println(width);
System.out.println(height);
System.out.println(width * 6/7);
System.out.println(-(width * 4/7));
int a = -(width * 4/7);
for (int i = 0; i < 3; i++) {
driver.swipe(width * 6/7, height / 2, -(width * 4/7), 0, 2000);
Thread.sleep(2000);
}

gloria #15 · 2017年02月07日 Author

#13 楼 @wangqingbinSunday 我设置的 during 是 500 num 是 1,跑了观察一下是压根没滑还是有滑动的动作 没过去

#15 楼 @gloria0610
改成这个之后滑过去了
driver.swipe(width * 6/7, height / 2, width * 2/7, 0, 1000);
pad 横屏 向左滑动 没有问题了

gloria #18 · 2017年02月08日 Author

#17 楼 @wangqingbinSunday 看起来是版本不一样 这个应该是起始坐标的方式

@gloria0610 有尝试过 appium1.6.3 吗?请问你是怎么进行元素抓取的,我的 WDA,http://localhost:8100/inspector一直没办法显示,请问你有遇见过吗?

gloria #20 · 2017年02月10日 Author

#19 楼 @xlth1947 用 xpath 链接不显示是正常的 不用理他 你点的是 appium 上的放大镜 inspector 吗

gloria #21 · 2017年02月10日 Author

#19 楼 @xlth1947 遍历整页的元素写法,找不到元素时可用,一点点查
System.out.print(wd.getPageSource());打印全部页面元素
但是一般的 inspector 会显示定位工具 你放大镜会报错吗 如果会的话还是环境问题

不是,1.6.3 没有客户端,所以都是在终端里命令行里搞的

@gloria0610 我这边一直在终端里跑 appium,应用跑起来后,我想在 inspector 里抓取元素,但是 inspector 一致打不开,我这边不知道怎么抓元素了。。。。WDA 的http://localhost:8100/inspectorstatus 显示的是 32,现在一点头绪都没有,在看 WDA 的官方文件。还有其他方式去查看 ios 的元素吗?你的遍历是在脚本里输出是吗?显示是各种乱码,返回

gloria #24 · 2017年02月10日 Author

#23 楼 @xlth1947 一直打不开看一下 log 个人感觉是报错了才会打不开 inspector 打不开 脚本应该也执行不了。。。 getPageSource() 这个方法是遍历页面元素 会打印出 xml 乱码的话考虑编码格式的问题

wd = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities) {
                public void rotate(DeviceRotation deviceRotation) {

                }

                public DeviceRotation rotation() {
                    return null;
                }

                public MobileElement scrollTo(String s) {
                    return null;
                }

                public MobileElement scrollToExact(String s) {
                    return null;
                }
            };


System.out.print(wd.getPageSource());

用法是这样

gloria #25 · 2017年02月10日 Author

#23 楼 @xlth1947 你 python 脚本需要换写法~

@gloria0610 换写法?我现在是这样的
from appium import webdriver
import os
from time import sleep

success = True
desired_caps = {}
desired_caps['automationName'] = 'XCUITest'
desired_caps['appiumversion'] = '1.6.3'
desired_caps['platformName'] = 'iOS'
desired_caps['platformVersion'] = '10.1.1'
desired_caps['deviceName'] = 'iPhone 6'
desired_caps['app'] = os.path.abspath('app 路径')

wd = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)

sleep(1000)
就是说要将 wd 这边改掉?

我这边用http://192.168.20.184:8100/inspector查看元素,显示的是这样的
{
"value" : "Invalid parameter not satisfying: path\n\n(\n\t0 CoreFoundation 0x00000001838b6dc8 + 148\n\t1 libobjc.A.dylib 0x0000000182f1bf80 objc_exception_throw + 56\n\t2 CoreFoundation 0x00000001838b6c80 + 0\n\t3 Foundation 0x000000018423c154 + 112\n\t4 WebDriverAgentLib 0x000000010686715c -[FBResponseFilePayload initWithFilePath:] + 284\n\t5 WebDriverAgentLib 0x0000000106862470 FBResponseFileWithPath + 84\n\t6 WebDriverAgentLib 0x00000001068743c0 __29+[FBInspectorCommands routes]_block_invoke + 100\n\t7 WebDriverAgentLib 0x0000000106862790 -[FBRoute_Sync mountRequest:intoResponse:] + 168\n\t8 WebDriverAgentLib 0x0000000106859598 __37-[FBWebServer registerRouteHandlers:]_block_invoke + 496\n\t9 RoutingHTTPServer 0x000000010691e3cc -[RoutingHTTPServer handleRoute:withRequest:response:] + 144\n\t10 RoutingHTTPServer 0x000000010691eb80 __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 44\n\t11 libdispatch.dylib 0x000000018330147c + 16\n\t12 libdispatch.dylib 0x0000000183310ae8 + 644\n\t13 libdispatch.dylib 0x000000018330147c + 16\n\t14 libdispatch.dylib 0x0000000183306b84 _dispatch_main_queue_callback_4CF + 1844\n\t15 CoreFoundation 0x000000018386cd50 + 12\n\t16 CoreFoundation 0x000000018386abb8 + 1628\n\t17 CoreFoundation 0x0000000183794c50 CFRunLoopRunSpecific + 384\n\t18 Foundation 0x00000001841a4cfc + 308\n\t19 Foundation 0x00000001841fa030 + 88\n\t20 WebDriverAgentLib 0x00000001068585f0 -[FBWebServer startServing] + 320\n\t21 WebDriverAgentRunner 0x00000001021cbed0 -[UITestingUITests testRunner] + 120\n\t22 CoreFoundation 0x00000001838bca60 + 144\n\t23 CoreFoundation 0x00000001837b4488 + 284\n\t24 XCTest 0x00000001000de0a8 __24-[XCTestCase invokeTest]_block_invoke_2 + 388\n\t25 XCTest 0x0000000100112c98 -[XCTestContext performInScope:] + 208\n\t26 XCTest 0x00000001000ddf0c -[XCTestCase invokeTest] + 268\n\t27 XCTest 0x00000001000de5e0 -[XCTestCase performTest:] + 460\n\t28 XCTest 0x00000001000dba5c -[XCTestSuite performTest:] + 428\n\t29 XCTest 0x00000001000dba5c -[XCTestSuite performTest:] + 428\n\t30 XCTest 0x00000001000dba5c -[XCTestSuite performTest:] + 428\n\t31 XCTest 0x00000001000c7740 __25-[XCTestDriver _runSuite]_block_invoke + 56\n\t32 XCTest 0x00000001000e8260 -[XCTestObservationCenter _observeTestExecutionForBlock:] + 528\n\t33 XCTest 0x00000001000c75d8 -[XCTestDriver _runSuite] + 460\n\t34 XCTest 0x00000001000c83b4 -[XCTestDriver _checkForTestManager] + 296\n\t35 XCTest 0x0000000100114164 _XCTestMain + 628\n\t36 CoreFoundation 0x000000018386cf84 + 20\n\t37 CoreFoundation 0x000000018386c8bc + 308\n\t38 CoreFoundation 0x000000018386a820 + 708\n\t39 CoreFoundation 0x0000000183794c50 CFRunLoopRunSpecific + 384\n\t40 GraphicsServices 0x000000018507c088 GSEventRunModal + 180\n\t41 UIKit 0x0000000188a82088 UIApplicationMain + 204\n\t42 XCTRunner 0x000000010009c3d4 XCTRunner + 33748\n\t43 libdyld.dylib 0x00000001833328b8 + 4\n)",
"sessionId" : "E58B89D4-3FBF-41EB-9272-A8CC825EA851",
"status" : 13
}

@gloria0610 你有遇到过这种情况吗?完全不看不懂。。。。

@gloria0610 我这边 WDAinspector 打开时,WDA 会报这样的错误

@gloria0610 hi 楼主 又来请教问题了。这两天写了一些脚本 。但是在运行自动化的时候发现最后 driver.quite();结束本次用例以后,运行下一个用例的时候打开被测 app 会直接到上个用例结束时的那个界面。你碰到过这种问题吗?
比如说我一个应用在登录界面输入账号密码登陆,弹出选择登录平台的窗口。到这里这个用例就结束了。退出运行下一个用例的时候新打开的界面会直接到选择平台等窗口,我想在新打开应用的时候是最初的输入账号密码的界面。这种情况怎么办呢

gloria #31 · 2017年02月13日 Author

#30 楼 @yefnegjun 试一下 webDriver.Dispose(); 或者把初始化的代码提出来 写 setup 试一下
中间这个方法说明看一下
quit() 详细信息: “Quits this driver, closing every associated window”,执行这个方法后,driver 会关闭所有关联窗口
close() 详细信息:Close the current window, quitting the browser if it's the last window currently open ,此方法是关闭当前窗口,或最后打开的窗口

  1. webDriver.Close() - Close the browser window that the driver has focus of //关闭当前焦点所在的窗口
  2. webDriver.Quit() - Calls dispose //调用 dispose 方法
  3. webDriver.Dispose() Closes all browser windows and safely ends the session 关闭所有窗口,并且安全关闭 session
32楼 已删除

楼主,按照楼主的步骤输入 ideviceinstaller -l 仍然会报 Could not connect to lockdownd. Exiting.请楼主指教

gloria #34 · 2017年02月20日 Author

#33 楼 @xiaoyu_li 开发者和 developer 选项里的 Enable UI Automation 开过么 重开终端试一下

都开着呢,重开终端也不行😭

楼主,可以加个好友帮我看一下吗 qq 3353817467

gloria #37 · 2017年02月20日 Author

#35 楼 @xiaoyu_li 这地方我印象里也卡了一小下 好像还重启过。。。后来就好了 步骤就是这几个。。。你注意下你的线是不是不能传输数据只能充电的。。。这也很重要。。😳

莫等闲 mac 上安装 appium 遇到困惑求解答 中提及了此贴 02月21日 09:56

lz 还有一个新的问题,现在我输入 ideviceinstaller -l 报如下错
Could not start com.apple.mobile.installation_proxy!
是什么问题

Appium 已经集成了 WebDriverAgent,怎么还需要真机加入开发者,还需要 Debug 包?
WDA 已经可以测试任意 app,直接 AppStore 下载的也 OK

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册