【问题标题】:Facing exception while automating iOS app using appium使用 appium 自动化 iOS 应用程序时遇到异常
【发布时间】:2014-08-22 19:58:32
【问题描述】:

我要运行的脚本是:

package shivaniios;

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.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class MyFirstClass
{
    public static void main(String[] args) throws MalformedURLException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("appium-version", "1.2");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "7.1");
        capabilities.setCapability("deviceName", "iPhone");
        capabilities.setCapability("app", "/Users/admin/Downloads/Wynk.app");
        WebDriver wd = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),       capabilities);
        wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

        //Click on continue button
        WebElement button_Continue = wd.findElement(By.name("Continue"));
        button_Continue.click();

        //Click on skip button
        WebElement button_Skip = wd.findElement(By.name("Skip"));
        button_Skip.click();

        //Click on Skip Tour button
        WebElement button_Skiptour = wd.findElement(By.name("Skip Tour"));
        button_Skiptour.click();

        //Click on Close Tip button
        WebElement button_Closetip = wd.findElement(By.name("Close Tip"));
        button_Closetip.click();

        //Click on Player button
        //WebElement button_Player = wd.findElement(By.name("Player"));
        //button_Player.click();

        //wd.findElement(By.name("Player")).click();

        //Click on seeAll link for moods
        wd.findElement(By.xpath("//UIATableCell[@name='Moods']/UIAButton")).click();

        //syntax of xpath
        //tagName[@attribute='attributevalue']/

        // Number of moods element
        List<WebElement> e = wd.findElements(By.tagName("UIACollectionCell"));
        //div, tr ,td, 
        int actualCount = e.size();
        int expectedCount = 14; // hardcoded

        if(expectedCount==actualCount)
        {
            System.out.println("passed");
        }
        else
        {
            System.out.println("Failed");
        }
        wd.close();
    }
}

执行时出现以下异常:

'Exception in thread "main" org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 2.63 seconds

Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30'

System info: host: 'admins-MacBook-Pro-87.local', ip: '192.168.1.197', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.7.0_55'

Session ID: 31031deb-5b8e-4d4d-96eb-6995fb7b7927

Driver info: org.openqa.selenium.remote.RemoteWebDriver

Capabilities [{platformVersion=7.1, app=/Users/admin/Downloads/Wynk.app, platform=MAC, databaseEnabled=false, javascriptEnabled=true, deviceName=iPhone, platformName=iOS, browserName=iOS, appium-version=1.2, webStorageEnabled=false, desired={platformVersion=7.1, app=/Users/admin/Downloads/Wynk.app, platformName=iOS, deviceName=iPhone, appium-version=1.2}, locationContextEnabled=false, warnings={}, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
at shivaniios.MyFirstClass.main(MyFirstClass.java:49)'

【问题讨论】:

    标签: appium


    【解决方案1】:
    WebDriver wd = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
    

    如果您使用的是 appium,我建议您使用

    AppiumDriver wd = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    

    试试这个方法。如果问题仍然存在,我将等待您的联系

    【讨论】:

    • Appium 日志:信息:
    猜你喜欢
    • 2017-10-03
    • 2016-02-27
    • 1970-01-01
    • 2018-10-25
    • 1970-01-01
    • 2014-09-25
    • 2020-07-29
    • 2020-09-28
    • 2016-07-29
    相关资源
    最近更新 更多