1 package androidtest
.models
;
5 import io
.appium
.java_client
.android
.AndroidDriver
;
6 import io
.appium
.java_client
.android
.AndroidElement
;
7 import io
.appium
.java_client
.android
.AndroidKeyCode
;
8 import io
.appium
.java_client
.pagefactory
.AndroidFindBy
;
9 import io
.appium
.java_client
.pagefactory
.AppiumFieldDecorator
;
11 import org
.openqa
.selenium
.NoSuchElementException
;
12 import org
.openqa
.selenium
.support
.CacheLookup
;
13 import org
.openqa
.selenium
.support
.PageFactory
;
15 import org
.openqa
.selenium
.Point
;
16 import androidtest
.actions
.Actions
;
18 public class MainView
{
19 final AndroidDriver driver
;
21 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"More options\")")
22 private AndroidElement menuButton
;
25 @AndroidFindBy(id
= "com.owncloud.android:id/list_root")
26 private AndroidElement filesLayout
;
29 @AndroidFindBy(uiAutomator
= "new UiSelector().resourceId(\"android:id/action_bar_title\")")
30 private AndroidElement titleText
;
32 @AndroidFindBy(id
= "android:id/progress_circular")
33 private AndroidElement progressCircular
;
36 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"New folder\")")
37 private AndroidElement newFolderButton
;
40 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"Upload\")")
41 private AndroidElement uploadButton
;
43 private AndroidElement waitAMomentText
;
45 @AndroidFindBy(id
= "com.owncloud.android:id/ListItemLayout")
46 private List
<AndroidElement
> listItemLayout
;
48 @AndroidFindBy(id
= "com.owncloud.android:id/list_root")
49 private AndroidElement listRootLayout
;
51 @AndroidFindBy(name
= "Files")
52 private AndroidElement filesElementUploadFile
;
55 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"List Layout\")")
56 private AndroidElement listLayout
;
58 private AndroidElement fileElement
;
60 private AndroidElement fileElementLayout
;
62 private static String localFileIndicator
= "com.owncloud.android:id/localFileIndicator";
63 private static String favoriteFileIndicator
= "com.owncloud.android:id/favoriteIcon";
66 public MainView (AndroidDriver driver
) {
68 PageFactory
.initElements(new AppiumFieldDecorator(driver
), this);
71 public MenuList
clickOnMenuButton () {
72 //if the menu option is not in the actionBar, it is opening again
75 } catch (NoSuchElementException e
){
76 driver
.sendKeyEvent(AndroidKeyCode
.MENU
);
78 MenuList menuList
= new MenuList (driver
);
82 public SettingsView
getSettingsView () {
83 SettingsView settingsView
= new SettingsView(driver
);
87 public NewFolderPopUp
clickOnNewFolderButton () {
88 newFolderButton
.click();
89 NewFolderPopUp newFolderPopUp
= new NewFolderPopUp(driver
);
90 return newFolderPopUp
;
93 public void clickOnUploadButton () {
97 public FilesView
clickOnFilesElementUploadFile () {
98 filesElementUploadFile
.click();
99 FilesView filesView
= new FilesView(driver
);
103 public AndroidElement
getTitleTextElement () {
107 public AndroidElement
getUploadButton () {
111 public AndroidElement
getWaitAMomentTextElement () {
112 return waitAMomentText
;
115 public AndroidElement
getListRootElement () {
116 return listRootLayout
;
119 public List
<AndroidElement
> getListItemLayout () {
120 return listItemLayout
;
123 public AndroidElement
getFileElement () {
127 public ElementMenuOptions
longPressOnElement (String elementName
) {
128 scrollTillFindElement(elementName
).tap(1, 1000);
129 //fileElement.tap(1, 1000);
130 ElementMenuOptions menuOptions
= new ElementMenuOptions(driver
);
134 public AndroidElement
scrollTillFindElement (String elementName
) {
135 fileElement
= Actions
.scrollTillFindElement (elementName
,filesLayout
,driver
);
137 fileElementLayout
= (AndroidElement
) driver
.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ elementName
+"\")");
138 } catch (NoSuchElementException e
) {
139 fileElementLayout
= null
;
144 public AndroidElement
getFileElementLayout () {
145 return fileElementLayout
;
148 public AndroidElement
getProgressCircular () {
149 return progressCircular
;
152 public static String
getLocalFileIndicator() {
153 return localFileIndicator
;
156 public static String
getFavoriteFileIndicator() {
157 return favoriteFileIndicator
;
160 public void pulldownToRefresh () throws InterruptedException
{
161 Point listLocation
= listLayout
.getLocation();
162 driver
.swipe(listLocation
.getX(),listLocation
.getY(), listLocation
.getX(),listLocation
.getY()+1000, 5000);