使用Appium在真实设备上自动化Mobile Safari并遇到未捕获的异常

时间:2014-02-06 15:32:44

标签: java ios selenium junit appium

使用最新的appium版本与我完全配置的iOS 7设备进行通信。

我可以让Webdriver构建并与我的appium服务器通信。

我可以让SafariLauncher从xcode构建并在我的设备上运行。

但是当我尝试使用我的java代码来使用appium服务器来调用SafariLauncher并在我的设备上运行它时,我得到以下“uncaughtException”

我尝试过让appium使用自己版本的SafariLauncher,但我得到了一个略有不同但却没有阻塞的错误,指出“无法创建新会话”。将所需的功能切换到我自己的本地构建的SafariLauncher.app版本后,我收到了新的“uncaughtException”错误。


*info: Welcome to Appium v0.14.2
info: Appium REST http interface listener started on 0.0.0.0:3001
   info  - socket.io started
info: Spawning instruments force-quitting watcher process
info: [FQInstruments] Force quit unresponsive instruments v0.0.1
info: Responding to client with success: {"status":0,"value":{"build":{"version":"0.14.2","revision":"113e796b850b28e7066fe472faf8554b73b6299d"}}}
debug: Appium request initiated at /wd/hub/status
GET /wd/hub/status 200 8ms - 144b
debug: Request received with params: {}
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"desiredCapabilities":{"app":"/Users/accesso/Library/Developer/Xcode/DerivedData/SafariLauncher-cquscfvgyludjdaolkpikgbmowez/Build/Products/Debug-iphoneos/SafariLauncher.app","device":"iphone"}}
info: Using local app from desiredCaps: /Users/accesso/Library/Developer/Xcode/DerivedData/SafariLauncher-cquscfvgyludjdaolkpikgbmowez/Build/Products/Debug-iphoneos/SafariLauncher.app
info: Creating new appium session a84fee15-6d72-41d2-8ebb-4c8860455c2a
info: Removing any remaining instruments sockets
info: Cleaned up instruments socket /tmp/instruments_sock
warn: Could not parse plist file at /Users/accesso/Library/Developer/Xcode/DerivedData/SafariLauncher-cquscfvgyludjdaolkpikgbmowez/Build/Products/Debug-iphoneos/SafariLauncher.app/en.lproj/Localizable.strings
info: Not setting locale because we're using a real device
info: Not setting iOS and app preferences since we're on a real device
info: Starting iOS device log capture via idevicesyslog
info: Not setting device type since we're connected to a device
error: uncaughtException: undefined date=Thu Feb 06 2014 10:17:25 GMT-0500 (EST), pid=3350, uid=501, gid=20, cwd=/Applications/Appium.app/Contents/Resources/node_modules/appium, execPath=/Applications/Appium.app/Contents/Resources/node/bin/node, version=v0.10.17, argv=[/Applications/Appium.app/Contents/Resources/node/bin/node, /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/main.js, --port, 3001, --app, /, --udid, 7cc3dc5cc930406e9ce0e9f721a8e21b1eadfebc, --session-override, --keep-artifacts], rss=46399488, heapTotal=34235136, heapUsed=17620112, loadavg=[1.60546875, 1.29833984375, 1.205078125], uptime=84958, trace=[], stack=undefined*

这是我正在尝试运行的脚本 -

import static org.junit.Assume.assumeTrue;



import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class test {


    WebDriver driver;


  private static boolean isSupportedPlatform() {
    Platform current = Platform.getCurrent();
    return Platform.MAC.is(current) || Platform.WINDOWS.is(current);

  }

  @Before

  synchronized public void createDriver() {
    assumeTrue(isSupportedPlatform());

    try {
        //setup the web driver and launch the webview app.
        DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
        desiredCapabilities.setCapability("app", "/Users/accesso/Library/Developer/Xcode/DerivedData/SafariLauncher-cquscfvgyludjdaolkpikgbmowez/Build/Products/Debug-iphoneos/SafariLauncher.app");
        desiredCapabilities.setCapability("device", "iphone");
        URL url = new URL("http://0.0.0.0:3001/wd/hub");
        driver = new RemoteWebDriver(url, desiredCapabilities);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

  }

  @After
  public void quitDriver() {
    driver.quit();
  }

  @Test
  public void shouldBeAbleToPerformAGoogleSearch() {
    driver.get("http://store.accesso.com/CF-KBF");

  }
}

1 个答案:

答案 0 :(得分:0)

试用Appium最新的15版本。

我遇到了同样的问题“错误:uncaughtException:undefined date”更新Appium版解决了它。

我正在使用MAC mini和IPAD与APPIUM。

相关问题