Skip to content

Commit

Permalink
#30 Page objects
Browse files Browse the repository at this point in the history
Next steps are:
- tp implement sample of tests
- to add comments.
  • Loading branch information
TikhomirovSergey committed Feb 27, 2015
1 parent 722b9dd commit 621333d
Show file tree
Hide file tree
Showing 4 changed files with 251 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.saucelabs.appium.page_object.android;

import io.appium.java_client.MobileElement;

import java.util.List;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.pagefactory.AndroidFindAll;
import io.appium.java_client.pagefactory.AndroidFindBy;

public class ApiDemosListViewScreenByAllPossible {

@AndroidFindAll({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/Fakecontent\")"),
@AndroidFindBy(id = "android:id/Faketext1"),
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"), //by this locator element is found
@AndroidFindBy(id = "android:id/FakeId")
})
public List<MobileElement> findAllElementViews;

@AndroidFindAll({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/Fakecontent\")"),
@AndroidFindBy(id = "android:id/Faketext1"),
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"), //by this locator element is found
@AndroidFindBy(id = "android:id/FakeId")
})
public AndroidElement findAllElementView;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.saucelabs.appium.page_object.android;

import io.appium.java_client.android.AndroidElement;
import java.util.List;
import org.openqa.selenium.WebElement;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.AndroidFindBys;
import io.appium.java_client.pagefactory.iOSFindBy;
import io.appium.java_client.pagefactory.iOSFindBys;

public class ApiDemosListViewScreenChaided {


@AndroidFindBys({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidFindBy(className = "android.widget.TextView")
})
public List<WebElement> chainElementViews;

@AndroidFindBys({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")"),
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidFindBy(id = "android:id/text1")
})
@iOSFindBys({@iOSFindBy(uiAutomator = ".elements()[0]"),
@iOSFindBy(xpath = "//someElement")})
public List<WebElement> chainAndroidOrIOSUIAutomatorViews;


@AndroidFindBys({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidFindBy(className = "android.widget.TextView")
})
public WebElement chainElementView;


@AndroidFindBys({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")"),
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidFindBy(id = "android:id/text1")
})
@iOSFindBys({@iOSFindBy(uiAutomator = ".elements()[0]"),
@iOSFindBy(xpath = "//someElement")})
public WebElement chainAndroidOrIOSUIAutomatorView;

@AndroidFindBys({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")"),
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidFindBy(id = "android:id/text1")
})
public AndroidElement androidElementView;

@AndroidFindBys({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")"),
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidFindBy(id = "android:id/text1")
})
public List<AndroidElement> androidElementViews;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.saucelabs.appium.page_object.android;

import io.appium.java_client.MobileElement;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.iOSFindBy;

import java.util.List;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.support.FindBy;

public class ApiDemosListViewScreenSimple {

@FindBy(className = "android.widget.TextView")
public List<WebElement> textVieWs;

@AndroidFindBy(className = "android.widget.TextView")
public List<WebElement> androidTextViews;

@iOSFindBy(uiAutomator = ".elements()[0]")
public List<WebElement> iosTextViews;

@iOSFindBy(uiAutomator = ".elements()[0]")
@AndroidFindBy(className = "android.widget.TextView")
public List<WebElement> androidOriOsTextViews;

@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
public List<WebElement> androidUIAutomatorViews;

@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
public List<MobileElement> mobileElementViews;

@FindBy(className = "android.widget.TextView")
public List<MobileElement> mobiletextVieWs;

@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
public List<RemoteWebElement> remoteElementViews;

@FindBy(id = "android:id/text1")
public WebElement textView;

@AndroidFindBy(className = "android.widget.TextView")
public WebElement androidTextView;

@iOSFindBy(uiAutomator = ".elements()[0]")
public WebElement iosTextView;

@AndroidFindBy(className = "android.widget.TextView")
@iOSFindBy(uiAutomator = ".elements()[0]")
public WebElement androidOriOsTextView;

@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
public WebElement androidUIAutomatorView;

@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
public MobileElement mobileElementView;

@FindBy(className = "android.widget.TextView")
public MobileElement mobiletextVieW;

@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
public RemoteWebElement remotetextVieW;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package com.saucelabs.appium.page_object.ios;

import io.appium.java_client.MobileElement;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.iOSFindBy;

import java.util.List;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.support.FindBy;

import io.appium.java_client.pagefactory.AndroidFindBys;
import io.appium.java_client.pagefactory.iOSFindAll;;

public class UICatalogScreenSimple {

@FindBy(className = "UIAButton")
public List<WebElement> uiButtons;

@FindBy(className = "UIAButton")
public List<WebElement> iosUIButtons;

@iOSFindBy(uiAutomator = ".elements()[0]")
public List<WebElement> iosUIAutomatorButtons;

@iOSFindBy(uiAutomator = ".elements()[0]")
@AndroidFindBy(className = "android.widget.TextView")
public List<WebElement> androidOriOsTextViews;

@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
public List<WebElement> androidUIAutomatorViews;

@iOSFindBy(uiAutomator = ".elements()[0]")
public List<MobileElement> mobileButtons;

@FindBy(className = "UIAButton")
public List<MobileElement> mobiletFindBy_Buttons;

@iOSFindBy(uiAutomator = ".elements()[0]")
public List<RemoteWebElement> remoteElementViews;

@AndroidFindBys({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidFindBy(className = "android.widget.TextView")
})
public List<WebElement> chainElementViews;


@FindBy(className = "UIAButton")
public WebElement uiButton;

@FindBy(className = "UIAButton")
public WebElement iosUIButton;

@iOSFindBy(uiAutomator = ".elements()[0]")
public WebElement iosUIAutomatorButton;

@AndroidFindBy(className = "android.widget.TextView")
@iOSFindBy(uiAutomator = ".elements()[0]")
public WebElement androidOriOsTextView;

@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
public WebElement androidUIAutomatorView;

@iOSFindBy(uiAutomator = ".elements()[0]")
public MobileElement mobileButton;

@FindBy(className = "UIAButton")
public MobileElement mobiletFindBy_Button;

@iOSFindBy(uiAutomator = ".elements()[0]")
public RemoteWebElement remotetextVieW;

@AndroidFindBys({
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
@AndroidFindBy(className = "android.widget.TextView")
})
public WebElement chainElementView;

@iOSFindBy(uiAutomator = ".elements()[0]")
public IOSElement iosButton;

@iOSFindBy(uiAutomator = ".elements()[0]")
public List<IOSElement> iosButtons;

@iOSFindAll({
@iOSFindBy(xpath = "ComputeSumButton_Test"),
@iOSFindBy(name = "ComputeSumButton") //it is real locator
})
public WebElement findAllElement;

@iOSFindAll({
@iOSFindBy(xpath = "ComputeSumButton_Test"),
@iOSFindBy(name = "ComputeSumButton") //it is real locator
})
public List<WebElement> findAllElements;

}

0 comments on commit 621333d

Please sign in to comment.