0
public static WebElement selectcity(String cityname)
{
     @AndroidFindBy(xpath="//android.widget.CheckedTextView[@text='"+cityname+"']") 
     WebElement city;
     return city;
}

Trying to select city dynamically. When used in above fashion I'm facing the below issues:

  1. The value for annotation attribute AndroidFindBy.xpath must be a constant expression

  2. The annotation @AndroidFindBy is disallowed for this location

Could someone please help me on this?

1

Page factory doesn't support dynamic webelements

    Webelement elem= driver.findElememt(By.xpath("locator"));

Use driver.findelemtns instead

See the status , pagefactory is marked as won't fix

https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/3567#

https://discuss.appium.io/t/page-factory-for-dynamic-locators/8659

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.