1 package androidtest
.models
;
3 import org
.openqa
.selenium
.support
.CacheLookup
;
4 import org
.openqa
.selenium
.support
.PageFactory
;
5 import io
.appium
.java_client
.android
.AndroidDriver
;
6 import io
.appium
.java_client
.android
.AndroidElement
;
7 import io
.appium
.java_client
.pagefactory
.AndroidFindBy
;
8 import io
.appium
.java_client
.pagefactory
.AppiumFieldDecorator
;
10 public class LoginForm
{
11 final AndroidDriver driver
;
14 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"Server address\")")
15 private AndroidElement hostUrlInput
;
18 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"Username\")")
19 private AndroidElement userNameInput
;
22 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"Password\")")
23 private AndroidElement passwordInput
;
26 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"Connect\")")
27 private AndroidElement connectButton
;
29 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"Testing connection\")")
30 private AndroidElement serverStatusText
;
32 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"Wrong username or password\")")
33 private AndroidElement authStatusText
;
35 public LoginForm (AndroidDriver driver
) {
37 PageFactory
.initElements(new AppiumFieldDecorator(driver
), this);
40 public void typeHostUrl (String hostUrl
) {
42 hostUrlInput
.sendKeys(hostUrl
);
43 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
46 public void clickOnUserName () {
47 userNameInput
.click();
50 public void typeUserName (String userName
) {
51 userNameInput
.clear();
52 userNameInput
.sendKeys(userName
);
53 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
56 public void typePassword (String password
) {
57 passwordInput
.clear();
58 passwordInput
.sendKeys(password
);
59 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
62 public MainView
clickOnConnectButton () {
63 connectButton
.click();
64 MainView mainView
= new MainView(driver
);
68 public AndroidElement
getServerStatusTextElement () {
69 return serverStatusText
;
72 public AndroidElement
getAuthStatusText () {
73 return authStatusText
;