@BeforeMethod(alwaysRun = true)
  public void prepareURL() {
    String articleUrl = urlBuilder.getWebUrlForPath(Configuration.getWikiName(), ARTICLE_NAME);
    url = urlBuilder.appendQueryStringToURL(articleUrl, QUERY_STRING);

    String expectedArticleUrl = urlBuilder.getUrlForPath(Configuration.getWikiName(), ARTICLE_NAME);
    expectedUrl = urlBuilder.appendQueryStringToURL(expectedArticleUrl, QUERY_STRING);
  }
  @Override
  public void onStart(ITestContext context) {
    CommonUtils.createDirectory(screenDirPath);
    imageCounter = 0;
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    Date date = new Date();

    StringBuilder builder = new StringBuilder();
    builder.append(
        "<html><style>"
            + "table {margin:0 auto;}td:first-child {width:200px;}td:nth-child(2) {width:660px;}td:nth-child(3) "
            + "{width:100px;}tr.success{color:black;background-color:#CCFFCC;}"
            + "tr.warning{color:black;background-color:#FEE01E;}"
            + "tr.error{color:black;background-color:#FFCCCC;}"
            + "tr.step{color:white;background:grey}"
            + "</style><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">"
            + "<style>td { border-top: 1px solid grey; } </style></head><body>"
            + "<script type=\"text/javascript\" src=\"http://code.jquery.com/jquery-1.8.2.min.js\"></script>"
            + "<p>Date: "
            + DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZZ")
                .print(DateTime.now(DateTimeZone.UTC))
            + "</p>"
            + "<p>Polish Time: "
            + DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss ZZ")
                .print(
                    DateTime.now()
                        .withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("Europe/Warsaw"))))
            + "</p>"
            + "<p>Browser: "
            + Configuration.getBrowser()
            + "</p>"
            + "<p>OS: "
            + System.getProperty("os.name")
            + "</p>"
            + "<p>Testing environment: "
            + new UrlBuilder().getUrlForWiki(Configuration.getWikiName())
            + "</p>"
            + "<p>Testing environment: "
            + Configuration.getEnv()
            + "</p>"
            + "<p>Tested version: "
            + "TO DO: GET WIKI VERSION HERE"
            + "</p>"
            + "<div id='toc'></div>");
    CommonUtils.appendTextToFile(logPath, builder.toString());
    appendShowHideButtons();
    try {
      FileInputStream input = new FileInputStream("./src/test/resources/script.txt");
      String content = IOUtils.toString(input);
      CommonUtils.appendTextToFile(logPath, content);
    } catch (IOException e) {
      System.out.println("no script.txt file available");
    }
  }
 @Test(
     groups = {"MercuryLoginTest_011"},
     enabled = false)
 @Execute(onWikia = "mercuryautomationtesting")
 public void MercuryLoginTest_011_japaneseUserLogIn() {
   LoginPageObject loginPageObject = new LoginPageObject(driver).get();
   loginPageObject.logUserIn(
       Configuration.getCredentials().userNameJapanese2,
       Configuration.getCredentials().passwordJapanese2);
   Assertion.assertTrue(
       loginPageObject.getNav().isUserLoggedIn(Configuration.getCredentials().userNameJapanese2));
 }
  @Test
  public void connectedUserCanLogInToWikiaByGoogle() {
    GoogleConnectPage googleConnectPage = new GoogleConnectPage(driver).open();

    googleConnectPage.signInWithGoogleAccount(
        Configuration.getCredentials().emailQaart4,
        Configuration.getCredentials().emailPasswordQaart4);

    Assertion.assertTrue(googleConnectPage.isUserLoggedIn());

    new ArticlePageObject(driver).open().verifyUserLoggedIn(User.GOOGLE_CONNECTED);
  }
  private static EventFiringWebDriver getAndroidInstance() {
    DesiredCapabilities destCaps = new DesiredCapabilities();
    destCaps.setCapability("deviceName", Configuration.getDeviceName());
    URL url = null;
    try {
      url = new URL("http://" + Configuration.getAppiumIp() + "/wd/hub");
    } catch (MalformedURLException e) {
      PageObjectLogging.log("getAndroindInstance", e, false);
    }
    mobileDriver = new AndroidDriver(url, destCaps);

    return new EventFiringWebDriver(mobileDriver);
  }
  private static EventFiringWebDriver getChromeInstance() {
    String chromeBinaryPath = "";
    String osName = System.getProperty("os.name").toUpperCase();

    if (osName.contains("WINDOWS")) {
      chromeBinaryPath = "/chromedriver_win32/chromedriver.exe";
    } else if (osName.contains("MAC")) {
      chromeBinaryPath = "/chromedriver_mac32/chromedriver";

      File chromedriver =
          new File(ClassLoader.getSystemResource("ChromeDriver" + chromeBinaryPath).getPath());

      // set application user permissions to 455
      chromedriver.setExecutable(true);
    } else if (osName.contains("LINUX")) {
      chromeBinaryPath = "/chromedriver_linux64/chromedriver";

      File chromedriver =
          new File(ClassLoader.getSystemResource("ChromeDriver" + chromeBinaryPath).getPath());

      // set application user permissions to 455
      chromedriver.setExecutable(true);
    }

    System.setProperty(
        "webdriver.chrome.driver",
        new File(ClassLoader.getSystemResource("ChromeDriver" + chromeBinaryPath).getPath())
            .getPath());

    // TODO change mobile tests to use @UserAgent annotation
    if ("CHROMEMOBILEMERCURY".equals(browserName)) {
      chromeOptions.addArguments("--user-agent=" + userAgentRegistry.getUserAgent("iPhone"));
    }

    //    chromeOptions.addArguments("user-data-dir="
    //        + ClassLoader.getSystemResource("ChromeProfiles/default/").getPath().substring(1));

    if ("true".equals(Configuration.getDisableFlash())) {
      chromeOptions.addArguments("disable-bundled-ppapi-flash");
      chromeOptions.addArguments("process-per-site");
      chromeOptions.addArguments("start-maximized");
    }

    caps.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

    setBrowserLogging(Level.SEVERE);

    ExtHelper.addExtensions(Configuration.getExtensions());

    return new EventFiringWebDriver(new ChromeDriver(caps));
  }
  @Test(groups = {"MercuryLoginTest_005"})
  @Execute(onWikia = "mercuryautomationtesting")
  public void MercuryLoginTest_005_notPossibleToLogInWhenPasswordFieldBlank() {
    LoginPageObject loginPageObject = new LoginPageObject(driver).get();
    loginPageObject.logUserIn(Configuration.getCredentials().userName10, "");

    Assertion.assertTrue(loginPageObject.isSubmitButtonDisabled(2));
  }
  @Test(groups = {"MercuryLoginTest_002"})
  @Execute(onWikia = "mercuryautomationtesting")
  public void MercuryLoginTest_002_userCanNotLogInWithWrongPassword() {
    LoginPageObject loginPageObject = new LoginPageObject(driver).get();
    loginPageObject.logUserIn(Configuration.getCredentials().userName10, "thisIsWrongPassword");

    Assertion.assertEquals(loginPageObject.getErrorMessage(), ERROR_MESSAGE);
  }
  @Test(groups = {"MercuryLoginTest_003"})
  @Execute(onWikia = "mercuryautomationtesting")
  public void MercuryLoginTest_003_invalidUserCanNotLogIn() {
    LoginPageObject loginPageObject = new LoginPageObject(driver).get();
    loginPageObject.logUserIn("notExistingUserName", Configuration.getCredentials().password10);

    Assertion.assertEquals(loginPageObject.getErrorMessage(), ERROR_MESSAGE);
  }
  @Test(groups = "TestUrlBuilder")
  public void appendQueryString() {
    String cb = "cb=1111";
    Configuration.setTestValue("qs", cb);

    Assertion.assertEquals(
        new UrlBuilder("prod").getUrlForPath("wowwiki", "Portal:Main"),
        "http://wowwiki.wikia.com/Portal:Main?" + cb);
  }
 public void logOut(WebDriver driver) {
   try {
     driver.manage().deleteAllCookies();
     driver.get(urlBuilder.getUrlForWiki(Configuration.getWikiName()) + URLsContent.LOGOUT);
   } catch (TimeoutException e) {
     PageObjectLogging.log("logOut", "page loads for more than 30 seconds", true);
   }
   waitForElementPresenceByBy(LOGIN_BUTTON_CSS);
   PageObjectLogging.log("logOut", "user is logged out", true, driver);
 }
Esempio n. 12
0
  public GeoEdgeUtils() {
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    try {
      DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
      doc = docBuilder.parse(Configuration.getCredentialsFilePath());
    } catch (ParserConfigurationException | SAXException | IOException ex) {
      throw new WebDriverException(ex);
    }

    setIPsForCountries();
  }
Esempio n. 13
0
  @Test(
      groups = {"MercuryLoginTest_001"},
      enabled = false)
  @Execute(onWikia = "mercuryautomationtesting")
  public void MercuryLoginTest_001_validUserCanLogIn() {
    NavigationSideComponentObject nav = new NavigationSideComponentObject(driver);

    nav.navigateToUrlWithPath(wikiURL, "Map");
    String url = driver.getCurrentUrl();
    new TopBarComponentObject(driver).clickLogInIcon();
    new LoginPageObject(driver)
        .clickOnSignInButton()
        .logUserIn(
            Configuration.getCredentials().userName10, Configuration.getCredentials().password10);

    new ArticlePageObject(driver).waitForFooterToBeVisible();
    boolean result = url.equals(driver.getCurrentUrl());
    PageObjectLogging.log("url", "was redirected correctly", result);

    Assertion.assertTrue(nav.isUserLoggedIn(Configuration.getCredentials().userName10));
  }
 private static void logJSError(WebDriver driver) {
   if ("true".equals(Configuration.getJSErrorsEnabled())) {
     JavascriptExecutor js = (JavascriptExecutor) driver;
     List<String> error =
         (ArrayList<String>) js.executeScript("return window.JSErrorCollector_errors.pump()");
     if (!error.isEmpty()) {
       StringBuilder builder = new StringBuilder();
       builder.append(
           "<tr class=\"error\"><td>click</td><td>" + error + "</td><td> <br/> &nbsp;</td></tr>");
       CommonUtils.appendTextToFile(logPath, builder.toString());
     }
   }
 }
Esempio n. 15
0
  @Test(groups = {"MercuryLoginTest_012"})
  @Execute(onWikia = "mercuryautomationtesting")
  public void MercuryLoginTest_012_passwordTogglerWorks() {
    LoginPageObject loginPageObject = new LoginPageObject(driver).get();
    loginPageObject.typePassword(Configuration.getCredentials().password10);

    Assertion.assertTrue(
        loginPageObject.isPasswordTogglerDisabled(), "password should be disabled");

    loginPageObject.clickOnPasswordToggler();

    Assertion.assertTrue(loginPageObject.isPasswordTogglerEnabled(), "password should be enabled");
  }
/*
 * Check for facebook button on the page
 */
public class FacebookButtonTests extends NewTestTemplate {

  Credentials credentials = Configuration.getCredentials();

  @Test(groups = {"FBButton_001", "FacebookButton"})
  public void FBButton_001_DropDownButton_Visible() {
    DropDownComponentObject dropDown = new DropDownComponentObject(driver);
    dropDown.openDropDown();
    dropDown.verifyDropDownFBButtonVisible();
  }

  @Test(groups = {"FBButton_002", "FacebookButton"})
  public void FBButton_002_SignUpButton_Visible() {
    WikiBasePageObject base = new WikiBasePageObject(driver);
    SignUpPageObject signUpPage = base.openSpecialSignUpPage(wikiURL);
    signUpPage.verifyFBButtonVisible();
  }

  @Test(groups = {"FBButton_003", "FacebookButton"})
  public void FBButton_003_LoginButton_Visible() {
    WikiBasePageObject base = new WikiBasePageObject(driver);
    SpecialUserLoginPageObject login = base.openSpecialUserLogin(wikiURL);
    login.verifyFBButtonVisible();
  }

  @Test(groups = {"FBButton_004", "FacebookButton"})
  public void FBButton_004_ForcedLoginButton_Visible() {
    WikiBasePageObject base = new WikiBasePageObject(driver);
    SpecialNewFilesPageObject specialPage = base.openSpecialNewFiles(wikiURL);
    specialPage.verifySpecialPage();
    specialPage.addPhoto();
    specialPage.verifyModalLoginAppeared();
    specialPage.verifyModalFBButtonVisible();
  }

  @Test(groups = {"FBButton_005", "FacebookButton"})
  @Execute(asUser = User.USER)
  public void FBButton_005_PrefsButton_Visible() {
    WikiBasePageObject base = new WikiBasePageObject(driver);
    PreferencesPageObject prefsPage = base.openSpecialPreferencesPage(wikiURL);
    prefsPage.selectTab(tabNames.FACEBOOK);
    prefsPage.verifyFBButtonVisible();
  }
}
  @Override
  public void onTestFailure(ITestResult result) {
    driver = NewDriverProvider.getWebDriver();
    if (driver == null) {
      driver = NewDriverProvider.getWebDriver();
    }

    imageCounter += 1;
    if ("true".equals(Configuration.getLogEnabled())) {
      try {
        new Shooter().savePageScreenshot(screenPath + imageCounter, driver);
        CommonUtils.appendTextToFile(screenPath + imageCounter + ".html", getPageSource(driver));
      } catch (Exception e) {
        log(
            "onException",
            "driver has no ability to catch screenshot or html source - driver may died",
            false);
      }

      String exception =
          escapeHtml(
              result.getThrowable().toString()
                  + "\n"
                  + ExceptionUtils.getStackTrace(result.getThrowable()));

      StringBuilder builder = new StringBuilder();
      builder.append(
          "<tr class=\"error\"><td>error</td><td><pre>"
              + exception
              + "</pre></td><td> <br/><a href='screenshots/screenshot"
              + imageCounter
              + ".png'>Screenshot</a><br/><a href='screenshots/screenshot"
              + imageCounter
              + ".html'>HTML Source</a></td></tr>");
      CommonUtils.appendTextToFile(logPath, builder.toString());
      logJSError(driver);
      onTestSuccess(result);
    }
  }
  @Test(groups = "TestUrlBuilder")
  public void urlBuilder() {
    Configuration.setTestValue("qs", "");

    for (Object[] data : TEST_DATA) {
      Assertion.assertEquals(
          new UrlBuilder("prod").getUrlForPath((String) data[0], (String) data[1]),
          (String) data[2]);
      Assertion.assertEquals(
          new UrlBuilder("preview").getUrlForPath((String) data[0], (String) data[1]),
          (String) data[3]);
      Assertion.assertEquals(
          new UrlBuilder("sandbox").getUrlForPath((String) data[0], (String) data[1]),
          (String) data[4]);
      Assertion.assertEquals(
          new UrlBuilder("sandbox-mercurydev").getUrlForPath((String) data[0], (String) data[1]),
          (String) data[5]);
      Assertion.assertEquals(
          new UrlBuilder("dev-dmytror").getUrlForPath((String) data[0], (String) data[1]),
          (String) data[6]);
    }
  }
public class CuratedContentTests extends NewTestTemplate {

  private static final String CATEGORY = URLsContent.CATEGORY_HELP;
  private static final String LABEL = PageContent.LOREM_IPSUM_SHORT;

  Credentials credentials = Configuration.getCredentials();

  @Test(groups = {"CuratedContent001", "CuratedContent"})
  public void curatedContent001_saveWithoutImage() {
    WikiBasePageObject base = new WikiBasePageObject(driver);
    base.loginAs(credentials.userNameStaff, credentials.passwordStaff, wikiURL);
    SpecialCuratedContentPageObject cc = base.openSpecialCuratedContent(wikiURL);
    // add new element without image
    cc.addNewElement(CATEGORY, LABEL);
    // verify error message and save button not clickable
    cc.verifyImageErrorInLastElement();
    cc.verifySaveNotClickable();
  }

  @Test(groups = {"CuratedContent002", "CuratedContent"})
  public void curatedContent002_saveWithImage() {
    WikiBasePageObject base = new WikiBasePageObject(driver);
    base.loginAs(credentials.userNameStaff, credentials.passwordStaff, wikiURL);
    SpecialCuratedContentPageObject cc = base.openSpecialCuratedContent(wikiURL);
    // add new element and add image to that element
    cc.addNewElement(CATEGORY, LABEL);
    PhotoAddComponentObject addPhotoModal = cc.clickImageOnLastElement();
    addPhotoModal.clickAddThisPhoto(1);
    cc.verifyImageInLastElement();
    cc.clickSave();
    cc.verifySuccesfulSave();
    // clean the added element
    cc.removeLastElement();
    cc.clickSave();
    cc.verifySuccesfulSave();
  }
}
 public void openRegisterPage() {
   driver.get(urlBuilder.getUrlForWiki(Configuration.getWikiName()) + "register");
 }
  private static EventFiringWebDriver getFFInstance() {
    // Windows 8 requires to set webdriver.firefox.bin system variable
    // to path where executive file of FF is placed
    if ("WINDOWS 8".equalsIgnoreCase(System.getProperty("os.name"))) {
      System.setProperty(
          "webdriver.firefox.bin",
          "c:"
              + File.separator
              + "Program Files (x86)"
              + File.separator
              + "Mozilla Firefox"
              + File.separator
              + "Firefox.exe");
    }

    // Check if user who is running tests have write access in ~/.mozilla dir and home dir
    if ("LINUX".equals(System.getProperty("os.name").toUpperCase())) {
      File homePath = new File(System.getenv("HOME") + File.separator);
      File mozillaPath = new File(homePath + File.separator + ".mozilla");
      File tmpFile;
      if (mozillaPath.exists()) {
        try {
          tmpFile = File.createTempFile("webdriver", null, mozillaPath);
        } catch (IOException ex) {
          PageObjectLogging.log("Can't create file", ex, false);
          throw new WebDriverException(
              "Can't create file in path: %s".replace("%s", mozillaPath.getAbsolutePath()));
        }
      } else {
        try {
          tmpFile = File.createTempFile("webdriver", null, homePath);
        } catch (IOException ex) {
          PageObjectLogging.log("Can't create file", ex, false);
          throw new WebDriverException(
              "Can't create file in path: %s".replace("%s", homePath.getAbsolutePath()));
        }
      }
      tmpFile.delete();
    }

    firefoxProfile =
        new FirefoxProfile(
            new File(ClassLoader.getSystemResource("FirefoxProfiles/Default").getPath()));

    if (unstablePageLoadStrategy) {
      firefoxProfile.setPreference("webdriver.load.strategy", "unstable");
    }

    if ("true".equals(Configuration.getDisableFlash())) {
      firefoxProfile.setPreference("plugin.state.flash", 0);
    }

    caps.setCapability(FirefoxDriver.PROFILE, firefoxProfile);

    // Adding console logging for FF browser
    setBrowserLogging(Level.SEVERE);

    ExtHelper.addExtensions(Configuration.getExtensions());

    return new EventFiringWebDriver(new FirefoxDriver(caps));
  }
public class PinMapTests extends NewTestTemplate {

  Credentials credentials = Configuration.getCredentials();

  @Test(
      enabled = false,
      groups = {"PinMapTests_001", "PinMapTests", "InteractiveMaps"})
  @Execute(asUser = User.USER)
  public void PinMapTests_001_VerifyPinModalContent() {
    WikiBasePageObject base = new WikiBasePageObject();
    InteractiveMapsPageObject specialMap = base.openSpecialInteractiveMaps(wikiURL);
    InteractiveMapPageObject selectedMap =
        specialMap.clickMapWithIndex(InteractiveMapsContent.SELECTED_MAP_INDEX);
    selectedMap.verifyMapOpened();
    AddPinComponentObject pinDialog = selectedMap.placePinInMap();
    pinDialog.verifyPinTitleFieldIsDisplayed();
    pinDialog.verifyAssociatedArticleFieldIsDisplayed();
    pinDialog.verifyAssociatedArticleImagePlaceholderIsDisplayed();
    pinDialog.verifyPinCategorySelectorIsDisplayed();
    pinDialog.verifyDescriptionFieldIsDisplayed();
    selectedMap = pinDialog.clickCancelButton();
  }

  @DontRun(env = {"dev", "sandbox", "preview"})
  @Test(
      enabled = false,
      groups = {"PinMapTests_002", "PinMapTests", "InteractiveMaps"})
  @Execute(asUser = User.USER)
  public void PinMapTests_002_VerifySuggestionsAndAssociatedImage() {
    WikiBasePageObject base = new WikiBasePageObject();
    InteractiveMapsPageObject specialMap = base.openSpecialInteractiveMaps(wikiURL);
    InteractiveMapPageObject selectedMap =
        specialMap.clickMapWithIndex(InteractiveMapsContent.SELECTED_MAP_INDEX);
    selectedMap.verifyMapOpened();
    AddPinComponentObject pinDialog = selectedMap.placePinInMap();
    pinDialog.verifyPinTitleFieldIsDisplayed();
    pinDialog.typePinName(InteractiveMapsContent.PIN_NAME);
    String placeholderSrc = pinDialog.getAssociatedArticleImageSrc();
    pinDialog.typeAssociatedArticle(InteractiveMapsContent.ASSOCIATED_ARTICLE_NAME);
    pinDialog.clickSuggestion(0);
    pinDialog.verifyAssociatedImageIsVisible(placeholderSrc);
    pinDialog.selectPinType();
    selectedMap = pinDialog.clickSaveButton();
    selectedMap.verifyPinPopupImageIsVisible();
  }

  @Test(
      enabled = false,
      groups = {"PinMapTests_003", "PinMapTests", "InteractiveMaps"})
  @Execute(asUser = User.USER)
  public void PinMapTests_003_VerifyPinCreationErrors() {
    WikiBasePageObject base = new WikiBasePageObject();
    InteractiveMapsPageObject specialMap = base.openSpecialInteractiveMaps(wikiURL);
    InteractiveMapPageObject selectedMap =
        specialMap.clickMapWithIndex(InteractiveMapsContent.SELECTED_MAP_INDEX);
    selectedMap.verifyMapOpened();
    AddPinComponentObject addPinModal = selectedMap.placePinInMap();
    addPinModal.clickSaveButton();
    addPinModal.verifyErrorExists();
    addPinModal.typePinName(InteractiveMapsContent.PIN_DESCRIPTION);
    addPinModal.clickSaveButton();
    addPinModal.verifyErrorExists();
    addPinModal.selectPinType();
    addPinModal.clickSaveButton();
    addPinModal.verifyErrorExists();
  }

  @RelatedIssue(issueID = " ", comment = "This maps test should not fail")
  @DontRun(env = {"dev", "sandbox", "preview"})
  @Test(groups = {"PinMapTests_004", "PinMapTests", "InteractiveMaps"})
  @Execute(asUser = User.USER)
  public void PinMapTests_004_VerifyPopUpAfterClickPin() {
    WikiBasePageObject base = new WikiBasePageObject();
    InteractiveMapsPageObject specialMap = base.openSpecialInteractiveMaps(wikiURL);
    InteractiveMapPageObject selectedMap =
        specialMap.clickMapWithIndex(InteractiveMapsContent.SELECTED_MAP_INDEX);
    selectedMap.verifyMapOpened();
    selectedMap.clickOnPin(0);
    selectedMap.verifyPopUpVisible();
  }

  @DontRun(env = {"dev", "sandbox", "preview"})
  @Test(
      enabled = false,
      groups = {"PinMapTests_005", "PinMapTests", "InteractiveMaps"})
  @Execute(asUser = User.USER)
  public void PinMapTests_005_VerifyDeletePin() {
    WikiBasePageObject base = new WikiBasePageObject();
    InteractiveMapsPageObject specialMap = base.openSpecialInteractiveMaps(wikiURL);
    InteractiveMapPageObject selectedMap =
        specialMap.clickMapWithIndex(InteractiveMapsContent.SELECTED_MAP_INDEX);
    selectedMap.verifyMapOpened();
    selectedMap.clickOnFilterBoxTitle();
    selectedMap.clickOnPin(0);
    String pinName = selectedMap.getOpenPinName();
    selectedMap.verifyPopUpVisible();
    AddPinComponentObject editPinModal = selectedMap.clickOnEditPin();
    selectedMap = editPinModal.clickDeletePin();
    selectedMap.verifyPinNotExists(pinName);
  }

  @DontRun(env = {"dev", "sandbox", "preview"})
  @Test(
      enabled = false,
      groups = {"PinMapTests_006", "PinMapTests", "InteractiveMaps", "PinMapTests_004"})
  @Execute(asUser = User.USER)
  public void PinMapTests_006_VerifyChangePinData() {
    WikiBasePageObject base = new WikiBasePageObject();
    InteractiveMapsPageObject specialMap = base.openSpecialInteractiveMaps(wikiURL);
    InteractiveMapPageObject selectedMap =
        specialMap.clickMapWithIndex(InteractiveMapsContent.SELECTED_MAP_INDEX);
    selectedMap.verifyMapOpened();
    selectedMap.clickOnFilterBoxTitle();
    AddPinComponentObject pinModal = selectedMap.placePinInMap();
    String pinTitle = base.getTimeStamp();
    String pinDescription = base.getTimeStamp() + base.getTimeStamp();
    pinModal.typePinName(pinTitle);
    pinModal.selectPinType();
    pinModal.typePinDescription(pinDescription);
    selectedMap = pinModal.clickSaveButton();
    pinModal = selectedMap.clickOnEditPin();
    pinModal.clearPinName();
    pinModal.typePinName(base.getTimeStamp() + base.getTimeStamp());
    pinModal.clearPinDescription();
    pinModal.typePinDescription(base.getTimeStamp());
    selectedMap = pinModal.clickSaveButton();
    selectedMap.verifyPinDataWasChanged(pinTitle, pinDescription);
    selectedMap.refreshPage();
    selectedMap.clickOnPin(0);
  }

  @DontRun(env = {"dev", "sandbox", "preview"})
  @Test(
      enabled = false,
      groups = {"PinMapTests_007", "PinMapTests", "InteractiveMaps"})
  @Execute(asUser = User.USER)
  public void PinMapTests_007_VerifyValidExternalUrlCanBeAdded() {
    WikiBasePageObject base = new WikiBasePageObject();
    InteractiveMapsPageObject specialMaps = base.openSpecialInteractiveMaps(wikiURL);
    InteractiveMapPageObject selectedMap =
        specialMaps.clickMapWithIndex(InteractiveMapsContent.SELECTED_MAP_INDEX);
    selectedMap.verifyMapOpened();
    AddPinComponentObject addPinModal = selectedMap.placePinInMap();
    addPinModal.typePinName(InteractiveMapsContent.PIN_NAME);
    addPinModal.typeAssociatedArticle(InteractiveMapsContent.EXTERNAL_LINK);
    addPinModal.selectPinType();
    selectedMap = addPinModal.clickSaveButton();
    selectedMap.verifyPinTitleLink();
    selectedMap.clickOpenPinTitle();
    selectedMap.verifyUrlInNewWindow(InteractiveMapsContent.EXTERNAL_LINK);
  }

  @Test(
      enabled = false,
      groups = {"PinMapTests_008", "PinMapTests", "InteractiveMaps"})
  @DontRun(env = {"dev", "sandbox", "preview"})
  @Execute(asUser = User.USER)
  public void PinMapTests_008_VerifyErrorMessageWhenAssociatedArticleNotExist() {
    WikiBasePageObject base = new WikiBasePageObject();
    InteractiveMapsPageObject specialMaps = base.openSpecialInteractiveMaps(wikiURL);
    InteractiveMapPageObject selectedMap =
        specialMaps.clickMapWithIndex(InteractiveMapsContent.SELECTED_MAP_INDEX);
    selectedMap.verifyMapOpened();
    AddPinComponentObject addPinModal = selectedMap.placePinInMap();
    addPinModal.typePinName(InteractiveMapsContent.PIN_NAME);
    addPinModal.typeAssociatedArticle(InteractiveMapsContent.ARTICLE_WHICH_DOES_NOT_EXIST);
    addPinModal.selectPinType();
    addPinModal.clickSaveButton();
    addPinModal.verifyErrorContent(
        InteractiveMapsContent.ARTICLE_NOT_EXIST_ERROR.replace(
            "%articlename%", InteractiveMapsContent.ARTICLE_WHICH_DOES_NOT_EXIST));
  }

  @Test(
      enabled = false,
      groups = {"PinMapTests_009", "PinMapTests", "InteractiveMaps"})
  @Execute(asUser = User.USER)
  public void PinMapTests_009_VerifyArticlePlaceholder() {
    WikiBasePageObject base = new WikiBasePageObject();
    InteractiveMapsPageObject specialMaps = base.openSpecialInteractiveMaps(wikiURL);
    InteractiveMapPageObject selectedMap =
        specialMaps.clickMapWithIndex(InteractiveMapsContent.SELECTED_MAP_INDEX);
    selectedMap.verifyMapOpened();
    AddPinComponentObject addPinModal = selectedMap.placePinInMap();
    addPinModal.verifyAssociatedArticlePlaceholder();
  }
}
@Test(groups = {"Facebook"})
public class FacebookTests extends NewTestTemplate {

  Credentials credentials = Configuration.getCredentials();

  TestUser user = FacebookTestUser.getUser();

  /**
   *
   *
   * <ol>
   *   <li>Log in to facebook
   *   <li>Click facebook login on signup page
   *   <li>Deny permission to user's facebook email address
   *   <li>>manually enter email address and create account
   *   <li>confirm account and login
   *   <li>Verify user can login via facebook
   * </ol>
   */
  @Test
  @UseUnstablePageLoadStrategy
  public void linkWithNewAccountNoEmailPermission() {
    new RemoveFacebookPageObject(driver).removeWikiaApps(user.getEmail(), user.getPassword());

    SignUpPageObject signUp = new SignUpPageObject(driver).open();
    FacebookSignupModalComponentObject fbModal = signUp.clickFacebookSignUp();

    String userName = "******" + signUp.getTimeStamp();
    String password = "******" + signUp.getTimeStamp();
    String email = credentials.emailQaart2;
    String emailPassword = credentials.emailPasswordQaart2;
    fbModal.createAccountNoEmail(email, emailPassword, userName, password);

    AlmostTherePageObject almostThere = new AlmostTherePageObject(driver);
    almostThere.confirmAccountAndLogin(email, emailPassword, userName, password, wikiURL);
  }

  /**
   * 1. Click facebook login in dropdown menu 2. Enter existing wikia credentials to link facebook
   * and wikia accounts 3. login 4. Verify user can login via wikia username/pwd 5. Disconnect
   * facebook via prefs for cleanup
   */
  @Test
  @UseUnstablePageLoadStrategy
  public void linkWithExistingWikiaAccount() {
    new RemoveFacebookPageObject(driver)
        .removeWikiaApps(user.getEmail(), user.getPassword())
        .logOutFB();

    DropDownComponentObject dropDown = new DropDownComponentObject(driver);
    dropDown.openWikiPage(wikiURL);
    dropDown.appendToUrl("noads=1");
    dropDown.openDropDown();
    dropDown.logInViaFacebook(user.getEmail(), user.getPassword());

    FacebookSignupModalComponentObject fbModal = new FacebookSignupModalComponentObject(driver);
    fbModal.acceptWikiaAppPolicy();
    fbModal.loginExistingAccount(credentials.userName13, credentials.password13);
    dropDown.verifyUserLoggedIn(credentials.userName13);
  }

  @Test
  @UseUnstablePageLoadStrategy
  public void connectUsingUserPreferences() {
    new RemoveFacebookPageObject(driver)
        .removeWikiaApps(user.getEmail(), user.getPassword())
        .logOutFB();

    PreferencesPageObject prefsPage = new PreferencesPageObject(driver).open();
    prefsPage.loginAs(User.USER);
    prefsPage.selectTab(PreferencesPageObject.tabNames.FACEBOOK);
    prefsPage.connectFacebook(user.getEmail(), user.getPassword());
    prefsPage.verifyFBButtonVisible();
    prefsPage.logOut(wikiURL);
    SignUpPageObject signUp = new SignUpPageObject(driver).open();
    signUp.clickFacebookSignUp();
    prefsPage.verifyUserLoggedIn(credentials.userName);
  }

  @Test
  @UseUnstablePageLoadStrategy
  public void signUpWithFacebook() {
    new RemoveFacebookPageObject(driver)
        .removeWikiaApps(user.getEmail(), user.getPassword())
        .logOutFB();
    WikiBasePageObject base = new WikiBasePageObject(driver);
    base.openWikiPage(wikiURL);
    FacebookMainPageObject fbLogin = base.openFacebookMainPage();
    FacebookUserPageObject userFB;
    userFB = fbLogin.login(user.getEmail(), user.getPassword());
    userFB.verifyPageLogo();
    SignUpPageObject signUp = userFB.navigateToSpecialSignUpPage(wikiURL);
    FacebookSignupModalComponentObject fbModal = signUp.clickFacebookSignUp();
    fbModal.acceptWikiaAppPolicy();
    String userName = "******" + DateTime.now().getMillis();
    String password = "******" + DateTime.now().getMillis();
    fbModal.typeUserName(userName);
    fbModal.typePassword(password);
    fbModal.createAccount();
    base.openWikiPage(wikiURL);
    base.appendToUrl("noads=1");
    base.verifyUserLoggedIn(userName);
    base.logOut(wikiURL);
  }
}
 @AfterMethod(alwaysRun = true)
 public void clearCustomTestProperties() {
   Configuration.clearCustomTestProperties();
 }
Esempio n. 25
0
public class ForumBoardTests extends NewTestTemplate {

  /*
   * StoryQA0128 - Create test cases for forum https://wikia.fogbugz.com/default.asp?95449
   */

  Credentials credentials = Configuration.getCredentials();
  private String title;
  private String message;

  @Test(groups = {"ForumBoardTests_001", "ForumBoardTests", "Forum", "Smoke3"})
  public void ForumBoardTests_001_startDiscussionWithTitleAndMessage() {
    ForumPageObject forumMainPage = new ForumPageObject(driver);
    forumMainPage.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL);
    title = PageContent.FORUM_TITLE_PREFIX + forumMainPage.getTimeStamp();
    message = PageContent.FORUM_MESSAGE + forumMainPage.getTimeStamp();
    forumMainPage.openForumMainPage(wikiURL);
    ForumBoardPageObject forumBoard = forumMainPage.openForumBoard();
    ForumThreadPageObject forumThread = forumBoard.startDiscussion(title, message, false);
    forumThread.verifyDiscussionTitleAndMessage(title, message);
  }

  @Test(groups = {"ForumBoardTests_002", "ForumBoardTests", "Forum"})
  public void ForumBoardTests_002_startDiscussionWithoutTitle() {
    ForumPageObject forumMainPage = new ForumPageObject(driver);
    forumMainPage.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL);
    message = PageContent.FORUM_MESSAGE + forumMainPage.getTimeStamp();
    forumMainPage.openForumMainPage(wikiURL);
    ForumBoardPageObject forumBoard = forumMainPage.openForumBoard();
    ForumThreadPageObject forumThread = forumBoard.startDiscussionWithoutTitle(message);
    // "Message from" default title appears after posting message without title
    forumThread.verifyDiscussionTitleAndMessage("Message from", message);
  }

  @Test(groups = {"ForumBoardTests_003", "ForumBoardTests", "Forum"})
  public void ForumBoardTests_003_startDiscussionWithImage() {
    ForumPageObject forumMainPage = new ForumPageObject(driver);
    forumMainPage.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL);
    title = PageContent.FORUM_TITLE_PREFIX + forumMainPage.getTimeStamp();
    forumMainPage.openForumMainPage(wikiURL);
    ForumBoardPageObject forumBoard = forumMainPage.openForumBoard();
    forumBoard.startDiscussionWithImgae(title);
    forumBoard.clickPostButton();
    forumBoard.verifyDiscussionWithImage();
  }

  @Test(groups = {"ForumBoardTests_004", "ForumBoardTests", "Forum"})
  public void ForumBoardTests_004_startDiscussionWithLink() {
    String externalLink = PageContent.EXTERNAL_LINK;
    String internalLink = PageContent.REDIRECT_LINK;
    ForumPageObject forumMainPage = new ForumPageObject(driver);
    forumMainPage.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL);
    title = PageContent.FORUM_TITLE_PREFIX + forumMainPage.getTimeStamp();
    forumMainPage.openForumMainPage(wikiURL);
    ForumBoardPageObject forumBoard = forumMainPage.openForumBoard();
    forumBoard.startDiscussionWithLink(internalLink, externalLink, title);
    forumBoard.clickPostButton();
    forumBoard.verifyStartedDiscussionWithLinks(internalLink, externalLink);
  }

  @Test(groups = {"ForumBoardTests_005", "ForumBoardTests", "Forum"})
  public void ForumBoardTests_005_startDiscussionWithVideo() {
    ForumPageObject forumMainPage = new ForumPageObject(driver);
    forumMainPage.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL);
    title = PageContent.FORUM_TITLE_PREFIX + forumMainPage.getTimeStamp();
    forumMainPage.openForumMainPage(wikiURL);
    ForumBoardPageObject forumBoard = forumMainPage.openForumBoard();
    forumBoard.startDiscussionWithVideo(VideoContent.YOUTUBE_VIDEO_URL3, title);
    forumBoard.clickPostButton();
  }

  @Test(groups = {"ForumBoardTests_006", "ForumBoardTests", "Forum"})
  public void ForumBoardTests_006_followDiscussion() {
    ForumPageObject forumMainPage = new ForumPageObject(driver);
    forumMainPage.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL);
    title = PageContent.FORUM_TITLE_PREFIX + forumMainPage.getTimeStamp();
    forumMainPage.openForumMainPage(wikiURL);
    ForumBoardPageObject forumBoard = forumMainPage.openForumBoard();
    forumBoard.unfollowIfDiscussionIsFollowed(1);
    forumBoard.verifyTextOnFollowButton(1, "Follow");
    forumBoard.clickOnFollowButton(1);
    forumBoard.verifyTextOnFollowButton(1, "Following");
    forumBoard.clickOnFollowButton(1);
    forumBoard.verifyTextOnFollowButton(1, "Follow");
  }

  @Test(
      enabled = false, // CONCF-476
      groups = {"ForumBoardTests_007", "ForumBoardTests", "Forum"})
  public void ForumBoardTests_007_highlightDiscussion() {
    ForumPageObject forumMainPage = new ForumPageObject(driver);
    forumMainPage.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL);
    title = PageContent.FORUM_TITLE_PREFIX + forumMainPage.getTimeStamp();
    message = PageContent.FORUM_MESSAGE + forumMainPage.getTimeStamp();
    forumMainPage.openForumMainPage(wikiURL);
    ForumBoardPageObject forumBoard = forumMainPage.openForumBoard();
    ForumThreadPageObject forumThread = forumBoard.startDiscussion(title, message, true);
    forumThread.verifyDiscussionTitleAndMessage(title, message);
    forumThread.notifications_verifyLatestNotificationTitle(title);
  }
}
  public String logInCookie(String userName, String password, String wikiURL) {
    String client_id = HeliosConfig.getClientId();
    String client_secret = HeliosConfig.getClientSecret();
    String heliosBaseUrl = HeliosConfig.getUrl(HeliosConfig.HeliosController.TOKEN);

    CloseableHttpClient httpClient = HttpClients.createDefault();

    HttpPost httpPost = new HttpPost(heliosBaseUrl);
    List<NameValuePair> nvps = new ArrayList<NameValuePair>();

    nvps.add(new BasicNameValuePair("grant_type", HeliosConfig.GrantType.PASSWORD.getGrantType()));
    nvps.add(new BasicNameValuePair("client_id", client_id));
    nvps.add(new BasicNameValuePair("client_secret", client_secret));
    nvps.add(new BasicNameValuePair("username", userName));
    nvps.add(new BasicNameValuePair("password", password));

    CloseableHttpResponse response = null;
    httpPost.setEntity(new UrlEncodedFormEntity(nvps, StandardCharsets.UTF_8));
    try {
      response = httpClient.execute(httpPost);

      HttpEntity entity = response.getEntity();
      JSONObject responseValue = new JSONObject(EntityUtils.toString(entity));

      EntityUtils.consume(entity);

      PageObjectLogging.log("LOGIN HEADERS: ", response.toString(), true);
      PageObjectLogging.log("LOGIN RESPONSE: ", responseValue.toString(), true);

      String token = responseValue.getString("access_token");

      String domian = Configuration.getEnvType().equals("dev") ? ".wikia-dev.com" : ".wikia.com";

      driver.manage().addCookie(new Cookie("access_token", token, domian, null, null));

      if (driver.getCurrentUrl().contains("Logout")) {
        driver.get(wikiURL);
      } else {
        driver.navigate().refresh();
      }

      verifyUserLoggedIn(userName);
      PageObjectLogging.log(
          "loginCookie", "user was logged in by by helios using acces token: " + token, true);
      return token;
    } catch (TimeoutException e) {
      PageObjectLogging.log("loginCookie", "page timeout after login by cookie", false);
    } catch (UnsupportedEncodingException | ClientProtocolException e) {
      PageObjectLogging.log("logInCookie", "UnsupportedEncodingException", false);
      throw new WebDriverException();
    } catch (JSONException e) {
      PageObjectLogging.log("logInCookie", "Problem with parsing JSON response", false);
      throw new WebDriverException();
    } catch (IOException e) {
      PageObjectLogging.log("logInCookie", "IO Exception", false);
    } finally {
      try {
        response.close();
      } catch (IOException | NullPointerException e) {
        PageObjectLogging.log("logInCookie", "IO Exception", false);
      }
    }
    return "";
  }