question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PageObjects gets elements API instead of element API

See original GitHub issue

@TikhomirovSergey need help on this

Works fine

@HowToUseLocators(androidAutomation = CHAIN)
    @AndroidFindBySet({
            @AndroidFindBy(xpath = "(.//*[@resource-id='org.wordpress.android:id/note_content_container'])[position()=2]"),
            @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"org.wordpress.android:id/note_subject\")")
    }) //gets the third text from the note_subject view

Does not work

@HowToUseLocators(androidAutomation = CHAIN)
    @AndroidFindBySet({
            @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"org.wordpress.android:id/note_content_container\").enabled(true).instance(2)"),
            @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"org.wordpress.android:id/note_subject\")")
    }) //return the first text from the view 

https://gist.github.com/anonymous/d4440cab5e3213f9084498471201cd84

The above works fine, when we cast AndroidDriver

((AndroidDriver) driver).findElementByAndroidUIAutomator("new UiSelector().resourceId(\"org.wordpress.android:id/note_subject\").enabled(true).instance(2)").getText()

https://gist.github.com/anonymous/3b1fcc5761c370a1025d52c42b60b9fd

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
TikhomirovSergeycommented, Dec 30, 2016

yes. It is here https://github.com/appium/java-client/blob/master/src/main/java/io/appium/java_client/pagefactory/AppiumElementLocator.java#L157

I really think that root cause is here. But I can check it only tomorrow or on the 1 Jan.

1reaction
TikhomirovSergeycommented, Dec 30, 2016

Yep. I will try to search for the root cause on the 1 Jan. For now please use xpath instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page object module - API Reference | Nightwatch.js
This is used to access those commands that are not part of the subset of commands within the page object API. elements, Object,...
Read more >
switch between page object api and main nightwatch api
1st : api will return this.api instead of this page-object so we are only able to call this page object via page
Read more >
Stop using Page Objects and Start using App Actions - Cypress
In this post I argue that page objects are a bad practice, ... addTodo to add items directly using the application's internal “api”....
Read more >
Automation in Selenium: Page Object Model and Page Factory
Webpage classes or Page Objects containing web elements need to be initialized using Page Factory before the web element variables can be used....
Read more >
Page Object Pattern - WebdriverIO
Version 5 of WebdriverIO was designed with Page Object Pattern support in mind. By introducing the "elements as first class citizens" principle, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found