问题描述
我正在将页面工厂用于我的appium框架.当我尝试运行testng5.xml
并想一个又一个地运行2个类时,就会出现问题.
I am using a page factory for my appium framework. The problem is arising when I am trying to run testng5.xml
where I want to run 2 classes one after another.
我收到类似"无法设置io.appium.java_client.MobileElement字段"的错误.
I get an error like "can not set io.appium.java_client.MobileElement field ".
我在构造函数级别遇到此错误.
I get this error at my constructor level.
public Homepage(WebDriver driver) {
super(driver);
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
不确定testng5.xml
中的问题是什么.首先,该类运行良好,但是当第二个类启动时会出现问题.
Not sure what the issue is in testng5.xml
. First, the class runs all fine, but problems occur when the 2nd class initiates.
testng5.xml
:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Regression Suit2">
<test name="Sanity Tests">
<parameter name="device" value="Nexus4" />
<parameter name="port" value="4723" />
<classes>
<class name="au.com.intelematics.mobileautomation.settings.SettingsPageTest" />
<class name="au.com.intelematics.mobileautomation.destinationdownload.DestinationDownloadPageTest" />
</classes>
</test>
</suite>
<!-- Suite -->
推荐答案
谢谢,我为每个测试设置了适当的生命周期,从而解决了这个问题.早些时候,我在@BeforeClass
下初始化驱动程序(ios或android).我将其更改为@BeforeMethod
,并提到了@AfterMethod
进行注销操作(无论何时需要)和driver.quit();
.现在,在每种测试方法开始之前已设置驱动程序.还将我的WebDriver
强制转换为AppiumDriver
进行驱动程序初始化.
Thanks all, I got this issue resolved by putting proper life cycle for each test.Earlier I was initializing the driver (ios or android)under @BeforeClass
. I changed that to @BeforeMethod
and mentioned @AfterMethod
for logout action(wherever required) and driver.quit();
Now the the driver is setup before start of each test method.Also casted my WebDriver
to AppiumDriver
for driver initialization.
这篇关于错误:无法设置框架中引发的io.appium.java_client.MobileElement字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!