Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98221

how to call mobile elements from a different class in appium page object model (Giving null pointer exception) [closed]

$
0
0

I am trying to implement page object model for appium suite. But it is throwing null pointer exception. I have made 3 classes one will start the app, other have mobile elements and functions defined and third one is defined here.

package AppiumTest.AppiumTest17th;

import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import appiumTestInitialize.AppiumTest;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;

public class CalculatorTest extends AppiumTest {
    public CalculatorTestElements testElements;

    @BeforeClass(alwaysRun=true)
    public void initElementsBeforeClass() {

        //  testElements = PageFactory.initElements(driver, CalculatorTestElements.class);
        PageFactory.initElements(new AppiumFieldDecorator(driver), CalculatorTestElements.class);
        //System.out.println("#### Current URL ###### " + driver.getCurrentUrl());
    }

    @Test(priority = 1, /*groups={"preProdSanity","prodSanity","regression"},*/ description = "Login to wikipedia App.\n"
            + "1. Click on menu button.\n"
            + "2. Click on logon button.\n"
            + "3. Enter username.\n"
            + "4. Enter password.\n"
            + "5. Click on login button.\n"
            + "6. Validate if login is success.")
    public void validate_login_to_wikipedia_app() throws InterruptedException {
        System.out.println("##### Current Function ####### " + new CalculatorTest() {
        }.getClass().getEnclosingMethod().getName() + "()");
        System.out.println("Hi Keshav");
        testElements
            .click_menu_overflow_button();

    }
}

Viewing all articles
Browse latest Browse all 98221

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>