2

I'm developing a test case that needs to run on both iOS and Android platforms using QAF (Qmetry Automation Framework). I want to follow a Page Object approach where I can define elements for both platforms in a single place and reuse them in my tests.

In Appium, I can achieve this by using annotations like @AndroidFindBy and @iOSXCUITFindBy. Here's an example:

@HowToUseLocators(androidAutomation = LocatorGroupStrategy.ALL_POSSIBLE, iOSXCUITAutomation = LocatorGroupStrategy.ALL_POSSIBLE)
@AndroidFindBy(xpath = "//android.widget.TextView[@resource-id='merchant-name']")
@iOSXCUITFindBy(accessibility = "Home")
protected WebElement home;

This allows me to specify different locators for Android and iOS, and the framework automatically chooses the appropriate locator based on the platform.

However, I couldn't find a similar implementation in QAF. Is there a way to achieve the same result in QAF? I would greatly appreciate any guidance or suggestions on how to approach this in QAF. Thank you!

1 Answers1

0

QAF has great capabilities of re-usability for cross platform test automation. You should utilize locator repository feature of qaf to abstract locator out from the code. For example, if using page class, instead of having platform specific class

IosHomePage.java


@iOSXCUITFindBy(accessibility = "Home")
protected WebElement home;

AndriodHomePage.java

@AndroidFindBy(xpath = "//android.widget.TextView[@resource-id='merchant-name']")
protected WebElement home;

you can have single class with separate locator repository for each platform (android and ios in this case)

HomePage.java

@FindBy(locator = "home.ele.loc")
protected WebElement home;

you can create locator repository for each platform and add locator in it

resource
  - appilcation.properties
  -common
     - 
  - android
     - homescreen.properties
     - 
     - 
  -ios
     - homescreen.properties
     - 
     - 

At the time of execution specify which resources you want to use by using env.resources property. For example, if want to run for android

env.resource=resource/common;resources/android

for android

env.resource=resource/common;resources/ios

Another alternate is driver specific resources. In that case your properties will look like below

env.resource=resource/common
android.resources=resources/android
ios.resources=resources/ios

Refer:

There is also a good training material available from perfecto on Locator & Capabilities

user861594
  • 5,733
  • 3
  • 29
  • 45