NullPointer异常:为Appium使用PageFactory设计模式

时间:2015-05-13 06:26:37

标签: nullpointerexception appium

我正在尝试使用PageFactory设计模式,但获得Null Pointer Exception。请提出所需的任何改进。

我的示例代码如下:

~T()

示例屏幕类:

public DriverCapabilities() throws IOException{
    URL url;
    try {
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("newCommandTimeout", "90");
        caps.setCapability("browserName", "");

            caps.setCapability("appActivity",Config.appActivity );
            caps.setCapability("appPackage", Config.appPackage);
            caps.setCapability("appWaitActivity",Config.appWaitActivity);
            caps.setCapability("platformName", "Android");
            caps.setCapability("platformVersion", "5.0");
            caps.setCapability("deviceName", "Android Emulator");
        }

        caps.setCapability("app", Config.path);
        caps.setCapability("appium-version", "1.3.7.2");
        url = new URL("http://127.0.0.1:4723/wd/hub");

        innerDriver = Config.os.equalsIgnoreCase("ANDROID")? new AndroidDriver(url, caps): new IOSDriver(url, caps);
        DriverWait.implicitWait();
        PageFactory.initElements(new AppiumFieldDecorator(innerDriver, 5, TimeUnit.SECONDS), this);
    }

示例测试代码:

public class DemoScreen{
@AndroidFindBy(id = "eula_accept")
private static RemoteWebElement eula;
public static void submit() throws IOException{
     init.getInstance(); //To initialize the driver
     getEula().click();
}
public static WebElement getEula() {
    return eula;
}
}

是因为某个地方我没有初始化对象,还是与我正在关注的设计模式有关?

0 个答案:

没有答案