首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未能实例化page(net.thucydides.core.webdriver.DriverConfigurationError:,无法实例化类io.appium.java_client.AppiumDriver)

未能实例化page(net.thucydides.core.webdriver.DriverConfigurationError:,无法实例化类io.appium.java_client.AppiumDriver)
EN

Stack Overflow用户
提问于 2021-11-25 09:20:35
回答 1查看 1.4K关注 0票数 0

宁静-appium在使用宁静版本1.7.4和宁静黄瓜版本1.6.3方面做得很好。但是,在页面中使用“宁静”和“黄瓜”版本3.0.5时出现了以下错误

代码语言:javascript
复制
[main] WARN net.thucydides.core.pages.PageFactory - Failed to instantiate page of type class pageObjects.LoginPageMobile (net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate class io.appium.java_client.AppiumDriver)
  Given User launches "Mobile" application # starter.stepdefinitions.LoginSteps.userLaunchesApplication(java.lang.String)
      net.thucydides.core.pages.WrongPageError: The page object class pageObjects.LoginPageMobile could not be instantiated:
Failed to instantiate page (net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate class io.appium.java_client.AppiumDriver)

试着用下面的页面

MobilePageObject

代码语言:javascript
复制
package pageObjects;

import io.appium.java_client.pagefactory.AndroidFindBy;
import net.serenitybdd.core.pages.PageObject;
import org.openqa.selenium.WebElement;

public class LoginPageMobile extends PageObject {

    @AndroidFindBy(xpath="//android.widget.Button[@text='Log In']")
    private WebElement WPLogInButton;
    public void doLogin(){
        typeInto(WPLogInButton,"test@test.com");
    }
}

与MobilePageObject

代码语言:javascript
复制
package pageObjects;

import com.google.common.base.Predicate;

import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import net.serenitybdd.core.pages.PageObject;
import io.appium.java_client.android.AndroidDriver;
import net.thucydides.core.webdriver.WebDriverFacade;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;

public class MobilePageObject extends PageObject {

    public MobilePageObject(final WebDriver driver) {
        super(driver, new Predicate<PageObject>() {
            @Override
            public boolean apply(PageObject page) {
                PageFactory.initElements(new AppiumFieldDecorator(((WebDriverFacade) page.getDriver()).getProxiedDriver()), page);
                return true;
            }
        });
    }

    public MobilePageObject() {
    }
}

Serenity.properties

代码语言:javascript
复制
webdriver.driver= appium
appium.hub = http://localhost:4723/wd/hub
######## android CAPS ######
appium.automationName = Appium
appium.platformName= Android
appium.platformVersion = 11.0
appium.deviceName  = emulator-5554
appium.app = serenity-cucumber-starter/src/test/resources/Calculator.apk

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-25 13:58:13

扩展页面的PageObject而不是MobilePageObject解决了宁静和黄瓜版本3.0.5的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70108545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档