使用Appium

时间:2016-11-24 05:38:44

标签: java ios session appium

以下版本的系统配置 -

Mac OS - 10.12 Xcode - 8.0 Appium - 1.5.3

以下是试图运行的脚本: -

public class testclass {

    public static AppiumDriver<WebElement> driver;

    public static void main(String[] args) throws MalformedURLException {
        // TODO Auto-generated method stub
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "8.1");
        capabilities.setCapability("deviceName", "iphone 6" );
        capabilities.setCapability("app", "settings");
        driver = new IOSDriver<WebElement>(new URL ("http://0.0.0.0:4723/wd/hub"), capabilities);
        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
        driver.close();

    }

}  

错误为异常 -

  

线程“main”中的异常   org.openqa.selenium.SessionNotCreatedException:无法创建新的   远程会话。期望的能力=能力[{app = settings,   platformVersion = 8.1,platformName = iOS,deviceName = iphone 6}],必需   capabilities = Capabilities [{}]构建信息:版本:'未知',   修订版:'1969d75',时间:'2016-10-18 09:43:45 -0700'系统信息:   主持人:'INCDSZPC02604.local',ip:'3.209.248.73',os.name:'Mac OS X',   os.arch:'x86_64',os.version:'10 .12.1',java.version:'1.8.0_112'   驱动程序信息:driver.version:IOSDriver at   org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)     在   org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)     在   io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:69)     在   org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)     在   io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)     at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)     在io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)at   org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)     在   org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:128)     在   org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:141)     在   io.appium.java_client.DefaultGenericMobileDriver。(DefaultGenericMobileDriver.java:36)     在io.appium.java_client.AppiumDriver。(AppiumDriver.java:114)     在io.appium.java_client.AppiumDriver。(AppiumDriver.java:132)     在io.appium.java_client.ios.IOSDriver。(IOSDriver.java:82)at   MobileDemo.testclass.main(testclass.java:22)

1 个答案:

答案 0 :(得分:0)

您可以尝试将服务器的端口号更改为5555之类的其他内容 并在代码中更新它

driver = new IOSDriver<WebElement>(new URL ("http://0.0.0.0:5555/wd/hub"), capabilities);