appium#52 Add @FindBy annotations for appium's extra locator strategies by TikhomirovSergey · Pull Request #68 · appium/java-client · GitHub
Skip to content

appium#52 Add @FindBy annotations for appium's extra locator strategies#68

Merged
Jonahss merged 1 commit into
appium:masterfrom
TikhomirovSergey:master
Jul 28, 2014
Merged

appium#52 Add @FindBy annotations for appium's extra locator strategies#68
Jonahss merged 1 commit into
appium:masterfrom
TikhomirovSergey:master

Conversation

@TikhomirovSergey

Copy link
Copy Markdown
Contributor

WebElement can be instantiated by these ways:

@FindBy(someStrategy) //for browser or Html UI
@AndroidFindBy(someStrategy) //for Android UI of the same application. Strategies are:
//uiAutomator, accessibility, id, name, className, tagName, xpath
//@AndroidFindBys({@AndroidFindBy(someStrategy1), @AndroidFindBy(someStrategy2)}) is for chained search

@iOSFindBy(someStrategy) //for iOS UI of the same application. Strategies are:
//uiAutomator, accessibility, id, name, className, tagName, xpath
//iOSFindBys({@iOSFindBy(someStrategy1), @iOSFindBy(someStrategy2)}) is for chained search
WebElement someElement;

or

@FindBy(someStrategy)
@AndroidFindBy(someStrategy) 
@iOSFindBy(someStrategy)
RemoteWebElement someElement;

or

@AndroidFindBy(someStrategy) 
@iOSFindBy(someStrategy)
MobileElement someElement;

Now old browser page objects can be reusable with this decorator:

PageFactory.initElements(new AppiumFieldDecorator(driver), 
pageObject //an instance of PageObject.class
);

or

PageFactory.initElements(new AppiumFieldDecorator(driver, 
          15, //default implicit waiting timeout for all strategies
        TimeUnit.SECONDS), 
            pageObject //an instance of PageObject.class
);

I made some tests. If there is not enough please add your own.

@bootstraponline

Copy link
Copy Markdown
Member

@jlipps

jlipps commented Jul 23, 2014

Copy link
Copy Markdown
Member

I think @Jonahss will want to review this and he's on vacation for a few more days--thanks a ton for the work!

@TikhomirovSergey

Copy link
Copy Markdown
Contributor Author

Is squashed.

@Jonahss Jonahss merged commit 70d9e03 into appium:master Jul 28, 2014
@Jonahss

Jonahss commented Jul 28, 2014

Copy link
Copy Markdown
Member

Awesome!

@prattpratt

Copy link
Copy Markdown
Contributor

Cool! Looks great!
Nice job, @TikhomirovSergey !

@hatti

hatti commented Sep 1, 2014

Copy link
Copy Markdown

Hello! I posted a question to the Annotations into https://discuss.appium.io/t/java-client-1-6-0-findby-annotations-vs-driver-find/88

@TikhomirovSergey

Copy link
Copy Markdown
Contributor Author

@email2vimalraj

Copy link
Copy Markdown
Contributor

I'm bit confused on this implementation. Correct me if I'm doing wrong here:

public class TestOne {
    private WebDriver driver;

    @FindBy(id="testid")
    @AndroidFindBy(id="testid")
    @iOSFindBy(id="testid")
    MobileElement testElement;

    @Before
    public void setup() {
        PageFactory.initElements(new AppiumFieldDecorator(driver, 15, TimeUnit.SECONDS), this);
    }

    @Test
    public void testHideKeyboard() {
        testElement.scrollTo("someText");   // Doesn't work, because the scrollTo is implemented in AndroidDriver
        driver.hideKeyboard();              // Doesn't work either, because hideKeyboard is implemented in AppiumDriver
    }
}

Are these annotations only works for web ui, not for native?
My native app and web ui have similar ui and the actions, only the locators are different. Kindly apologise me for the very basic question as I have started learning the Appium now.

@TikhomirovSergey

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants