Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible that MobileElement/AndroidElement/IOSElement support element description? #478

Closed
ansonliao opened this issue Sep 27, 2016 · 11 comments

Comments

@ansonliao
Copy link

Description

Hi,
For more details to track the test operation/flow in test report (for example, ReportNG, ExtentsReport), is it possible that add a public String field to MobileElement/AndroidElement/IOSElement for storing the element's description?

for example:

public class HomePageObjects {

    @iOSFindBy(id = "submit", description = "Home page - [Submit] button")
    public IOSElement submitButton;

    ...
}

public class ProfilePageObjects {

    @iOSFindBy(id = "submit", description = "Profile page - [Submit] button")
    public MobileElement submitButton;
}

so that in calling reporter's log method in personal Appium test project:

public void click(MobileElement e) {
    e.click();
    // reportNG
    reporter.log("Click: " + e.getDescription());
}

public void clearText(MobileElement e) {
    e.clear();
    //reportNG
    reporter.log("Clear Text: " + e.getDescription());
}

public void enterText(MobileElement e, String s) {
    e.sendKeys(s);
    //reportNG
    reporter.log("Type Text: " + e.getDescription());
}

public void swipDown(MobileElement e) {
    //add code here
}

so that the test report will be more detail as mobile description supported:

Snipshot of ReportNG:

Type: ......
Swipe Down: ....
Clear Text: ...
...
Click: Home page - [Submit] button
...
Click: Profile page - [Submit] button
Test fail

Error: MobileElemet: by.id = "submit" still displayed.

tracking test report test operation flow, it is more easier to locate the it was fail after click profile page submit button, not home page submit button.

please advise.

Please describe the issue. It may be a bug description. So then please briefly descride steps which you were trying to perform and what happened instead.
If there is the feature you want to see added to Appium Java client so please describe necessity of this feature and the way that it should work.

Environment

  • java client build version or git revision if you use some shapshot:
  • Appium server version or git revision if you use some shapshot:
  • Desktop OS/version used to run Appium if necessary:
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe:
  • Mobile platform/version under test:
  • Real device or emulator/simulator:

Details

Please provide more details, if necessary.

Code To Reproduce Issue [ Good To Have ]

Please remember that, with sample code; it's easier to reproduce bug and much faster to fix it.
You can git clone https://github.com/appium/sample-code or https://github.com/appium/sample-code/tree/master/sample-code/apps and reproduce an issue using Java and sample apps.
Also you can create a gist with pasted java code sample or put it here using markdown. About markdown please read Mastering markdown and
Writing on GitHub

Ecxeption stacktraces

Please create a gist with pasted stacktrace of exception thrown by java.

Link to Appium logs

Please create a gist which is a paste of your full Appium logs, and link them here. Do not paste your full Appium logs here, as it will make this issue very long and hard to read!
If you are reporting a bug, always include Appium logs as linked gists! It helps to define the problem correctly and clearly.

@rromanik
Copy link

rromanik commented Oct 5, 2016

Hi all,

I like the idea to have some additional info returned about an element when its 'toString()' method is invoked.

Maybe, to inject such description into @findby annotation is not reasonable, but to add, e.g., @name annotation (in a manner similar to Yandex HtmlElements framework, see here and here ) would be great!

And this enhancement may well be in accord with 'Widget' feature of Appium framework, see here.

The example code:

public class APage {
    @Name("'Login' Button")
    @FindBy(id = "loginButton")
    private Button loginButton;

    public void clickLoginButton() {
        System.out.println("Clicks " + loginButton);
        loginButton.click();
    }
}

and invoking 'clickLoginButton()' method from APage would print
"Clicks 'Login' Button"

And last comment: It does not sound like an issue, but rather as a Feature Request. Where should I put it then?

Thanks,
Roman Romanik

@ansonliao
Copy link
Author

@rromanik

Good to know Yandex HtmlElements framework, and look good that anntation @Name, dont know how to implement it in MobileElement.

any idea?

@HlebHalkouski
Copy link
Contributor

@TikhomirovSergey how you look at idea add Name annotation like Yandex HtmlElements framework?

We need to change AppiumField decorator: update defaultElementFieldDecorator and decorateWidget method.
Add to interceptors constructors parameter String name and in intercept toString replace locator.toString to name:
And add ElementUtil class with logic around Name annotation.

I can try to implement this.

@aldonin
Copy link

aldonin commented May 10, 2017

@HlebHalkouski hi, any progress? If you need, I have working example, but for 1.4 fork. We use it for our project

@ansonliao
Copy link
Author

thanks all, I also use Yandex HtmlElements framework in my Selenium test, for Appium, I tried to extend MobileElement and finally found that many classes are private in Java-Client, it is hard to extend from Java-Client.

@HlebHalkouski @aldonin hope can hear the good news from you soon.

@HlebHalkouski
Copy link
Contributor

HlebHalkouski commented May 12, 2017

@ansonliao @aldonin I found good solution. This merge make locator factory classes public and I use annotation from java-client with my custom decorator. My decorator is hybrid of Yandex HtmlElements decorator with locator factory from java-client.

elementLocatorFactory = new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver, new DefaultElementByBuilder(platform, automation));' ' blockLocatorFactory = new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver, new WidgetByBuilder(platform, automation));

I add Named interface for my mobile elements and set name in interceptor.

@aldonin
Copy link

aldonin commented May 12, 2017

@HlebHalkouski Do you plan any pull request to java-client? It would be great. Thanks in advance

@HlebHalkouski
Copy link
Contributor

@aldonin no, no pull request. Because I created issue and Mykola explained me why appium java-client don't need updates.
You can contact me by Skype and I will show you me inmplementation.

@saikrishna321
Copy link
Member

Closing w.r.t #625

@ansonliao
Copy link
Author

@HlebHalkouski
could you share your code that those classes implemetation?
Contact you via Skyep but no response.

elementLocatorFactory = new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver, new DefaultElementByBuilder(platform, automation));' ' blockLocatorFactory = new AppiumElementLocatorFactory(context, timeOutDuration, originalDriver, new WidgetByBuilder(platform, automation));

@UltroEdward
Copy link

Any custom Decorator & extended mobile elements implementation?

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

No branches or pull requests

6 participants