testLogin失败:在AWS Device Farm中

时间:2017-06-13 11:48:02

标签: java amazon-web-services appium aws-device-farm

我正在使用AWS Device Farm运行Appium TestNG Test。每次运行时都会出现以下错误。

{
    "attachment_id": null,
    "parent_id": null,
    "timestamp": "2017-06-13T10:25:38.950000Z",
    "level": "Debug",
    "pid": 1824,
    "data": "[MJSONWP] Responding to client with driver.getStatus() result: {\"build\":{\"version\":\"1.6.3\",\"revision\":null}}",
    "source": "Test",
    "tag": "Appium Server",
    "subtype": "Text",
    "tid": -1,
    "type": "Message",
    "id": 5631
}, {
    "attachment_id": null,
    "parent_id": null,
    "timestamp": "2017-06-13T10:25:38.964000Z",
    "level": "Info",
    "pid": 1824,
    "data": "<-- GET /wd/hub/status 200 38 ms - 83",
    "source": "Test",
    "tag": "Appium Server",
    "subtype": "Text",
    "tid": -1,
    "type": "Message",
    "id": 5632
}, {
    "attachment_id": null,
    "parent_id": null,
    "timestamp": "2017-06-13T10:25:41.064000Z",
    "level": "Info",
    "pid": 1824,
    "data": "Received SIGTERM - shutting down",
    "source": "Test",
    "tag": "Appium Server",
    "subtype": "Text",
    "tid": -1,
    "type": "Message",
    "id": 5634
}, {
    "attachment_id": null,
    "parent_id": null,
    "timestamp": "2017-06-13T10:25:41.068525Z",
    "level": "Info",
    "pid": 1411,
    "data": "testLogin completed in 0.001s",
    "source": "Harness",
    "tag": null,
    "subtype": "Text",
    "tid": 1417,
    "type": "Message",
    "id": 5635
}, {
    "attachment_id": null,
    "parent_id": null,
    "timestamp": "2017-06-13T10:25:41.068751Z",
    "level": "Debug",
    "pid": 1411,
    "data": "\n      java.lang.NullPointerException\n
    \tat io.appium.java_client.pagefactory.AppiumFieldDecorator.getTypeForProxy(AppiumFieldDecorator.java:233)\n
    \tat io.appium.java_client.pagefactory.AppiumFieldDecorator.proxyForAnElement(AppiumFieldDecorator.java:248)\n
    \tat io.appium.java_client.pagefactory.AppiumFieldDecorator.access$0(AppiumFieldDecorator.java:246)\n
    \tat io.appium.java_client.pagefactory.AppiumFieldDecorator$3.proxyForLocator(AppiumFieldDecorator.java:121)\n
    \tat org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:62)\n
    \tat io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:172)\n
    \tat org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:112)\n
    \tat org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:104)\n
    \tat com.mobile.pages.BasePage.<init>(BasePage.java:31)\n
    \tat com.mobile.pages.LoginPage.<init>(LoginPage.java:47)\n
    \tat com.mobile.testcases.Login.doBeforeTest(Login.java:27)\n
    \tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n
    \tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n
    \tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n
    \tat java.lang.reflect.Method.invoke(Method.java:497)\n
    \tat org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)\n
    \tat org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)\n
    \tat org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)\n
    \tat org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)\n
    \tat org.testng.TestRunner.beforeRun(TestRunner.java:641)\n
    \tat org.testng.TestRunner.run(TestRunner.java:609)\n
    \tat org.testng.SuiteRunner.runTest(SuiteRunner.java:348)\n
    \tat org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)\n
    \tat org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)\n
    \tat org.testng.SuiteRunner.run(SuiteRunner.java:254)\n
    \tat org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)\n
    \tat org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)\n
    \tat org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)\n
    \tat org.testng.TestNG.runSuitesLocally(TestNG.java:1149)\n
    \tat org.testng.TestNG.run(TestNG.java:1057)\n
    \tat org.testng.TestNG.privateMain(TestNG.java:1364)\n
    \tat org.testng.TestNG.main(TestNG.java:1333)\n\n    ",
    "source": "Harness",
    "tag": null,
    "subtype": "Text",
    "tid": 1417,
    "type": "Message",
    "id": 5636
}, {
    "attachment_id": null,
    "parent_id": null,
    "timestamp": "2017-06-13T10:25:41.068987Z",
    "level": "Failed",
    "pid": 1411,
    "data": "testLogin failed: ",
    "source": "Harness",
    "tag": null,
    "subtype": "Text",
    "tid": 1417,
    "type": "Message",
    "id": 5637
}, {
    "attachment_id": null,
    "parent_id": null,
    "timestamp": "2017-06-13T10:25:46.245218Z",
    "level": "Info",
    "pid": 1411,
    "data": "Finished testLogin",
    "source": "Harness",
    "tag": null,
    "subtype": "Text",
    "tid": 1416,
    "type": "Message",
    "id": 5651
}

我的BaseConfig是:

package com.mobile.testcases;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.service.local.AppiumDriverLocalService;

import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;

/**
 * Base class for All Test Cases. All the test cases to extend this base class.
 * 
 *
 */
public abstract class BaseTestConfig {

    //------------------------------------------------------------------------------------------------------------------
    /**
     * Instance of {@link WebDriver}
     */
    protected AppiumDriver<WebElement> driver;
    /**
     * Instance of {@link AppiumDriverLocalService}
     */
    private AppiumDriverLocalService appiumService;
    /**
     * Variable to store appium service url.
     */
    private String appiumServiceUrl;
    //------------------------------------------------------------------------------------------------------------------
    /**
     * Method to be called before start of the test suite. This method will launch the appium server installed on the 
     * machine. This method will load the device capabilites configuration and launch the device using appium.
     */
    @BeforeSuite
    public void doBeforeSuite() {
        /*appiumService = AppiumDriverLocalService.buildDefaultService();
        appiumService.start();
        appiumServiceUrl = appiumService.getUrl().toString();*/

        Properties prop = new Properties();
        try {
            prop.load(new FileInputStream("device_capabilities.properties"));

            Map<String, String> prop_map = new HashMap<String, String>();
            for (String key : prop.stringPropertyNames()) {
                prop_map.put(key, prop.getProperty(key));
            }           
            DesiredCapabilities capabilities = new DesiredCapabilities(prop_map);
            driver = new AndroidDriver<WebElement>(new URL(appiumServiceUrl), capabilities);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    //------------------------------------------------------------------------------------------------------------------
    /**
     * Method to be called before the test starts. All the extending class to implement this method as per the test case requirements.
     */
    @BeforeTest
    public abstract void doBeforeTest();
    //------------------------------------------------------------------------------------------------------------------
    /**
     * Method to be called after the test case execution. All the extending class to implement this method as per the test case requirements.
     */
    @AfterTest
    public abstract void doAfterTest();
    //------------------------------------------------------------------------------------------------------------------
    /**
     * Method to be called after test suite execution to close the web driver and close the appium service.
     */
    @AfterSuite
    public void doAfterSuite() {
        /*driver.quit();
        appiumService.stop();*/
    }
    //------------------------------------------------------------------------------------------------------------------
}

我上传了apk,然后是zip-with-dependencies。当我创建一个运行时,我收到了错误。

0 个答案:

没有答案