Closed
Description
Env:
java-client:1.6.1
Appium:v1.2.0
1:Create class PageObjects
public class PageObjects {
protected AppiumDriver driver;
protected CmSelenium2 se2;
protected CmReport cm;
public PageObjects(AppiumDriver driver, CmSelenium2 se2) {
this.se2 = se2;
this.cm = se2.cm;
this.driver = driver;
PageFactory.initElements(driver, this);
}
public PageObjects() {
}
public void initElements(AppiumDriver driver ) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
}
2:Create class FolderPage:
import com.mailtech.selenium2.CmSelenium2;
import com.mailtech.selenium2.pageobjects.PageObjects;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import io.appium.java_client.pagefactory.AndroidFindBy;
public class FolderPage extends PageObjects {
@AndroidFindBy(id="cn.mailtech.app:id/compose")
public WebElement toMAIl;
public FolderPage(WebDriver driver, CmSelenium2 se2) {
super(driver,se2);
}
}
3. my test code:
FolderPage folderPage=new FolderPage(driver,se2);
folderPage.toMAIl.click();
error
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 231 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'jli', ip: '192.168.200.85', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_39'
Session ID: a69b18bd-9190-4de1-b5fe-09b0efa2800d
Driver info: io.appium.java_client.AppiumDriver
Capabilities [{platform=LINUX, javascriptEnabled=true, browserName=, appActivity=cn.mailtech.app.activity.SplashMailtech, desired={newCommandTimeout=100, platformVersion=4.4, deviceName=Android Emulator, platformName=Android, browserName=, appActivity=cn.mailtech.app.activity.SplashMailtech, appPackage=cn.mailtech.app}, appPackage=cn.mailtech.app, newCommandTimeout=100, platformVersion=4.4, databaseEnabled=false, deviceName=Android Emulator, platformName=Android, webStorageEnabled=false, warnings={}, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:95)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:425)
at org.openqa.selenium.By$ByName.findElement(By.java:299)
at org.openqa.selenium.support.ByIdOrName.findElement(ByIdOrName.java:49)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:59)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:34)
at sun.proxy.$Proxy9.click(Unknown Source)
at com.mailtech.selenium2.example.appium.cmappTest.Cal.CalTest(Cal.java:115)
at com.mailtech.selenium2.example.appium.cmappTest.Cal.testCal(Cal.java:131)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Process finished with exit code -1
My question: why is @AndroidFindBy not working?
when i use @findby ,it is ok!
@FindBy(id="cn.mailtech.app:id/compose")
public WebElement toMAIl;
Metadata
Metadata
Assignees
Labels
No labels