Appium Appium 上真机运行 Safari 曲线救国方式

恒温 · 2013年12月22日 · 最后由 王智强 回复于 2018年04月17日 · 2606 次阅读
本帖已被设为精华帖!

http://testerhome.com/topics/309 里, @rockchensir 提到了真机上运行 Safari。 于是花了点时间研究了下。

先看下,模拟器上如何启动 Safari

Automating mobile web apps 里讲的很清楚,

{
  app: 'safari'
  , device: 'iPhone Simulator'
  , version: '7.0'
}

只要配置下 cap 的 app 参数就可以了。当然你要确保 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/Applications/MobileSafari.app 是存在的。

看下 sample code,

package com.saucelabs.appium;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

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

import static org.junit.Assert.*;

/**
 *
 * Simple test which demonstrates how a test can be run against Mobile Safari running on an Appium instance.
 *
 * The test is based on https://github.com/appium/appium/blob/master/sample-code/examples/node/safari.js
 *
 * @author Ross Rowe
 */
public class SafariTest {

    private WebDriver driver;

    /**
     * Instantiates the {@link #driver} instance by using DesiredCapabilities which specify the
     * 'iPhone Simulator' device and 'safari' app.
     * @throws Exception
     */
    @Before
    public void setUp() throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("device", "iPhone Simulator");
        capabilities.setCapability("version", "7.0");
        capabilities.setCapability("app", "safari");
        driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),
                capabilities);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    /**
     * Navigates to http://saucelabs.com/test/guinea-pig and interacts with the browser.
     *
     * @throws Exception
     */
    @Test
    public void runTest() throws Exception {
        driver.get("http://saucelabs.com/test/guinea-pig");
        WebElement idElement = driver.findElement(By.id("i_am_an_id"));
        assertNotNull(idElement);
        assertEquals(idElement.getText(), "I am a div");
        WebElement commentElement = driver.findElement(By.id("comments"));
        assertNotNull(commentElement);
        commentElement.sendKeys("This is an awesome comment");
        WebElement submitElement = driver.findElement(By.id("submit"));
        assertNotNull(submitElement);
        submitElement.click();
        WebElement yourCommentsElement = driver.findElement(By.id("your_comments"));
        assertNotNull(yourCommentsElement);
        assertTrue(driver.findElement(By.id("your_comments")).getText().contains("This is an awesome comment"));

    }

    /**
     * Closes the {@link #driver} instance.
     *
     * @throws Exception
     */
    @After
    public void tearDown() throws Exception {
        driver.quit();
    }
}

像普通的 webdriver 测试一样,亲测可以运行。

在真机上运行 Safari

真机上运行 Safari 就没有那么简单了。

https://github.com/appium/appium/issues/1083 里,snevesbarros 提到:

@PavithraNavaneeth, you have two options:

Use the SafariLauncher which navigates to a URL causing Safari to launch.
It needs to have a 20 - 30 seconds delay after launching the app before it navigates to the link or else Appium ?>thinks the app has crashed.
NOTE: In this case you will have to set the app to be the safari launcher app.

Or if you dont want the 20 seconds delay then you can use the webview app.
The downside of this is that the webview isn't as good as safari at rendering certain elements (e.g. canvas).
NOTE: In this case you will have to set the app value to be the webview app.

For both solutions you will have to run the ios-webkit-debug-proxyand build the app using a profile that allows it >to be installed on your device.

In NO case can you set the app to safari or set the bundle id to com.apple.mobilesafari for a real device. This will not work!

按他说的,你是没有办法直接打开 safari 的, 我估计所有没有开发证书的应用我们都无法直接打开。所以只能曲线救国。一般两种方法:

  • SafariLauncher
  • WebViewApp

最新的 Automating mobile web apps 里面也介绍了如何配置 SafariLauncher 在真机上运行 Safari。大家可以自行阅读。使用 SafariLauncher 我没能成功运行。不知道什么原因。

不过我成功的启动了 WebViewApp, 并通过 WebViewApp 转到网站。看代码。

   //setup the web driver and launch the webview app.
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("device", "iPhone Simulator");
desiredCapabilities.setCapability("app", "http://appium.s3.amazonaws.com/WebViewApp6.0.app.zip");  
URL url = new URL("http://127.0.0.1:4723/wd/hub");
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(url, desiredCapabilities);

//switch to the latest web view
for(String winHandle : remoteWebDriver.getWindowHandles()){
  remoteWebDriver.switchTo().window(winHandle);
}

remoteWebDriver.get("http://saucelabs.com/test/guinea-pig");
//Interact with the elements on the guinea-pig page using id.
WebElement div = remoteWebDriver.findElement(By.id("i_am_an_id"));
Assert.assertEquals("I am a div", div.getText()); //check the text retrieved matches expected value
remoteWebDriver.findElement(By.id("comments")).sendKeys("My comment"); //populate the comments field by id.

//leave the webview to go back to native app.
remoteWebDriver.executeScript("mobile: leaveWebView");      

//close the app.
remoteWebDriver.quit();

这里的 WebViewApp 是直接从网上下载的, 你可以用 appium 下面 sample code 里面的 app 下面的 WebViewApp 来运行。

总的来说 WebView 和 Safari 虽然有些许差异,但大部分还是一致的。不过目前而言, Appium 对 真机 iOS 上的 Safari 支持并不好。其实就像 Webdriver 一样, 驱动 Safari 也得费不少功夫。

另外切记一点,无论是哪种方式,都必须使用 ios-webkit-debug-proxy, 并且要打开真机里面 Safari 的 debug 模式。

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 18 条回复 时间 点赞

hi 你好
非常感谢你的帮助。

我按照你的帖子,在我这台 mac 上运行起来有以下 2 个问题,我都尝试搜索了下。。。实在出于我的英文太烂了,用 google 翻译都是一只半解的,还请帮忙看下这些问题呀。

1.当我在模拟器上 launch safari 的时候,每次都回先打开 apple 的网址,等加载完后,webdriver 就抛出异常了,没有到达我制定的网址。

APPIUM 异常:

info: Welcome to Appium v0.12.3

info: Appium REST http interface listener started on 0.0.0.0:4723
   info  - socket.io started

info: Not spawning instruments force-quit watcher since it only works on 10.9 and you have 10.8.5

info: Responding to client with success: {"status":0,"value":{"build":{"version":"0.12.3","revision":"c8abd030c0cedcc387532f2aa986fd956e46eb4f"}}}

GET /wd/hub/status 200 7ms - 144b

debug: Appium request initiated at /wd/hub/status

debug: Request received with params: {}

debug: Appium request initiated at /wd/hub/session

info: Determining current user

debug: Request received with params: {"desiredCapabilities":{"platform":"iPhone Simulator","app":"safari","version":"7.0"}}

info: User is administrator

error: Could not find support directory for mobile safari, does it exist at Library/Application Support/iPhone Simulator/7.0/Library/ or /Users/administrator/Library/Application Support/iPhone Simulator/7.0/Library/?

info: ENOENT, stat '/Users/administrator/Library/Application Support/iPhone Simulator/7.0/Library'
info: Using local zip or ipa from desiredCaps: ./build/SafariLauncher/SafariLauncherSim.zip
info: Copying local zip to tmp dir

info: ./build/SafariLauncher/SafariLauncherSim.zip copied to /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/appium-app.zip

info: Unzipping /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/appium-app.zip
info: Testing zip archive: /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/appium-app.zip

info: Zip archive tested clean

info: Unzip successful

info: Using locally extracted app: /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/submodules/SafariLauncher/build/Release-iphonesimulator/SafariLauncher.app
info: Creating new appium session 25762106-558d-467e-8652-efdecd8a2f4b

info: Removing any remaining instruments sockets
info: Cleaned up instruments socket /tmp/instruments_sock

warn: Could not parse plist file at /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/submodules/SafariLauncher/build/Release-iphonesimulator/SafariLauncher.app/en.lproj/Localizable.strings

debug: Launching device: iPhone Retina (4-inch)

info: Killing the simulator process

info: Parsed app Info.plist
info: Wrote new app Info.plist with device type
info: Starting iOS 7.* simulator log capture

debug: No device id or app, not installing to real device.

info: Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments

debug: Creating instruments

info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock
info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/submodules/SafariLauncher/build/Release-iphonesimulator/SafariLauncher.app -e UIASCRIPT /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments/
info: And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/Applications/Appium.app/Contents/Resources/node_modules/appium/build/iwd/InstrumentsShim.dylib","LIB_PATH":"/Applications/Appium.app/Contents/Resources/node_modules/appium/build/iwd"}
info: And launch timeout: 90000ms

debug: Appium request initiated at /wd/hub/status

info: Responding to client with success: {"status":0,"value":{"build":{"version":"0.12.3","revision":"c8abd030c0cedcc387532f2aa986fd956e46eb4f"}},"sessionId":"25762106-558d-467e-8652-efdecd8a2f4b"}

debug: Request received with params: {}

GET /wd/hub/status 200 4ms - 199b

info: [INST STDERR] 2013-12-22 08:31:04.631 ScriptAgent[1591:3007] CLTilesManagerClient: initialize, sSharedTilesManagerClient


info: [INST STDERR] 2013-12-22 08:31:04.632 ScriptAgent[1591:3007] CLTilesManagerClient: init

info: [INST STDERR] 2013-12-22 08:31:04.633 ScriptAgent[1591:3007] CLTilesManagerClient: reconnecting, 0xa176510


info: [INSTSERVER] Instruments is ready to receive commands

info: Instruments launched. Starting poll loop for new commands.

info: [INSTSERVER] Socket data received (15 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event

info: Navigating to most recently opened webview

info: [REMOTE] Debugger socket connected to ::1:27753

debug: [REMOTE] Sending _rpc_reportIdentifier: message to remote debugger

info: [REMOTE] Sending connection key
info: [REMOTE] Selecting app
info: Picking webview 1
info: [REMOTE] Selecting page 1 and forwarding socket setup
info: [REMOTE] Set sender key

debug: [REMOTE] { __argument: { WIRConnectionIdentifierKey: 'd06114b4-f048-4d4f-b7a1-a743c38f5184' },
  __selector: '_rpc_reportIdentifier:' }
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] { __selector: '_rpc_reportSetup:',
  __argument: 
   { WIRSimulatorNameKey: 'iPhone Simulator',
     WIRSimulatorProductVersionKey: '7.0.3',
     WIRSimulatorBuildKey: '11B508' } }
debug: [REMOTE] Sim name: iPhone Simulator
debug: [REMOTE] Sim build: 11B508
debug: [REMOTE] { __selector: '_rpc_reportConnectedApplicationList:',
  __argument: 
   { WIRApplicationDictionaryKey: 
      { 'com.apple.mobilesafari': 
         { WIRApplicationIdentifierKey: 'com.apple.mobilesafari',
           WIRApplicationNameKey: 'Safari',
           WIRIsApplicationProxyKey: false } } } }
debug: [REMOTE] Sending _rpc_forwardGetListing: message to remote debugger
debug: [REMOTE] { __argument: 
   { WIRConnectionIdentifierKey: 'd06114b4-f048-4d4f-b7a1-a743c38f5184',
     WIRApplicationIdentifierKey: 'com.apple.mobilesafari' },
  __selector: '_rpc_forwardGetListing:' }
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] { __selector: '_rpc_applicationSentListing:',
  __argument: 
   { WIRApplicationIdentifierKey: 'com.apple.mobilesafari',
     WIRListingKey: 
      { '1': 
         { WIRPageIdentifierKey: 1,
           WIRTitleKey: 'Apple',
           WIRURLKey: 'http://www.apple.com/' } } } }
debug: [REMOTE] Sending _rpc_forwardSocketSetup: message to remote debugger
debug: [REMOTE] { __argument: 
   { WIRApplicationIdentifierKey: 'com.apple.mobilesafari',
     WIRConnectionIdentifierKey: 'd06114b4-f048-4d4f-b7a1-a743c38f5184',
     WIRSenderKey: 'bc8a3a50-d0e6-4c68-bbdc-cbede9cd210e',
     WIRPageIdentifierKey: 1 },
  __selector: '_rpc_forwardSocketSetup:' }
debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] <applicationSentData response>
debug: [REMOTE] Checking document readyState
debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] <applicationSentData response>
debug: [REMOTE] readyState was complete

info: [REMOTE] Enabled activity on page
info: [REMOTE] Sending javascript command
info: Overriding session id with [object Object]
info: Device launched! Ready for commands (will time out in 60secs)
info: Appium session started with sessionId [object Object]
POST /wd/hub/session 303 15334ms - 9b

debug: [REMOTE] Receiving data from remote debugger

info: Remote debugger notified us of a new page listing

debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] { __selector: '_rpc_applicationSentListing:',
  __argument: 
   { WIRApplicationIdentifierKey: 'com.apple.mobilesafari',
     WIRListingKey: 
      { '1': 
         { WIRConnectionIdentifierKey: 'd06114b4-f048-4d4f-b7a1-a743c38f5184',
           WIRURLKey: 'http://www.apple.com/',
           WIRTitleKey: 'Apple',
           WIRPageIdentifierKey: 1 } } } }
debug: [REMOTE] Page loaded, verifying through readyState
debug: [REMOTE] Checking document readyState
debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger

info: [REMOTE] Sending javascript command
info: New page listing is same as old, doing nothing

debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] <applicationSentData response>
debug: [REMOTE] readyState was complete
debug: [REMOTE] Page is ready, calling onload cbs

Code:

public static void callMac() throws MalformedURLException, InterruptedException {
       DesiredCapabilities cap = new DesiredCapabilities();
       WebDriver wd = null;
       cap.setCapability(CapabilityType.VERSION, "7.0");
       cap.setCapability(CapabilityType.PLATFORM, "iPhone Simulator");
       cap.setCapability("app", "safari");///Users/administrator/Documents/WebViewApp.app
       wd = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
       wd.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
       for (String winHandle : wd.getWindowHandles()) {
           wd.switchTo().window(winHandle);
       }
       wd.get("http://www.baidu.com");
       Thread.sleep(10000);
       wd.quit();
   }

   public static void main(String... args) throws MalformedURLException, InterruptedException {
       callMac();
   }

WebDriver exceptions:

run:
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.38.0', revision: 'bd32d4e', time: '2013-12-05 16:16:40'
System info: host: 'administrators-Mac-mini.local', ip: '192.168.1.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.7.0_45'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
    at apptest.iMAC.callMac(iMAC.java:28)
    at apptest.iMAC.main(iMAC.java:39)
Caused by: org.apache.http.client.ClientProtocolException
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:867)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
    at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:319)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:298)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
    ... 5 more
Caused by: org.apache.http.ProtocolException: Invalid redirect URI: http://127.0.0.1:4723/wd/hub/session/[object Object]
    at org.apache.http.impl.client.DefaultRedirectStrategy.createLocationURI(DefaultRedirectStrategy.java:197)
    at org.apache.http.impl.client.DefaultRedirectStrategy.getLocationURI(DefaultRedirectStrategy.java:145)
    at org.apache.http.impl.client.DefaultRedirectStrategy.getRedirect(DefaultRedirectStrategy.java:217)
    at org.apache.http.impl.client.DefaultRequestDirector.handleResponse(DefaultRequestDirector.java:1065)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:514)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
    ... 10 more
Caused by: java.net.URISyntaxException: Illegal character in path at index 37: http://127.0.0.1:4723/wd/hub/session/[object Object]
    at java.net.URI$Parser.fail(URI.java:2829)
    at java.net.URI$Parser.checkChars(URI.java:3002)
    at java.net.URI$Parser.parseHierarchical(URI.java:3086)
    at java.net.URI$Parser.parse(URI.java:3034)
    at java.net.URI.<init>(URI.java:595)
    at org.apache.http.impl.client.DefaultRedirectStrategy.createLocationURI(DefaultRedirectStrategy.java:186)
    ... 15 more
Java Result: 1
BUILD SUCCESSFUL (total time: 16 seconds)

第二个问题:
我尝试配置并且启动 ios_webkit_debug_proxy 的时候曝出以下错误,我试着去找解决办法,找了下面 2 个帮助,我看他们说的 貌似解决了。。但是我没看懂怎么解决的。。我下的也是最新 branch 的 master。
http://www.google.com.hk/url?sa=t&rct=j&q=Invalid+idevice_connection+struct%3F&source=web&cd=1&ved=0CCwQFjAA&url=%68%74%74%70%73%3a%2f%2f%67%69%74%68%75%62%2e%63%6f%6d%2f%67%6f%6f%67%6c%65%2f%69%6f%73%2d%77%65%62%6b%69%74%2d%64%65%62%75%67%2d%70%72%6f%78%79%2f%69%73%73%75%65%73%2f%33%38&ei=7jW2UoPGMOO1iQeX5IDYDQ&usg=AFQjCNESThDmaZ9MwPFpEU9dE3z7UQ5HMw

http://www.google.com.hk/url?sa=t&rct=j&q=Invalid+idevice_connection+struct%3F&source=web&cd=2&ved=0CDQQFjAB&url=%68%74%74%70%73%3a%2f%2f%67%69%74%68%75%62%2e%63%6f%6d%2f%67%6f%6f%67%6c%65%2f%69%6f%73%2d%77%65%62%6b%69%74%2d%64%65%62%75%67%2d%70%72%6f%78%79%2f%62%6c%6f%62%2f%6d%61%73%74%65%72%2f%73%72%63%2f%77%65%62%69%6e%73%70%65%63%74%6f%72%2e%63&ei=7jW2UoPGMOO1iQeX5IDYDQ&usg=AFQjCNEWiMG5ixSr-cbuRN_-3FkIzKDbyw

error:

administrators-Mac-mini:~ administrator$ ios_webkit_debug_proxy
Invalid idevice_connection struct?: Undefined error: 0
Unable to get connection file descriptor.: Undefined error: 0
Unable to attach e999ccef170a38133665c2c1120f471ca90e06ed inspector```

@rockchensir 我用 SafariLauncher 也遇到了这个问题。

第二个问题:
···bash
ios_webkit_debug_proxy -c 45f082689dbaebb0ffa3620b3ae22ad9faff9a30:27753 -d
···
用你自己的 uuid 代替 45f082689dbaebb0ffa3620b3ae22ad9faff9a30,先连接上你的苹果设备。

#2 楼 @lihuazhang 第二个问题 我尝试过使用你说的这种方式,也是一样的错误。。

另外我还有个疑问,如果我想在 android 中测试 native 的程序,比如 mms,phone 等,那我的 app 应该设置为什么?
我当前的设置是
"app","mms"

如果不指定 app-activity 或者 pachage 的话 ,appium 会让你指定,可是我不知道怎么获取 app 的 activity?

MainActivity incorrent.

 cap.setCapability(CapabilityType.BROWSER_NAME, "");
 cap.setCapability(CapabilityType.VERSION, "4.4.2");
 cap.setCapability(CapabilityType.PLATFORM, "MAC");//iPhone Simulator  iPad Device  Selendroid
 cap.setCapability("device","Android");
 cap.setCapability("app", "mms");//app.getAbsolutePath()    chromium ContactManager /Users/administrator/Documents/ContactManager.apk
 //cap.setCapability("launch", "true");
cap.setCapability("app-activity", "MainActivity");//MainActivity   .ContactManager
cap.setCapability("app-package", "com.android.mms");//com.example.android.contactmanager

#2 楼 @lihuazhang 另外 是不是 app-activity 和 app-package 只能向开发获取呀?没有工具可以得到吗?

#4 楼 @rockchensir 我们之前翻译了文档, 你可以先看看翻译的中文文档.

#4 楼 @rockchensir 可以看看 https://github.com/appium/appium/tree/master/docs/cn

app-activity 和 app-package 只能向开发获取,对的。

#5 楼 @seveniruby
#6 楼 @lihuazhang

好的 非常感谢 2 位

WIRPageIdentifierKey: 1,
WIRTitleKey: 'Apple',

WIRURLKey: 'http://www.apple.com/'

说的很清楚了,需要 apple 的 safair 开发者证书,因为苹果对 iphone、imac 和 safair 设定了三种开发证书,除了前面两个是个人每年 99,safair 的开发者证书是免费的,各位要做这个测试去 apple 网站申请一下吧。另外如果是在 windows 上安装 safair 证书和 mac 上是不一样的,前者要增加 p12,不过全部都是 2024 的,很安全。android 上因为 google 开源的关系,能获得 rom 权限,所以在 android 上就不需要这些麻烦的东西了。

2048 的 ssl,写成 2024 了,汗

#6 楼 @lihuazhang WebViewApp 在真机和模拟器中的设置都一样吗?

desiredCapabilities.setCapability("device", "iPhone Simulator");
desiredCapabilities.setCapability("app", "http://appium.s3.amazonaws.com/WebViewApp6.0.app.zip");

WebViewApp 不是事先装好在真机中的吗?是不是启动 Appium 的时候也要设置 UDID。。。
小白刚开始整 ios,例子没跑起来。。。

safari 的 alert 怎么破?

我尝试用楼主的方式在真机上运行,直接弹出 fruitstrap 意外退出的界面,代码中 提示 “ Unable to install WebViewApp.app”,在 appium 的 log 中提示 “Installing app using cmd: /usr/local/lib/node_modules/appium/build/fruitstrap/fruitstrap install .../WebViewApp.app”,但不知道为何 install 失败,望能指教下。

恒温 #13 · 2015年03月13日 Author

#12 楼 @kristina /usr/local/lib/node_modules/appium/build/fruitstrap/fruitstrap install .../WebViewApp.app 你试试看这个命令啊

#13 楼 @lihuazhang 嗯,按照这个命令,果然没法 install 成功,copy 到 70% 失败
VerifyingApplication AMDeviceInstallApplication failed: -402620388
感觉是不是没有开发者账户,可是只有一个 app 文件怎么能加入开发者账户呢?

ps:使用 safariLanucher.app 也是一样的问题。

恒温 #15 · 2015年03月16日 Author

#14 楼 @kristina 你要重新编译这个 webviewapp 啊,用你的真机的开发证书。

#15 楼 @lihuazhang 嗯,😄 不好意思,又问了小白问题。抱歉~

你好,第一个链接已经失效了,我想请问一下启动模拟器上本来就有的 safari,appium 里面的 app path 应该填什么,谢谢

恒温 在 Mac 上配置 Appium 问题收集 中提及了此贴 12月28日 17:29
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册