Exemplo n.º 1
0
public class Bulk_Add_Participants_Page {
  WebDriver driver;
  By bulkAddParticipantsWelcome = By.cssSelector("h4");
  By importFileName = By.cssSelector("input[id='importFile']");
  By importButton = By.cssSelector("button[id='next']");
  By importMessage = By.cssSelector("div[class='alert alert-success']");
  By closePage = By.cssSelector("i[class='icon-remove']");
  private String message = "Bulk add participants finished.";

  public Bulk_Add_Participants_Page(WebDriver driver) {
    this.driver = driver;
  }

  // return the welcome message text
  public String getbulkAddParticipantsWelcome() {
    return driver.findElement(bulkAddParticipantsWelcome).getText();
  }

  // select the import file input text box and populate it with the import file name
  // and hit the import button
  public void bulk_add_Participants(String filename) {
    driver.findElement(importFileName).clear();
    driver.findElement(importFileName).sendKeys(filename);
    driver.findElement(importButton).click();
  }
  // return the message indicating import status
  public String getImportFileMessage() {
    return driver.findElement(importMessage).getText();
  }
  // close the import message bar
  public void close_Page() {
    driver.findElement(closePage).click();
  }
}
  /**
   * 取得新闻标题、时间和评论数的集合
   *
   * @param urls 所有新闻URL集合
   * @return 新闻标题、时间和评论数的集合
   */
  public static List<String> getTimeAndJoin(List<String> urls) {
    List<String> listTimeAndJoin = new ArrayList<String>();

    int num = 1;
    // System.setProperty("webdriver.ie.driver", "." + File.separator + "Driver" + File.separator +
    // "IEDriverServer.exe");
    // WebDriver driver = new InternetExplorerDriver();
    WebDriver driver = new FirefoxDriver();
    for (int i = 0; i < urls.size(); i++) {
      // System.setProperty("webdriver.ie.driver", "." + File.separator + "Driver" + File.separator
      // + "IEDriverServer.exe");
      // WebDriver driver = new InternetExplorerDriver();
      driver.get(urls.get(i));
      List<WebElement> headline =
          driver.findElements(By.cssSelector("div[class='atitle tCenter']"));
      List<WebElement> timeAndJoin = driver.findElements(By.cssSelector("div[class='about']"));

      StringBuffer sb = null;
      sb = new StringBuffer();

      if ((timeAndJoin.size() == 1) && (headline.size() == 1)) {
        sb.append("[新闻 " + num + "]");
        sb.append(headline.get(0).getText() + "\t");
        String[] temp = timeAndJoin.get(0).getText().split("\n");
        sb.append(temp[0] + "\t" + temp[1] + "\t" + temp[2]);
        // sb.append(timeAndJoin.get(0).getText().replaceAll("\\s+", ""));
        listTimeAndJoin.add(sb.toString());
        num++;
      }
      // driver.close();
    }
    driver.close();
    return listTimeAndJoin;
  }
  @Test
  public void testEditXidioAddressInProfileManagement() throws Exception {
    UserLoginFunctions userLogin = new UserLoginFunctions();
    driver.get(AppProperties.APPURL);

    assertTrue(
        driver
            .findElement(By.cssSelector("BODY"))
            .getText()
            .matches("^[\\s\\S]*Sign In[\\s\\S]*$"));

    userLogin.UserLoginCredentials(driver);

    driver.findElement(By.linkText(AppProperties._USER_NAME)).click();
    driver.findElement(By.name("user[address]")).clear();
    driver.findElement(By.name("user[address]")).sendKeys(AppProperties._UPD_ADDRESS);
    driver.findElement(By.linkText("Save profile")).click();

    assertTrue(
        driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*XIDIO[\\s\\S]*$"));
    driver.findElement(By.linkText(AppProperties._USER_NAME)).click();
    driver.findElement(By.linkText("Sign out")).click();

    assertTrue(
        driver
            .findElement(By.cssSelector("BODY"))
            .getText()
            .matches("^[\\s\\S]*User Account[\\s\\S]*$"));
    assertEquals(
        AppProperties._UPD_ADDRESS,
        driver.findElement(By.name("user[address]")).getAttribute("value"));
  }
Exemplo n.º 4
0
  // W-1625895: Safari WebDriver bug- cannot right click because interactions API not implemented
  @ExcludeBrowsers({
    BrowserType.IPAD,
    BrowserType.IPHONE,
    BrowserType.SAFARI,
    BrowserType.ANDROID_PHONE,
    BrowserType.ANDROID_TABLET
  })
  public void testBaseMouseClickEventValue() throws Exception {
    open(TEST_CMP);
    WebElement input = findDomElement(By.cssSelector(".keyup2"));
    WebElement outputValue = findDomElement(By.cssSelector(".outputValue"));

    // IE < 9 uses values 1, 2, 4 for left, right, middle click (respectively)
    String expectedVal =
        (BrowserType.IE7.equals(getBrowserType()) || BrowserType.IE8.equals(getBrowserType()))
            ? "1"
            : "0";
    input.click();
    assertEquals("Left click not performed ", expectedVal, outputValue.getText());

    // right click behavior
    Actions actions = new Actions(getDriver());
    actions.contextClick(input).perform();
    assertEquals("Right click not performed ", "2", outputValue.getText());
  }
Exemplo n.º 5
0
  // Method checking if the edited profile is displayed back to the user and if illegal string like
  // URL and email id are stripped off from "profile essay" sections
  private void verifyChanges() {

    List<WebElement> allElements = driver.findElements(By.cssSelector("div[id='about_myself'] p"));
    for (WebElement element1 : allElements) {
      if (element1.getText().contains("www.") || element1.getText().contains(".com")) ;
      ripOffTextAboutMe++;
    }

    List<WebElement> allElements2 =
        driver.findElements(By.cssSelector("div[id='who_im_looking_for'] p"));

    for (WebElement element2 : allElements2) {
      if (element2.getText().contains("www.") || element2.getText().contains(".com")) ;
      ripOffTextPartnerSearch++;
    }

    List<WebElement> allElement3 =
        driver.findElements(By.cssSelector("ul[class='profileInformation'] li"));
    for (WebElement element3 : allElement3) {
      // System.out.println(element3.getText());
      if (element3.getText().contains("Mixed") || element3.getText().contains("4ft. 10in."))
        profileChangeCheck++;
    }

    if (profileChangeCheck > 0)
      System.out.println("SUCCESS: The changes made in the basic profile are visible");

    if (ripOffTextAboutMe != 0)
      System.out.println(
          "SUCCESS: The About Myself section has ripped off any illegal strings like URL and Email id");

    if (ripOffTextPartnerSearch != 0)
      System.out.println(
          "SUCCESS: The What I am Looking For section has ripped off any illegal strings like URL and Email id");
  }
  protected boolean addTable(WebElement procedureDescToolBar, String data)
      throws InterruptedException {

    boolean created;
    WebElement tableLoader = procedureDescToolBar.findElement(By.cssSelector(".grid.load"));
    tableLoader.click();

    TimeUnit.SECONDS.sleep(4);

    writeInTable(data);

    TimeUnit.SECONDS.sleep(2);

    WebElement imgSaveDesc =
        driverWait.until(
            ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".fa.fa-check")));
    imgSaveDesc.click();
    TimeUnit.SECONDS.sleep(4);

    driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".delete_me")));

    String value = readFromTable();

    WebElement tableArea =
        driverWait.until(
            ExpectedConditions.visibilityOfElementLocated(
                By.cssSelector(".inline_form_container.type_excel.spreadJS_activated")));

    created = ((tableArea != null) && (data.equals(value)));
    return created;
  }
  public void testViewMacronutrientsAsHCP() throws Exception {
    // Login patient 1.
    WebDriver wd = (HtmlUnitDriver) login("9000000071", "pw");
    assertEquals("iTrust - HCP Home", wd.getTitle());

    // Navigate to the Macronutrients page.
    wd.findElement(By.partialLinkText("Patient Macronutrient")).click();
    assertEquals("iTrust - Please Select a Patient", wd.getTitle());
    wd.findElement(By.name("UID_PATIENTID")).sendKeys("342");
    // the button to click should have the text of the MID
    wd.findElement(By.cssSelector("input[value='342']")).submit();

    assertTrue(
        wd.findElement(By.tagName("body"))
            .getText()
            .contains("Hubert Farnsworth's Macronutrient Intake"));

    wd = (HtmlUnitDriver) login("9000000000", "pw");
    assertEquals("iTrust - HCP Home", wd.getTitle());

    // Navigate to the Macronutrients page.
    wd.findElement(By.partialLinkText("Patient Macronutrient")).click();
    assertEquals("iTrust - Please Select a Patient", wd.getTitle());
    wd.findElement(By.name("UID_PATIENTID")).sendKeys("342");
    // the button to click should have the text of the MID
    wd.findElement(By.cssSelector("input[value='342']")).submit();

    assertTrue(
        wd.findElement(By.tagName("body"))
            .getText()
            .contains("You do not have permission to view the Food Diary!"));
  }
  /**
   * Waits for a battle to begin. Times out after two minutes.
   *
   * @return TurnEndStatus.SWITCH if we are prompted for a lead Pokemon, TurnEndStatus.ATTACK
   *     otherwise.
   * @throws InvalidTeamException If Showdown rejects your team for any reason.
   */
  public TurnEndStatus waitForBattleStart() throws InvalidTeamException {
    (new WebDriverWait(driver, 120))
        .until(
            new ExpectedCondition<Boolean>() {
              public Boolean apply(WebDriver d) {
                return isElementPresent(By.cssSelector("div.whatdo"))
                    || isElementPresent(By.cssSelector("div.ps-popup"));
              }
            });
    if (isElementPresent(By.cssSelector("div.ps-popup"))) {
      throw new InvalidTeamException(
          driver.findElement(By.cssSelector("div.ps-popup>p:first")).getText());
    }

    initBattleLog();
    battleTimerOn = false;

    if (driver
        .findElement(By.cssSelector("div.whatdo"))
        .getText()
        .contains("How will you start the battle?")) {
      return TurnEndStatus.SWITCH;
    }
    return TurnEndStatus.ATTACK;
  }
 /** Leaves the current battle (click the close room button) */
 public void leaveBattle() {
   clickAt(By.cssSelector("a.button.cur.closable + a.closebutton"));
   sleep(500);
   if (isElementPresent(By.cssSelector("button[type='submit']"))) {
     clickAt(By.cssSelector("button[type='submit']"));
   }
 }
 @Test
 @Ignore
 public void testRegisterFailsWithBadEmail() throws Exception {
   Map<String, String> userDetails = createRandomUser();
   userDetails.put("email", "test");
   doRegister(userDetails, false);
   assertEquals(
       "Message not found",
       "An email address must contain a single @",
       driver.findElement(By.cssSelector(".error")).getText());
   driver.findElement(By.id("email")).clear();
   driver.findElement(By.id("email")).sendKeys("@bob.com");
   driver.findElement(By.id("form.submitted")).click();
   assertEquals(
       "Message not found",
       "The username portion of the email address is invalid (the portion before the @: )",
       driver.findElement(By.cssSelector(".error")).getText());
   driver.findElement(By.id("email")).clear();
   driver.findElement(By.id("email")).sendKeys("test@bob");
   driver.findElement(By.id("form.submitted")).click();
   assertEquals(
       "Message not found",
       "The domain portion of the email address is invalid (the portion after the @: bob)",
       driver.findElement(By.cssSelector(".error")).getText());
 }
Exemplo n.º 11
0
  /**
   * Attempts to find a battle of the specified format using the specified team.
   *
   * @param format The format you want to search for.
   * @param team The team you are using. Ignored for any format that does not require a team
   *     selection.
   * @throws NoSuchChoiceException if the specified format or team does not exist.
   */
  public void findBattle(String format, String team) throws NoSuchChoiceException {
    // Select the desired format
    clickAt(By.cssSelector("button[name='format']"));
    waitForElementPresent(By.cssSelector("div.ps-popup"));
    sleep(500);
    By wantedFormatBy =
        By.xpath(String.format("//button[@name='selectFormat'][text()='%s']", format));
    if (!isElementPresent(wantedFormatBy)) {
      throw new NoSuchChoiceException(String.format("Battle format '%s' does not exist", format));
    }
    clickAt(wantedFormatBy);

    // Select the desired team
    By teamDropdownBy = By.cssSelector("button[name='team']:not([disabled])");
    if (isElementPresent(teamDropdownBy)) {
      if (team != null) {
        clickAt(teamDropdownBy);
        waitForElementPresent(By.cssSelector("div.ps-popup"));
        By wantedTeamBy =
            By.xpath(String.format("//button[@name='selectTeam'][text()='%s']", team));
        if (!isElementPresent(wantedTeamBy)) {
          throw new NoSuchChoiceException(String.format("Team '%s' does not exist", team));
        }
        clickAt(wantedTeamBy);
      }
    } else {
      if (team != null) {
        throw new NoSuchChoiceException(String.format("Unable to select team '%s'.", team));
      }
    }
    clickAt(By.cssSelector("button[name='search']"));
  }
  @Test
  @Ignore(
      "I would love for this to work consistently but it fails too often between releases to use as an example")
  public void multiSelectWithUserInteractions() {

    WebElement multiSelect;

    multiSelect = driver.findElement(By.cssSelector("select[multiple='multiple']"));
    List<WebElement> multiSelectOptions = multiSelect.findElements(By.tagName("option"));

    // in real life, clicking on a multi select item without holding down
    // CTRL will deselect all others and select only that one item

    Actions actions = new Actions(driver);

    actions
        .click(multiSelectOptions.get(0))
        .click(multiSelectOptions.get(1))
        .click(multiSelectOptions.get(2))
        .perform();

    clickSubmitButton();

    new WebDriverWait(driver, 10).until(ExpectedConditions.titleIs("Processed Form Details"));

    assertEquals(
        "Expected only 1 match",
        1,
        driver.findElements(By.cssSelector("[id^='_valuemultipleselect']")).size());
  }
Exemplo n.º 13
0
  public static void main(String[] args) throws InterruptedException {
    WebDriver dr = new ChromeDriver();

    File file = new File("src/form.html");
    String filePath = "file:///" + file.getAbsolutePath();
    System.out.printf("now accesss %s \n", filePath);

    dr.get(filePath);
    Thread.sleep(1000);

    dr.findElement(By.cssSelector("input[type=checkbox]")).click();
    Thread.sleep(1000);

    dr.findElement(By.cssSelector("input[type=radio]")).click();
    Thread.sleep(1000);

    List<WebElement> options =
        dr.findElement(By.tagName("select")).findElements(By.tagName("option"));
    options.get(options.size() - 1).click();
    Thread.sleep(1000);

    dr.findElement(By.cssSelector("input[type=submit]")).click();

    Alert alert = dr.switchTo().alert();
    System.out.println(alert.getText());
    alert.accept();

    Thread.sleep(1000);
    System.out.println("browser will be close");
    dr.quit();
  }
  @Test
  public void workWithTheIFrame() {
    driver.get("http://www.compendiumdev.co.uk/selenium/frames");
    WebDriverWait wait = new WebDriverWait(driver, Driver.DEFAULT_TIMEOUT_SECONDS);

    assertThat(driver.getTitle(), is("Frameset Example Title (Example 6)"));

    // click on "menu"."iFrames Example"
    driver.switchTo().frame("menu");
    driver.findElement(By.cssSelector("a[href='iframe.html']")).click();

    wait.until(titleIs("HTML Frames Example - iFrame Contents"));

    // click on Example 5 in the iFrame
    driver.switchTo().frame(0);
    driver.findElement(By.cssSelector("a[href='frames_example_5.html']")).click();

    wait.until(titleIs("Frameset Example Title (Example 5)"));

    // then content.load main frames page
    driver.switchTo().frame("content");
    driver.findElement(By.cssSelector("a[href='index.html']")).click();

    wait.until(titleIs("Frameset Example Title (Example 6)"));
  }
  @Test
  public void testLoginToCamcast() throws Exception {
    driver.get(DataServiceProperties.APPURL);

    assertTrue(
        driver
            .findElement(By.cssSelector("BODY"))
            .getText()
            .matches("^[\\s\\S]*User name[\\s\\S]*$"));
    Thread.sleep(1000);
    assertTrue(
        driver
            .findElement(By.cssSelector("BODY"))
            .getText()
            .matches("^[\\s\\S]*Password[\\s\\S]*$"));

    userLogin.UserLoginCredentials(driver);

    // userLogin.ChangePassword(driver);

    assertTrue(
        driver
            .findElement(By.cssSelector("BODY"))
            .getText()
            .matches("^[\\s\\S]*Sign out[\\s\\S]*$"));
    driver.findElement(By.linkText("Sign out")).click();
  }
Exemplo n.º 16
0
 /**
  * Waits for the next turn to begin or the battle to end, kicking inactive players.
  *
  * @param kickAfterSeconds Clicks 'Kick inactive player' after this number of seconds. Set to 0 to
  *     never kick
  * @return TurnEndStatus indicator.
  */
 public TurnEndStatus waitForNextTurn(int kickAfterSeconds) {
   int waited = 0;
   boolean gameOver = false;
   while (!isElementPresent(By.cssSelector("div.whatdo")) && !gameOver) {
     if (!battleTimerOn && kickAfterSeconds != 0 && waited >= kickAfterSeconds * 1000) {
       kickInactivePlayer();
       kickAfterSeconds = 0;
     }
     sleep(500);
     waited += 500;
     gameOver = ((Long) javascript("return curRoom.battle.done;") > 0);
   }
   updateBattleLog();
   if (gameOver) {
     if (battlelog.contains(getUserName() + " won the battle!", true)) {
       return TurnEndStatus.WON;
     } else {
       return TurnEndStatus.LOST;
     }
   } else {
     String whatdoText = driver.findElement(By.cssSelector("div.whatdo")).getText();
     if (whatdoText.contains("Switch " + getCurrentPokemon(false) + " to:")) {
       return TurnEndStatus.SWITCH;
     } else if (whatdoText.contains("What will " + getCurrentPokemon(false) + " do?")) {
       return TurnEndStatus.ATTACK;
     }
   }
   return TurnEndStatus.UNKNOWN;
 }
 public AdsFloorAdhesionObject clickFloorAdhesion() {
   WebElement iframeAd = driver.findElement(By.cssSelector(FLOOR_ADHESION_AD_FRAME_CSS));
   driver.switchTo().frame(iframeAd);
   driver.findElement(By.cssSelector(FLOOR_ADHESION_IMAGE_IN_FRAME_CSS)).click();
   driver.switchTo().defaultContent();
   return this;
 }
  @Parameters("browser")
  @Test
  public void RMO_TC384_PricingSummaryExpandedOverlap_QA_Test(@Optional("FF") String BrowserType)
      throws Exception {

    try {
      this.gc.log.logSetup(this);
      this.gc.log.logInfo("/////Execution Started/////");

      gc.browser.BrowserCloseAllBrowsersBeforeRun();
      gc.browser.BrowserGetBrowserType(BrowserType);
      gc.browser.BrowserGet(Global.BaseUrlRMO_QA);
      gc.browser.BrowserWaitForPageToLoad();

      gc.rmo.RMO_Login(Global.RMOLoginUsername, Global.RMOLoginPassword);
      Thread.sleep(Global.Max_Wait);

      gc.rmo.RMOPricing_ClickProperty_QA(Global.RMO_PropertyName2);
      gc.browser.BrowserWaitForPageToLoad();
      gc.browser.BrowserClick("RMOPropertyPage_PropertiesLink_QA");
      gc.browser.BrowserWaitForPageToLoad();

      gc.rmo.RMOPricing_SelectFutureWeek();

      // UpdateDateStartDate();
      // UpdateDateEndDate();
      gc.rmo.RMOPricing_UpdateDate();
      gc.rmo.RMOPricing_SelectBAR();

      // gc.browser.BrowserClick("RMOAddNewPricing_Override_xp2btn");
      gc.browser.js.executeScript(
          "arguments[0].scrollIntoView(true);",
          gc.browser.driver.findElement(
              By.cssSelector(
                  "form[data-room-master='1BF'] div.data-table__row div.data-table__row-title")));
      gc.browser
          .driver
          .findElement(
              By.cssSelector(
                  "div.room-master-pricing div.summary-edit__data form[data-room-master='1BF'] div.xpu-section div.data-table__submit button.btn.blue-button span.blue-button__icon"))
          .click();

      gc.rmo.RMOPricing_UpdateRoomUpchargeXP2(Global.XP_Upcharge_Positive);
      gc.browser.BrowserClick("RMOAddNewPricing_CreatePricingBtn");
      gc.browser.BrowserWaitForElementPresent("RMOAddNewPricing_ConfimationAlert", 10);
      gc.browser.BrowserVerifyText("You have successfully created a Pricing Strategy for");

    } catch (ParserConfigurationException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } catch (IOException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } catch (TimeoutException e) {
      this.gc.log.logException(e.getMessage());
      Assert.assertTrue(false, "Exception occured.... Failing the script...!!");
    } finally {
      gc.generic.Env_Teardown();
    }
  }
  /**
   * Share a project with spreadsheet data and then check if it is seen in the shared url as
   * read-only.
   *
   * @param insertedData
   * @return
   * @throws InterruptedException
   */
  public boolean shareProjectCheckPermissions(String insertedData) throws InterruptedException {

    WebElement btnShare =
        driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".share")));
    btnShare.click();
    TimeUnit.SECONDS.sleep(2);
    WebElement shareUrl =
        driverWait.until(
            ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#project_share_url")));
    String urlToOpen = shareUrl.getText();

    logout();

    waitForPageCompleteLoading();
    // go into the shared url and check that the project is read-only
    getWebDriver().get(urlToOpen);

    String value = readFromTable();

    WebElement tableArea =
        driverWait.until(
            ExpectedConditions.visibilityOfElementLocated(
                By.cssSelector(".inline_form_container_read_only>.excel_container>.excel>table")));

    boolean created = ((tableArea != null) && (insertedData.equals(value)));
    return created;
  }
Exemplo n.º 20
0
  // Test Case 6: Password Empty - Error
  private void profileSetUpPasswordEmpty() throws InterruptedException {

    profilePage1();
    driver.findElement(By.id("nickName")).click();
    driver.findElement(By.id("nickName")).clear();
    driver.findElement(By.id("nickName")).sendKeys("Neel");

    new Select(driver.findElement(By.id("DOBMonth"))).selectByVisibleText("January");
    driver.findElement(By.cssSelector("option[value=\"01\"]")).click();
    new Select(driver.findElement(By.id("DOBDay"))).selectByVisibleText("04");
    driver.findElement(By.cssSelector("#DOBDay > option[value=\"02\"]")).click();
    new Select(driver.findElement(By.id("DOBYear"))).selectByVisibleText("1994");
    driver.findElement(By.cssSelector("option[value=\"1994\"]")).click();

    driver.findElement(By.id("email")).click();
    driver.findElement(By.id("email")).clear();
    driver.findElement(By.id("email")).sendKeys("*****@*****.**");

    driver.findElement(By.id("emailConfirmation")).click();
    driver.findElement(By.id("emailConfirmation")).clear();
    driver.findElement(By.id("emailConfirmation")).sendKeys("*****@*****.**");

    driver.findElement(By.id("password")).click();
    driver.findElement(By.id("password")).clear();

    Thread.sleep(3000);

    driver.findElement(By.cssSelector("input.submitButton.green")).click();
    Thread.sleep(3000);
    System.out.println("ERROR: Password Missing");
  }
Exemplo n.º 21
0
  protected void selectOptionByLabel(WebElement menuElement, String text, boolean guardAjax) {
    String menuId = getEscapedElementId(menuElement);
    WebElement trigger = menuElement.findElement(By.cssSelector("div.ui-selectonemenu-trigger"));
    trigger.click();

    String menuItemsContainerId = menuId + "_panel";
    List<WebElement> options =
        driver.findElements(
            By.cssSelector("#" + menuItemsContainerId + " tr.ui-selectonemenu-item"));
    if (options.isEmpty()) {
      options =
          driver.findElements(
              By.cssSelector("#" + menuItemsContainerId + " li.ui-selectonemenu-item"));
    }
    String selectedOptionText = getSelectedOptionText(menuElement);
    for (WebElement option : options) {
      if (option.getAttribute("data-label").equals(text)) {
        if (guardAjax && !selectedOptionText.equals(text)) {
          Graphene.guardAjax(option).click();
        } else {
          option.click();
        }
        break;
      }
    }
  }
Exemplo n.º 22
0
/** @author Aliaksei Boole */
public class EditCommentForm extends AbstractCommentForm {
  private static final String FORM_DIV_CSS = "DIV[class='comments-list']>DIV[class='comment-form']";
  private static final By FORM_DIV = By.cssSelector(FORM_DIV_CSS);
  private static final By AVATAR = By.cssSelector(FORM_DIV_CSS + ">img");
  private static final By CANCEL_BUTTON =
      By.cssSelector(FORM_DIV_CSS + " span[class~='yui-reset-button']>span>button");
  public static final By SUBMIT_BUTTON =
      By.cssSelector(FORM_DIV_CSS + " span[class~='yui-submit-button']>span>button");

  public void clickSaveCommentButton() {
    click(SUBMIT_BUTTON);
  }

  public void clickCancelButton() {
    click(CANCEL_BUTTON);
  }

  public boolean isDisplay() {
    return isElementDisplayed(FORM_DIV);
  }

  public boolean isAvatarDisplay() {
    return isElementDisplayed(AVATAR);
  }

  public boolean isButtonsEnable() {
    return super.isButtonsEnable(SUBMIT_BUTTON, CANCEL_BUTTON);
  }
}
  public void hoverAndViewStudentPhotoOnBody(int panelBodyIndex, String urlRegex) throws Exception {
    String idOfPanelBody = "panelBodyCollapse-" + panelBodyIndex;
    WebElement photoLink =
        browser
            .driver
            .findElements(By.cssSelector('#' + idOfPanelBody + "> .panel-body > .row"))
            .get(0)
            .findElements(By.className("profile-pic-icon-hover"))
            .get(0);
    Actions actions = new Actions(browser.driver);
    actions.moveToElement(photoLink).perform();

    waitForElementPresence(By.cssSelector(".popover-content > img"));
    ThreadHelper.waitFor(500);

    AssertHelper.assertContainsRegex(
        urlRegex,
        browser
            .driver
            .findElements(By.cssSelector(".popover-content > img"))
            .get(0)
            .getAttribute("src"));

    JavascriptExecutor jsExecutor = (JavascriptExecutor) browser.driver;
    jsExecutor.executeScript(
        "document.getElementsByClassName('popover')[0].parentNode.removeChild(document.getElementsByClassName('popover')[0])");
  }
Exemplo n.º 24
0
  @Test
  public void testLogin() {
    driver.get(appUrl + "/#/login");

    WebDriverWait wait = new WebDriverWait(driver, 10);

    WebElement user =
        wait.until(
            ExpectedConditions.presenceOfElementLocated(By.cssSelector("input[type=\"text\"]")));
    user.sendKeys("demo");

    WebElement password =
        wait.until(
            ExpectedConditions.presenceOfElementLocated(
                By.cssSelector("input[type=\"password\"]")));
    password.sendKeys("demo");

    WebElement submit =
        wait.until(
            ExpectedConditions.presenceOfElementLocated(By.cssSelector("button[type=\"submit\"]")));
    submit.submit();

    boolean found =
        wait.until(
            ExpectedConditions.textToBePresentInElement(By.cssSelector("td"), "Assign Approver"));
  }
  public void clickViewPhotoLink(int panelBodyIndex, String urlRegex) throws Exception {
    String idOfPanelBody = "panelBodyCollapse-" + panelBodyIndex;
    WebElement photoCell =
        browser
            .driver
            .findElement(By.id(idOfPanelBody))
            .findElements(By.cssSelector(".profile-pic-icon-click"))
            .get(0);
    JavascriptExecutor jsExecutor = (JavascriptExecutor) browser.driver;
    jsExecutor.executeScript(
        "document.getElementById('"
            + idOfPanelBody
            + "')"
            + ".getElementsByClassName('profile-pic-icon-click')[0]"
            + ".getElementsByTagName('a')[0].click();");
    Actions actions = new Actions(browser.driver);

    actions.moveToElement(photoCell).perform();
    waitForElementPresence(By.cssSelector(".popover-content > img"));

    List<WebElement> photos = browser.driver.findElements(By.cssSelector(".popover-content > img"));
    AssertHelper.assertContainsRegex(urlRegex, photos.get(photos.size() - 1).getAttribute("src"));

    actions.moveByOffset(100, 100).click().perform();
  }
  public void hoverClickAndViewStudentPhotoOnHeading(int panelHeadingIndex, String urlRegex)
      throws Exception {
    JavascriptExecutor jsExecutor = (JavascriptExecutor) browser.driver;
    String idOfPanelHeading = "panelHeading-" + panelHeadingIndex;
    WebElement photoDiv =
        browser
            .driver
            .findElement(By.id(idOfPanelHeading))
            .findElement(By.className("profile-pic-icon-hover"));
    jsExecutor.executeScript("arguments[0].scrollIntoView(true);", photoDiv);
    Actions actions = new Actions(browser.driver);
    actions.moveToElement(photoDiv).perform();
    waitForElementPresence(By.cssSelector(".popover-content"));

    jsExecutor.executeScript(
        "document.getElementsByClassName('popover-content')[0]"
            + ".getElementsByTagName('a')[0].click();");

    waitForElementPresence(By.cssSelector(".popover-content > img"));

    AssertHelper.assertContainsRegex(
        urlRegex,
        browser
            .driver
            .findElements(By.cssSelector(".popover-content > img"))
            .get(0)
            .getAttribute("src"));

    jsExecutor.executeScript(
        "document.getElementsByClassName('popover')[0].parentNode.removeChild(document.getElementsByClassName('popover')[0])");
  }
public class ManageAppointmentPage extends AbstractBasePage {

  private static final By APPOINTMENT_SCHEDULING =
      By.id("appointmentschedulingui-homeAppLink-appointmentschedulingui-homeAppLink-extension");
  private static final By MANAGE_APPOINTMENT =
      By.id("appointmentschedulingui-manageAppointments-app");
  private static final By DELETE_APPOINTMENT = By.cssSelector("i.delete-item.icon-remove");
  private static final By YES_DELETE = By.cssSelector("button.button.confirm.right");
  private static final By ENTER_SERVICE = By.xpath("//div[@id='selectAppointmentType']/input");
  private static final By SEARCH = By.cssSelector("#searchButtons > button.confirm");
  private static final By APPOINTMENT =
      By.xpath("//table[@id='appointmentTable']/div[2]/div/div/div/div[2]/div[2]/div");
  private static final By NEXT = By.cssSelector("#selectAppointment > button.confirm");
  private static final By SAVE = By.xpath("//div[@id='confirmAppointment']/div[2]/button[2]");
  private static final By SERVICE_DROPDOWN = By.cssSelector("a.ng-scope.ng-binding");

  public void goToManageAppointment() {
    clickOn(APPOINTMENT_SCHEDULING);
    clickOn(MANAGE_APPOINTMENT);
  }

  public boolean deletePresent() {
    try {
      return driver.findElement(DELETE_APPOINTMENT) != null;
    } catch (Exception ex) {
      return false;
    }
  }

  public void deleteAppointment() {
    clickOn(DELETE_APPOINTMENT);
    clickOn(YES_DELETE);
  }

  public void searchAppointment() {
    clickOn(SEARCH);
    clickOn(APPOINTMENT);
  }

  public void saveAppointment() {
    clickOn(NEXT);
    clickOn(SAVE);
  }

  public void enterService(String service) {
    setTextToFieldNoEnter(ENTER_SERVICE, service);
    waitForElement(SERVICE_DROPDOWN);
    clickOn(SERVICE_DROPDOWN);
  }

  public ManageAppointmentPage(WebDriver driver) {
    super(driver);
  }

  @Override
  public String expectedUrlPath() {
    return URL_ROOT + "/appointmentschedulingui/scheduleProviders.page";
  }
}
Exemplo n.º 28
0
  public static void CreateCustomer(String CustomerLastName, String Brand)
      throws InterruptedException {

    String TenDigitRandomNumber = CommonMethods.GetRandomNumber();
    String title = "Mr";
    String firstName = "F_" + TenDigitRandomNumber;
    String lastName = CustomerLastName;
    String day = "01";
    String year = "1990";
    String dob = day + "/" + "03" + "/" + year;
    String postcode = "HA90AB";
    String city = "Wembley";

    try {
      driver.findElement(By.cssSelector("img.allTabsArrow")).click();
      driver.findElement(By.linkText("Customers")).click();
      driver.findElement(By.name("new")).click();
      new Select(driver.findElement(By.xpath("//select[@id='p3']")))
          .selectByVisibleText("Customer");
      driver.findElement(By.cssSelector("#bottomButtonRow > input[name=\"save\"]")).click();
      driver.findElement(By.id("PersonEmail")).sendKeys(TenDigitRandomNumber + "*****@*****.**");
      driver.findElement(By.id("name_firstacc2")).sendKeys(firstName);
      driver.findElement(By.id("name_lastacc2")).sendKeys(lastName);
      new Select(
              driver.findElement(
                  By.xpath("//div[@id='ep']/div[2]/div[3]/table/tbody/tr[4]/td[2]/select")))
          .selectByVisibleText(title);
      new Select(driver.findElement(By.id("00N20000003Ag9N"))).selectByVisibleText("Male");
      driver.findElement(By.id("00N20000003Ag9M")).sendKeys(firstName + " " + lastName);
      driver.findElement(By.id("00N20000003B43e")).sendKeys("Flat 1");
      driver.findElement(By.id("00N20000003B43f")).sendKeys("Forum House");
      driver.findElement(By.id("00N20000003B43g")).sendKeys("Empire Way");
      driver.findElement(By.id("00N20000003B43l")).sendKeys(postcode);
      driver.findElement(By.id("00N20000003B43h")).sendKeys(city);
      driver.findElement(By.id("00N20000003B43j")).sendKeys("Wembley");
      driver.findElement(By.id("PersonBirthdate")).sendKeys(dob);
      new Select(driver.findElement(By.id("00N20000003Ajpc"))).selectByVisibleText(Brand);
      driver.findElement(By.cssSelector("#bottomButtonRow > input[name=\"save\"]")).click();
      Thread.sleep(5000);
    } catch (Exception e) {

      try {
        File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(
            scrFile,
            new File(
                System.getProperty("user.dir")
                    + "\\Screenshots\\"
                    + CommonMethods.GetRandomNumber()
                    + "screenshot.png"));
      } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  @Test
  public void testRender() throws Exception {

    //
    driver.get(getURL().toString());
    assertEquals(RunMode.LIVE, RUN_MODE);
    WebElement elt = driver.findElement(By.id("trigger"));
    URL url = new URL(elt.getAttribute("href"));
    driver.get(url.toString());
    assertEquals("ok", driver.findElement(By.tagName("body")).getText());
    assertFalse(SAME_CL_1);
    assertFalse(SAME_CL_2);
    assertNull(SAME_CL_3);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    assertEquals(getErrorStatus(), conn.getResponseCode());
    driver.get(url.toString());
    assertEquals(
        "java.lang.RuntimeException: throwed",
        driver.findElement(By.cssSelector("div.juzu > section > p")).getText().trim());

    // Make a change
    JavaFile pkgFile = getCompiler().assertJavaSource("bridge.runmode.live.controller.A");
    pkgFile.assertSave(pkgFile.assertContent().replace("\"ok\"", "\"OK\""));
    driver.get(applicationURL().toString());
    elt = driver.findElement(By.id("trigger"));
    elt.click();
    assertEquals("OK", driver.findElement(By.tagName("body")).getText());
    assertTrue(SAME_CL_1);
    assertFalse(SAME_CL_2);
    assertNull(SAME_CL_3);

    // Now make fail with compilation error
    pkgFile.assertSave(pkgFile.assertContent().replace("public", "_public_"));

    //
    conn = (HttpURLConnection) applicationURL().openConnection();
    assertEquals(getErrorStatus(), conn.getResponseCode());
    driver.get(applicationURL().toString());
    assertNotNull(driver.findElement(By.cssSelector("div.juzu")));
    assertNotNull(elt);

    //
    pkgFile.assertSave(pkgFile.assertContent().replace("_public_", "public"));

    //
    driver.get(applicationURL().toString());
    elt = driver.findElement(By.id("trigger"));
    elt.click();
    assertEquals("OK", driver.findElement(By.tagName("body")).getText());

    // Add a new class
    JavaFile abc = getCompiler().assertAddJavaSource("bridge.runmode.live.controller.C");
    driver.get(applicationURL().toString());
    assertTrue(SAME_CL_1);
    assertFalse(SAME_CL_2);
    assertTrue(SAME_CL_3);
  }
  /** Find Element By CSS */
  private void findElementByCssSelector(String objectLocators) {

    WebDriverWait wait = new WebDriverWait(WebDriverClass.getDriver(), 30);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(objectLocators)));

    List<WebElement> list1 =
        WebDriverClass.getInstance().findElements(By.cssSelector(objectLocators));
    listOfElements = list1;
  }