Reputation: 1
Hi all!
I've been having the next issue: I'm trying to use PageFactory in my appium project, but haven't been able.
public class LoginPageObjects {
AppiumDriver driver;
@AndroidFindBy(id = "username")
public WebElement username;
@AndroidFindBy(id = "password")
public WebElement passwordElement;
@AndroidFindBy(xpath = "//android.view.ViewGroup[@content-desc=\"loginBtn\"]/android.widget.TextView\n")
public WebElement buttonElement;
public LoginPageObjects(AppiumDriver driver){
this.driver = driver;
PageFactory.initElements(driver,this);
}
public void setUsernameTextBox(String text){
username.sendKeys(text);
}
public void setPasswordTextBox(String text){
passwordElement.sendKeys(text);
}
public void clickLoginButton() {
passwordElement.click();
}
}
It's not working this way, having the following error calling username.sendKeys():
Unsupported CSS selector '*[name='username']'. Reason: 'Error: 'name' is not a valid attribute.
where I have also tried
PageFactory.initElements(new AppiumFieldDecorator(driver),this);
But this throws a new error
Currently using:
io.appium 8.0.0; org.seleniumhq.selenium 4.1.3; JDK v18
Pst: PageFactory in Selenium with the same versions is working fine.
Upvotes: 0
Views: 406