Unable to call out a method using Page Object


#1

Hello,
I have just built two Pages (Launch screen and Sign up screen) and created a test class where I am trying to call out a method from Sign up screen. Getting and error:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1
I am using android real device.
Similar test case works great in a separate class without pointing it to a Page.
here’ Sign up screen:
public class SignUpScreen {
private AppiumDriver driver;
private WebDriverWait wait;

public SignUpScreen(AndroidDriver<AndroidElement>driver){
    this.driver=driver;
    PageFactory.initElements(new AppiumFieldDecorator(driver), this);


}

// //Constructor
// public SignUpScreen(AndroidDriver driver){
// super(driver);
// }

//elements on the screen

@AndroidFindBy(id="signup_input_first_name")
        private AndroidElement Signup_firstname;

@AndroidFindBy(id= "signup_input_last_name")
        private AndroidElement Signgup_lastname;

 @AndroidFindBy(id = "signup_input_email")
         private AndroidElement Signup_email;

@AndroidFindBy(id = "signup_input_password")
private AndroidElement Signup_password;

@AndroidFindBy(id = "signup_input_vin")
private AndroidElement Signup_vin;

@AndroidFindBy(xpath = "\"//android.widget.TextView[@text=\\\"Please enter a first name\\\"]\")")
private AndroidElement Signup_emptyname;

@AndroidFindBy(xpath = "\"//android.widget.TextView[@text=\\\"Please enter a last name\\\"]\")")
private AndroidElement Signup_emptylastname;

@AndroidFindBy(xpath = "\"//android.widget.TextView[@text=\\\"Please enter a valid email address\\\"]\")")
private AndroidElement Signup_invalidemail;

@AndroidFindBy(xpath = "\"//android.widget.TextView[@text=\\\"Please enter a password\\\"]\")")
private AndroidElement Signup_invalidpassw;

@AndroidFindBy(xpath = "\"//android.widget.TextView[@text=\\\"VIN must be 17 characters\\\"]\")")
private AndroidElement Signup_vinLess17chars;

@AndroidFindBy(id = "onboarding_signup_continue_button")
private AndroidElement SignupContinuebtn;

@AndroidFindBy(xpath = "\"//android.widget.TextView[@text=\\\"Already have an account?\\\"]\")")
private AndroidElement Signup_alreadyHaveAccount;

@AndroidFindBy(id= "btn_login")
private AndroidElement loginbtnInSignUp;

@AndroidFindBy(id="onboarding_barcode_button")
private AndroidElement barcodebtn;

@AndroidFindBy(id="text_input_password_toggle")
private AndroidElement showpassword;

@AndroidFindBy(className = "UIAKeyboard")
private AndroidElement keyboard;


//functions for all elements
public boolean isDisplayed(){
    return SignupContinuebtn.isDisplayed();
}

public void clickContinuebtn(){
    SignupContinuebtn.click();
}

public void enterFirstname(String name){
    Signup_firstname.sendKeys(name);
}

public void enterLasname(String lastName){
    Signgup_lastname.sendKeys(lastName);
}

public void enterEmail(String email){
    Signup_email.sendKeys(email);
}

public void enterpassword(String password){
    Signup_password.sendKeys(password);
}

public void enterVin(String vin){
    Signup_vin.sendKeys(vin);
}

public void emptyName(){
    Signup_emptyname.getText();
}

public void emptyLastname(){
    Signup_emptylastname.getText();
}

public void invalidEmail(){
    Signup_invalidemail.getText();
}

public void invalidFormatPassword(){
    Signup_invalidpassw.getText();
}

public void vinLess17Chars(){
    Signup_vinLess17chars.getText();
}

public void continueBtn(){
    SignupContinuebtn.click();
}

public void haveAccountbtn(){
    Signup_alreadyHaveAccount.click();
}

public void loginBtnSignUp(){
    loginbtnInSignUp.click();
}

public void scanbtn(){
    barcodebtn.click();
}

public void togglePassword(){
    showpassword.click();
}



//function to enter all fields in sign up screen
public void signUp(String name,String lastName,String email,String password, String vin ){
    wait = new WebDriverWait(driver, 15);
    enterFirstname(name);
    enterLasname(lastName);
    enterEmail(email);
    enterpassword(password);
    enterVin(vin);
    togglePassword();
    driver.hideKeyboard();
    wait = new WebDriverWait(driver, 15);
    continueBtn();

}

and here’s a test class with all my caps. the following test case fails:
@Test
public void sighUpTest() throws MalformedURLException, InterruptedException{
LaunchScreen launchscreen = new LaunchScreen(driver);
if (!launchscreen.isDisplayed()) {
return;
}

    launchscreen.selectServerCompanion();
    launchscreen.clickSignup();

    SignUpScreen signUpscreen = new SignUpScreen(driver);
    if (!signUpscreen.isDisplayed()) {
        return;
    }

    signUpscreen.signUp("Tanya", "Test", "[email protected]","qa123123", "TOPTESTVINX07TGTI");
    Thread.sleep(3000);




}

#2

@TanyaMTL which is the base class where u r initializing the driver?
In my case I have extended the base class where the driver objects have been initialized and it works fine.
Try Class SignUp extends


#3

I have caps and drivers in this class…no need to extend and other class.
protected AndroidDriver driver;
protected WebDriverWait wait;
private SignUpScreen signUpScreen;
private LaunchScreen launchScreen;

My question is why the fields are not being completed by send.key:
this line fails to run and returns an error
signUpscreen.signUp(NAME, LASTNAME, "[email protected]",PASSWORD, X07_VIN);


#4

What is the error?
Please attach the error it will be helpful for anyone to respond…


#5

it’s actually in the description.


#6

@TanyaMTL not sure for this error may be this is useful to you https://github.com/cglib/cglib/issues/129
Also check this once
https://github.com/appium/java-client/issues/73


#7

@TanyaMTL is POM working at your end?
Using Client 6.1,Appium Server - 1.8
As I had initially kept all my classes under 1 package which is not a good practice as I read
I am a practicing so moved classes under packages created
But Now when I run I get
Driver info: driver.version: unknown at Driver info: driver.version: unknown
at o.appium.java_client.pagefactory.AppiumElementLocator$WaitingFunction.apply(AppiumElementLocator.java:192)
at io.appium.java_client.pagefactory.AppiumElementLocator$WaitingFunction.apply(AppiumElementLocator.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:260)
at io.appium.java_client.pagefactory.AppiumElementLocator.waitFor(AppiumElementLocator.java:99)

Can you share / advise how did you structure ur class for reference.?