How to use iOSXCUITBy class of io.appium.java_client.pagefactory package

Best io.appium code snippet using io.appium.java_client.pagefactory.iOSXCUITBy

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

LoginScreen.java

Source: LoginScreen.java Github

copy
1package screens;
2
3import io.appium.java_client.AppiumDriver;
4import io.appium.java_client.MobileElement;
5import io.appium.java_client.pagefactory.AndroidFindBy;
6import io.appium.java_client.pagefactory.iOSXCUITBy;
7import org.openqa.selenium.support.ui.WebDriverWait;
8
9public class LoginScreen extends PhoneLookupScreen {
10    //   @iOSXCUITBy(xpath = "UsernameTextField")
11    @AndroidFindBy(xpath = "//*[@content-desc=\"username\"]")
12    private MobileElement usernameField;
13
14    //    @iOSXCUITBy(id = "PasswordTextField")
15    @AndroidFindBy(xpath = "//*[@content-desc=\"password\"]")
16    private MobileElement passwordField;
17
18    //    @iOSXCUITBy(id = "SignInButton")
19    @AndroidFindBy(xpath = "//*[@content-desc=\"login\"]/android.widget.Button")
20    private MobileElement signInButton;
21
22    public LoginScreen(AppiumDriver driver, WebDriverWait wait) {
23        super(driver, wait);
24    }
25
26    //    @Step("Enter username")
27    private void enterUserName(String username) {
28        usernameField.clear();
29        usernameField.sendKeys(username);
30        hideKeyboard();
31    }
32
33    //    @Step("Enter password")
34    private void enterPassword(String password) {
35        passwordField.clear();
36        passwordField.sendKeys(password);
37        hideKeyboard();
38    }
39
40    //    @Step("Click SignIn button")
41    private void clickSignIn() {
42        signInButton.click();
43    }
44
45    public void login(String username, String password) throws Exception {
46        enterUserName(username);
47        enterPassword(password);
48        clickSignIn();
49    }
50}
51
Full Screen

HomePage.java

Source: HomePage.java Github

copy
1package com.appium.nativeapppages;
2
3import io.appium.java_client.MobileElement;
4import io.appium.java_client.pagefactory.AndroidFindBy;
5import io.appium.java_client.pagefactory.iOSXCUITBy;
6
7public final class HomePage extends NativeAppBasePage {
8	
9	
10	@AndroidFindBy(xpath="//android.widget.TextView[@text='Views']")
11	@iOSXCUITBy(xpath="//*[text()='somevalue']")
12	private MobileElement views;
13	
14	
15	public ViewsLandingPage clickViews() {
16		click(views);
17		
18		return new ViewsLandingPage();
19	}
20
21}
22
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used methods in iOSXCUITBy

    No methods found for this class 😞

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)