Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nativeapp.mobiledriver.page.mtv;
- import java.util.List;
- import org.apache.log4j.Logger;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import com.appium.driver.AppiumDriver;
- import com.appium.driver.annotation.AndroidFindBy;
- import com.appium.driver.annotation.IOSFindBy;
- import com.google.inject.Inject;
- import com.nativeapp.mobiledriver.page.PageWithProxy;
- import com.nativeapp.mobiledriver.page.exception.ViewNotFoundException;
- import com.nativeapp.mobiledriver.page.mtv.interf.IMTVSearchPage;
- import com.nativeapp.mobiledriver.wait.MobileWait;
- import com.nativeapp.tests.utils.ExpectedConditions;
- import com.selenium.element.impl.AppiumElement;
- public class MTVHomePage extends PageWithProxy {
- @IOSFindBy(xpath = "//UIAApplication[1]/UIAWindow[1]/UIACollectionView[1]")
- @AndroidFindBy(id = "content")
- private AppiumElement collectionView;
- @IOSFindBy(xpath = "//UIAApplication[1]/UIAWindow[1]/UIAButton[2]")
- @AndroidFindBy(id = "search_button")
- private AppiumElement searchButton;
- @IOSFindBy(xpath = "//UIAApplication[1]/UIAWindow[1]/UIAStaticText[@name='browse' or @name='BROWSE']")
- @AndroidFindBy(xpath = "//")
- private AppiumElement browseButton;
- @IOSFindBy(xpath = "//UIAApplication[1]/UIAWindow[1]/UIACollectionView[1]/UIACollectionCell/UIAStaticText[contains(@name, 'live') or contains(@name, 'LIVE')]")
- @AndroidFindBy(xpath = "//")
- private AppiumElement liveVideo;
- @IOSFindBy(xpath = "//UIAApplication[1]/UIAWindow[1]/UIAButton[1]")
- @AndroidFindBy(xpath = "//")
- private AppiumElement closePromoBtn;
- @IOSFindBy(xpath = "//UIAApplication[1]/UIAWindow[1]/UIAImage[1]")
- @AndroidFindBy(xpath = "//")
- private AppiumElement promoImage;
- private By settingsButton = By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton");
- private static final Logger LOGGER = Logger.getLogger(MTVHomePage.class);
- private WebDriver driver;
- @Inject
- private MTVLoginPage loginPage;
- @Inject
- private IMTVSearchPage searchPage;
- @Inject
- private MTVBrowsePage browsePage;
- public MTVHomePage(WebDriver driver) {
- this.driver = driver;
- }
- @Override
- public void checkPage() {
- new MobileWait(driver, 30).until(ExpectedConditions.isVisible(collectionView), ViewNotFoundException.class,
- "Home page is not loaded.");
- }
- public MTVLoginPage openSettings() {
- List<WebElement> buttons = driver.findElements(settingsButton);
- buttons.get(buttons.size() - 1).click();
- loginPage.checkPage();
- return loginPage;
- }
- public IMTVSearchPage openSearch() {
- searchPage.openSearchPage();
- return searchPage;
- }
- public MTVBrowsePage openBrowsePage() {
- browseButton.click();
- return browsePage;
- }
- //.cells().staticText.withPredicate(\"name=='watch live'\")"
- public void openLiveVideo() {
- ((AppiumDriver)driver).findElement("target.frontMostApp().mainWindow().collectionViews()[0].cells().withPredicate(\"name=='2015 movie awards'\")");
- ((AppiumDriver)driver).findElement("target.frontMostApp().mainWindow().collectionViews()[0].cells()[\"watch live\"]").click();
- ((AppiumDriver)driver).findElements(".collectionViews()[0].cells()");
- ((AppiumDriver)driver).findElements("target.frontMostApp().mainWindow().collectionViews()[0].staticTexts()");
- System.out.println(driver.getPageSource());
- // liveVideo.click();
- }
- public void closePromotionPopup() {
- if (promoImage.isDisplayed()) {
- LOGGER.info("Close promotion popup");
- closePromoBtn.click();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement