Multi Platform Finder

Ekam provides the capability of running same test in Android and iOS platforms.

Multi platform finder

It may so happen that, the element locator stratagies could differ in Android and iOS platforms. Multi platform finder helps to declare locators for Android and iOS in a single statement.

 MultiPlatformFinder usernameTextBox = finder(
        queryByContentDesc("test-Username"),  // Locator in Android for username element
        queryById("test-Username")            // Locator in iOS for username element
      );

The same test now can be executed against Android and iOS platforms.

Sample Test

Let us us see an example:

LoginScreen

package ekam.example.mobile.screen;

import com.testvagrant.ekam.atoms.mobile.MobileScreen;
import com.testvagrant.ekam.reports.annotations.MobileStep;
import org.openqa.selenium.By;

import static org.testng.Assert.*;

public class LoginScreen extends MobileScreen {

    private final MultiPlatformFinder usernameTextBox = finder(
      queryByContentDesc("test-Username"), queryById("test-Username"));
    
    private final MultiPlatformFinder passwordTextBox = finder(
      queryByContentDesc("test-Password"), queryById("test-Password"));
    
    private final MultiPlatformFinder loginButton = finder(
      queryByContentDesc("test-LOGIN"), queryById("test-LOGIN"));
    
    private final MultiPlatformFinder cart = finder(
      queryByContentDesc("test-Error message"), queryById("test-Cart"));

    @MobileStep(keyword = "When", description = "I login")
    public LoginScreen login() {
        textbox(usernameTextBox).setText("standard_user");
        textbox(passwordTextBox).setText("secret_sauce");
        element(loginButton).click();
        return this;
    }

    @MobileStep(keyword = "Then", description = "Return if cart is displayed")
    public boolean isCartDisplayed() {
        return element(cart).isDisplayed();
    }
}

LoginTest

package ekam.example.mobile;

import com.testvagrant.ekam.testBases.testng.MobileTest;
import static com.testvagrant.ekam.commons.LayoutInitiator.*;
import ekam.example.mobile.screen.LoginScreen;
import org.testng.annotations.Test;

import static org.testng.Assert.*;

public class LoginTest extends MobileTest {

    @Test(groups = "mobile")
    public void shouldLoginSuccessfully() {

        boolean cartDisplayed = Screen(LoginScreen.class)
                .login()
                .isCartDisplayed();
        assertTrue(cartDisplayed, "Cart is not displayed");
    }
}

Execute test in Android and iOS platforms

Execute the above test in android and iOS platforms.

Android

To execute tests in Android platform, please refer here

iOS

To execute tests in iOS platform, please refer here


In absence of Ekam, we had to create two different repositories and two different tests - One for Android and one for iOS. With Ekam save 50% of efforts, as you now can have one repositiry and one test.