I’m using Appium 2 (appium:java-client:8.3.0) in my project and noticed @AndroidFindBy and @iOSXCUITFindBy is not working only @FindBy is working.
Is there any dependent library we have to add?
It’s not throwing any error when i mention @AndroidFindBy and @iOSXCUITFindBy but not detecting webElement. But when I use @FindBy it’s detecting. I have to use these annotation as we will have different element locator for both app.
public boolean click(){
element(signIn).waitUntilClickable();
element(signIn).click();
}
Appium Server error:
[HTTP] {“using”:“css selector”,“value”:“#signIn”}
[debug] [XCUITestDriver@0567 (65e9b496)] Calling AppiumDriver.findElement() with args: [“css selector”,“#signIn”,“65e9b496-4170-4fdd-8f2c-cf7e5f63a5ac”]
[debug] [XCUITestDriver@0567 (65e9b496)] Executing command ‘findElement’
[debug] [XCUITestDriver@0567 (65e9b496)] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id, css selector
[debug] [XCUITestDriver@0567 (65e9b496)] Waiting up to 0 ms for condition
[debug] [XCUITestDriver@0567 (65e9b496)] Setting custom timeout to 240000 ms for ‘findElement’ command
[debug] [XCUITestDriver@0567 (65e9b496)] Matched ‘/element’ to command name ‘findElement’
[debug] [XCUITestDriver@0567 (65e9b496)] Proxying [POST /element] to [POST http://127.0.0.1:8100/session/98A1C73A-56D4-45B0-9403-74C6EB5B2755/element] with body: {“using”:“class chain”,“value”:“/*[name == \"signIn\"]"}
[XCUITestDriver@0567 (65e9b496)] Got response with status 404: {“value”:{“error”:“no such element”,“message”:"unable to find an element using ‘class chain’, value '/*[name == \"signIn\"]'”,“traceback”:"(\n\t0 WebDriverAgentLib 0x000000010fcd3748 FBNoSuchElementErrorResponseForRequest + 252\n\t1 WebDriverAgentLib 0x000000010fcd3578 +[FBFindElementCommands handleFindElement:] + 304\n\t2 WebDriverAgentLib 0x000000010fc9b2d8 -[FBRoute_TargetAction mountRequest:intoResponse:] + 168\n\t3 WebDriverAgentLib 0x000000010fc8767c __37-[FBWebServer registerRouteHandlers:]_block_invoke + 396\n\t4 WebDriverAgentLib 0x000000010fcbbc58 -[RoutingHTTPServer handleRoute:withRequest:response:] + 160\n\t5 WebDriverAgentLib 0x000000010fcbc6e4 __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 64\n\t6 libdispatch.dylib 0x0000000180135768 _dispatch_client_callout + 16\n\t7 libdispatch.dylib …
[debug] [W3C] Matched W3C error code ‘no such element’ to NoSuchElementError
[debug] [XCUITestDriver@0567 (65e9b496)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
IntelliJ error
net.thucydides.core.webdriver.exceptions.ElementShouldBeEnabledException: Expected enabled element was not enabled
at net.serenitybdd.core.pages.WebElementFacadeImpl.waitUntilClickable(WebElementFacadeImpl.java:1134)
In appium server logs it shows CSS selector but i used only accessibility in iOS. Not sure why it’s showing different in logs?Same element is clickable while using @FindBy
And super calls to
protected PageObject(WebDriver driver, Predicate<? super PageObject> callback) {
this();
this.driver = driver;
callback.apply(this);
}
Same , it’s not detecting IOS and android annotation
Yes.It’s working in @FindBy. We have cross platform in which iOS and Android have different element locator. Can’t use @FindBy until we have same element locator in both.
[quote=“IMOBILETester, post:4, topic:39465”] hello, It’s in my previous post. Attaching again thanks. Appium Server error:
[HTTP] {“using”:“css selector”,“value”:“#signIn”}
[debug] [XCUITestDriver@0567 (65e9b496)] Calling AppiumDriver.findElement() with args: [“css selector”,“#signIn”,“65e9b496-4170-4fdd-8f2c-cf7e5f63a5ac”]
[debug] [XCUITestDriver@0567 (65e9b496)] Executing command ‘findElement’
[debug] [XCUITestDriver@0567 (65e9b496)] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id, css selector
[debug] [XCUITestDriver@0567 (65e9b496)] Waiting up to 0 ms for condition
[debug] [XCUITestDriver@0567 (65e9b496)] Setting custom timeout to 240000 ms for ‘findElement’ command
[debug] [XCUITestDriver@0567 (65e9b496)] Matched ‘/element’ to command name ‘findElement’
[debug] [XCUITestDriver@0567 (65e9b496)] Proxying [POST /element] to [POST http://127.0.0.1:8100/session/98A1C73A-56D4-45B0-9403-74C6EB5B2755/element] with body: {“using”:“class chain”,“value”:" /[ name == \"signIn\" ]"}
[XCUITestDriver@0567 (65e9b496)] Got response with status 404: {“value”:{“error”:“no such element”,“message”:"unable to find an element using ‘class chain’, value ' /[ name == \"signIn\" ]’“,“traceback”:”(\n\t0 WebDriverAgentLib 0x000000010fcd3748 FBNoSuchElementErrorResponseForRequest + 252\n\t1 WebDriverAgentLib 0x000000010fcd3578 +[FBFindElementCommands handleFindElement:] + 304\n\t2 WebDriverAgentLib 0x000000010fc9b2d8 -[FBRoute_TargetAction mountRequest:intoResponse:] + 168\n\t3 WebDriverAgentLib 0x000000010fc8767c __37-[FBWebServer registerRouteHandlers:]_block_invoke + 396\n\t4 WebDriverAgentLib 0x000000010fcbbc58 -[RoutingHTTPServer handleRoute:withRequest:response:] + 160\n\t5 WebDriverAgentLib 0x000000010fcbc6e4 __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 64\n\t6 libdispatch.dylib 0x0000000180135768 _dispatch_client_callout + 16\n\t7 libdispatch.dylib …
[debug] [W3C] Matched W3C error code ‘no such element’ to NoSuchElementError
[debug] [XCUITestDriver@0567 (65e9b496)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
It looks like you still haven’t initialized the AppiumFieldDecorator because I had a similar problem, precisely due to incorrect page initialization. My function in the base class of page looks like this:
I tried above code . Issue is I can’t declare AppiumDriver in code as My base class extends PageObject inbuilt class and there is no “AppiumDriver” in that inbuilt class. It’s just having “Webdriver”.
So, I’m using like this below
And super calls in a page like this:
public AuthListPage(WebDriver driver) {
super(driver);
}
But same error like mentioned above.
If i use exactly like your code using “AppiumDriver”,getting below error like this
net.thucydides.core.pages.WrongPageError: The page object class com.Page could not be instantiated:
This page object does not appear have a constructor that takes a WebDriver parameter
at net.thucydides.core.pages.PageFactory.thisPageObjectLooksDodgy(PageFactory.java:103)
at net.thucydides.core.pages.PageFactory.createPageOfType(PageFactory.java:46)
at net.thucydides.core.steps.PageObjectDependencyInjector.instantiatePageObjectIfNotAssigned(PageObjectDependencyInjector.java:83)
at net.thucydides.core.steps.PageObjectDependencyInjector.injectDependenciesInto(PageObjectDependencyInjector.java:50)
at net.thucydides.core.steps.StepFactory.injectOtherDependenciesInto(StepFactory.java:206)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:196)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:177)
at net.thucydides.core.steps.StepFactory.getNewStepLibraryFor(StepFactory.java:124)
at net.thucydides.core.steps.IndividualInstancesByDefaultStepCreationStrategy.initiateStepsFor(IndividualInstancesByDefaultStepCreationStrategy.java:16)
at net.thucydides.core.steps.StepAnnotations.instantiateAnyUnitiaializedSteps(StepAnnotations.java:89)
at net.thucydides.core.steps.StepAnnotations.instanciateScenarioStepFields(StepAnnotations.java:70)
at net.thucydides.core.steps.StepAnnotations.injectScenarioStepsInto(StepAnnotations.java:52)
at net.serenitybdd.core.Serenity.injectScenarioStepsInto(Serenity.java:148)
at net.serenitybdd.core.Serenity.initializeWithNoStepListener(Serenity.java:112)
at cucumber.runtime.SerenityObjectFactory.newInstance(SerenityObjectFactory.java:76)
at cucumber.runtime.SerenityObjectFactory.cacheNewInstance(SerenityObjectFactory.java:59)
at cucumber.runtime.SerenityObjectFactory.getInstance(SerenityObjectFactory.java:49)
at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47)
at io.cucumber.java.JavaStepDefinition.execute(JavaStepDefinition.java:29)
at io.cucumber.core.runner.CoreStepDefinition.execute(CoreStepDefinition.java:66)
at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:63)
at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10)
at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:84)
at io.cucumber.core.runner.TestStep.run(TestStep.java:56)
at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51)
at io.cucumber.core.runner.TestCase.run(TestCase.java:84)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:75)
at io.cucumber.junit.PickleRunners$NoStepDescriptions.lambda$run$0(PickleRunners.java:151)
at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runTestCase$5(CucumberExecutionContext.java:130)
at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:130)
at io.cucumber.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:148)
at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:144)
at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:28)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at io.cucumber.junit.FeatureRunner.run(FeatureRunner.java:137)
at io.cucumber.junit.CucumberSerenityBaseRunner.runChild(CucumberSerenityBaseRunner.java:330)
at io.cucumber.junit.CucumberSerenityBaseRunner.runChild(CucumberSerenityBaseRunner.java:51)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at io.cucumber.junit.CucumberSerenityBaseRunner$RunCucumber.evaluate(CucumberSerenityBaseRunner.java:361)
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$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Noticed one more thing when I’m using @AndroidFindBy while debugging it’s taking that element value as ByIDOrName. But Name is not mentioned in element locator as i have used id only .Whereas @FindBy it’s taking correct By.id=“xxxxx”. Not sure why it’s taking differently.
I think the problem is that you are using Webdriver instead of AppiumDriver. Thucydides is used by original Selenuim and doesn’t seem to work with AppiumDriver. In my case, in the base class of the page, I declare the Appium Driver like this: