无法实例化页面(net.thucydides.core.webdriver.DriverConfigurationError:无法实例化类 io.appium.java_client.AppiumDr
Posted
技术标签:
【中文标题】无法实例化页面(net.thucydides.core.webdriver.DriverConfigurationError:无法实例化类 io.appium.java_client.AppiumDriver)【英文标题】:Failed to instantiate page(net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate class io.appium.java_client.AppiumDriver) 【发布时间】:2022-01-03 13:53:07 【问题描述】:serenity-appium 在使用 serenity 1.7.4 版和 serenity cucumber 1.6.3 版时运行良好。但是在页面上使用 serenity 和 cucumber 3.0.5 版时出现以下错误
[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
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
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
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
【问题讨论】:
【参考方案1】:为页面扩展 PageObject 而不是 MobilePageObject 解决了 serenity 和 cucumber 版本 3.0.5 的问题。
【讨论】:
以上是关于无法实例化页面(net.thucydides.core.webdriver.DriverConfigurationError:无法实例化类 io.appium.java_client.AppiumDr的主要内容,如果未能解决你的问题,请参考以下文章
无法实例化 android.gms.maps.MapFragment
在Joomla上获取错误:无法读取会话数据和应用程序实例化错误