public void testSchoolWard() throws Exception {
   File car = new AssetDownloader(new File("downloads")).getLocalAsset(DOWNLOAD_URL);
   FolderView folder =
       page.openCurrentFolder()
           .openImportDialogue()
           .selectFile(car)
           .replaceContents()
           .importCar()
           .openCurrentFolder();
   String archive = folder.getCurrentUrl().replaceAll("\\?.*", "?archive");
   File ex =
       new AssetDownloader(getUsername(), getPassword()).downloadAsset(archive, "schools.car");
   folder.openImportDialogue().selectFile(ex).replaceContents().importCar().open("./");
   ex.delete();
   browser.click(By.linkText("Bartley Green"));
   browser.focusInTopWindow();
   browser.click(By.linkText("Bartley Green School A Specialist Technology and Sports College"));
   browser.focusInTopWindow();
   String uri = browser.getCurrentUrl().replace("?view", "");
   browser.click(By.linkText("Edit"));
   browser.focusInTopWindow();
   browser.type(By.id("name"), "Bartley Green School");
   browser.type(By.id("comment"), "A Specialist Technology and Sports College");
   browser.click(By.id("save"));
   browser.focusInTopWindow();
   browser.waitUntilTextPresent(By.tagName("p"), "A Specialist Technology and Sports College");
   page.open("/sparql", DatasourceView.class)
       .query("DELETE WHERE { <" + uri + "> ?p ?o }")
       .execute();
   browser.focusInTopWindow();
 }
 private void SpecialNeeds() throws IOException {
   // Click Special Needs
   driver
       .findElement(
           By.xpath(
               "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Special Needs\")]"))
       .click();
   // Select Special Needs
   Select SpecialNeeds = new Select(driver.findElement(By.id("edit-special-needs")));
   // Select Learning Center
   SpecialNeeds.selectByVisibleText("Learning Center");
   // Select Early Syllabus
   SpecialNeeds.selectByVisibleText("Early syllabus");
   // Click Apply
   driver.findElement(By.id("edit-special-needs-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
 private void AreaOfStudy() throws IOException, InterruptedException {
   // Click Area of School
   driver
       .findElement(
           By.xpath(
               "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Area of Study\")]"))
       .click();
   // Select One Area Study
   new Select(driver.findElement(By.id("edit-area-of-study-parent")))
       .selectByVisibleText("Area, Ethnic, Cultural, and Gender Studies");
   // Wait For Another Select List To Load
   Thread.sleep(5000);
   // Select Subareas of Study
   new Select(driver.findElement(By.xpath("//div[@id='child-area-of-study-wrapper']//select")))
       .selectByVisibleText("Area, Ethnic, Cultural, and Gender Studies, Other");
   // Click Apply
   driver.findElement(By.id("edit-area-of-study-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
  /** http://jira.xwiki.org/browse/XWIKI-7913 */
  @Test
  public void testJavascriptExtension() {
    // Create a doc
    WikiEditPage wep = WikiEditPage.gotoPage("Test", "SkinxTest");
    wep.setContent("this is the content");
    ViewPage vp = wep.clickSaveAndView();

    // Add an XWikiGroups object
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("XWiki.JavaScriptExtension");
    objectForm.setFieldValue(By.id("XWiki.JavaScriptExtension_0_code"), SCRIPT);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("always");
    vp = oep.clickSaveAndView();
    Assert.assertTrue(isScriptActive(vp));
    vp = HomePage.gotoPage();
    Assert.assertTrue(isScriptActive(vp));

    oep = ObjectEditPage.gotoPage("Test", "SkinxTest");
    objectForm = oep.getObjectsOfClass("XWiki.JavaScriptExtension").get(0);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("currentPage");
    vp = oep.clickSaveAndView();
    Assert.assertTrue(isScriptActive(vp));
    vp = HomePage.gotoPage();
    Assert.assertFalse(isScriptActive(vp));

    oep = ObjectEditPage.gotoPage("Test", "SkinxTest");
    objectForm = oep.getObjectsOfClass("XWiki.JavaScriptExtension").get(0);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("onDemand");
    vp = oep.clickSaveAndView();
    Assert.assertFalse(isScriptActive(vp));
  }
 public void addFeedbackResponseComment(String addResponseCommentId, String commentText) {
   WebDriverWait wait = new WebDriverWait(browser.driver, 5);
   WebElement addResponseCommentForm = browser.driver.findElement(By.id(addResponseCommentId));
   WebElement parentContainer = addResponseCommentForm.findElement(By.xpath("../.."));
   WebElement showResponseCommentAddFormButton =
       parentContainer.findElement(By.id("button_add_comment"));
   showResponseCommentAddFormButton.click();
   wait.until(
       ExpectedConditions.elementToBeClickable(
           addResponseCommentForm.findElement(By.tagName("textarea"))));
   fillTextBox(addResponseCommentForm.findElement(By.tagName("textarea")), commentText);
   addResponseCommentForm
       .findElement(By.className("col-sm-offset-5"))
       .findElement(By.tagName("a"))
       .click();
   if (commentText.equals("")) {
     // empty comment: wait until the textarea is clickable again
     wait.until(
         ExpectedConditions.elementToBeClickable(
             addResponseCommentForm.findElement(By.tagName("textarea"))));
   } else {
     // non-empty comment: wait until the add comment form disappears
     waitForElementToDisappear(By.id(addResponseCommentId));
   }
 }
示例#6
0
  public void checkBottomAdD() {
    // Seems that sometimes the ad is embedded in iframe, sometime not!
    String adURL = "";

    try {
      // first, check it in iframe 3
      adURL =
          driver
              .findElement(By.id("bottomleaderboard"))
              .findElement(By.tagName("a"))
              .getAttribute("href");
    } catch (Exception e) {

    }

    if (adURL.length() < 1) {
      try {
        // first, check it in iframe 3
        adURL =
            driver
                .findElement(By.id("bottomleaderboard"))
                .findElement(By.tagName("iframe"))
                .getAttribute("name");
      } catch (Exception e) {

      }
    }

    if (adURL.length() < 1) {
      driver.switchTo().defaultContent();
      try {
        adURL =
            driver
                .findElement(By.id("bottomleaderboard"))
                .findElement(By.tagName("a"))
                .getAttribute("href");
      } catch (Exception e) {

      }

      if (adURL.length() < 1) {
        driver.switchTo().defaultContent();
        try {
          adURL =
              driver
                  .findElement(By.id("bottomleaderboard"))
                  .findElement(By.tagName("iframe"))
                  .getAttribute("name");
        } catch (Exception e) {

        }
      }
    }

    System.out.println("adURL: " + adURL);

    if (adURL.length() < 4) {
      errors.append("No ad is displayed in the bottom Leader Board.");
    }
  }
示例#7
0
  // odi.614 Able to generate reports for time range
  public void search() {
    String dmName = "US_AIRWAYS";
    gotoreports(dmName);
    try {
      driver.findElement(By.id("PARAM_START_DATE")).clear();
      Alert alert = driver.switchTo().alert();
      alert.dismiss();
      driver.findElement(By.id("PARAM_START_DATE")).sendKeys("8/11/2013");
      driver.findElement(By.id("PARAM_END_DATE")).clear();
      alert.dismiss();
      driver.findElement(By.id("PARAM_END_DATE")).sendKeys("9/11/2013");
      driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
      driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
      new WebDriverWait(driver, 10)
          .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("reportContent"));
      WebElement page =
          new WebDriverWait(driver, 10)
              .until(ExpectedConditions.visibilityOfElementLocated(By.id("CrystalViewer")));
      WebElement rangeStart = page.findElement(By.xpath("//*[contains(text(),'8/11/2013')]"));
      WebElement rangeEnd = page.findElement(By.xpath("//*[contains(text(),'9/11/2013')]"));
      if (rangeStart != null && rangeEnd != null) {
        System.out.println("Report for selected range is showed");
      }
      ReportFile = new WriteXmlFile();
      driver.switchTo().defaultContent();
      ReportFile.addTestCase("ODI6.x-614:CSSR-Search", "ODI6.x-614:CSSR-Search => Pass");

    } catch (Exception e) {
      System.out.print("trace: ");
      e.printStackTrace();
    }
    // driver.quit();
    ReportFile.WriteToFile();
  }
  @Override
  public JRSCCustomerPage<P> ensurePageLoaded() {
    //        super.ensurePageLoaded();

    getWait()
        .until(
            presenceOfElementLocated(
                By.id(JRSCCustomAutomationConstant.JRSC_MAINPAGE_SEARCH_FORM_BUTTON_ID)));
    getWait()
        .until(
            presenceOfElementLocated(
                By.id(JRSCCustomAutomationConstant.JRSC_MAINPAGE_FULLSCREEN_MODULES_BUTTON_ID)));
    getWait()
        .until(
            presenceOfElementLocated(
                By.id(JRSCCustomAutomationConstant.JRSC_MAINPAGE_ERROR_DIALOG_BUTTON_ID)));
    getWait()
        .until(
            presenceOfElementLocated(
                By.id(JRSCCustomAutomationConstant.JRSC_MAINPAGE_EMBEDDED_MODULES_BUTTON_ID)));
    getWait()
        .until(
            presenceOfElementLocated(
                By.id(JRSCCustomAutomationConstant.JRSC_MAINPAGE_CURRENT_USER_BUTTON_ID)));

    return this;
  }
  public boolean addNoteFromNotesTab(String note) throws InterruptedException {

    clickOnTab("tabs-notes-link");

    clickOnButton("add_note");
    TimeUnit.SECONDS.sleep(1);

    // open note dialog and add data in it
    getWebDriver().switchTo().activeElement();

    driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.id("new_projects_note")));

    WebElement title = getWebDriver().findElement(By.id("title"));
    title.sendKeys(note);

    writeInRedactor("This is a note description");

    WebElement save = getWebDriver().findElement(By.id("Save"));
    save.click();
    TimeUnit.SECONDS.sleep(2);

    getWebDriver().switchTo().activeElement();

    // wait until tab content appears again
    driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.id("add_note")));

    return checkNoteInList(note);
  }
 private void login() {
   driver.findElement(By.id("username")).clear();
   driver.findElement(By.id("username")).sendKeys("GSH8");
   driver.findElement(By.name("j_password")).clear();
   driver.findElement(By.name("j_password")).sendKeys("GSH");
   driver.findElement(By.xpath("//input[@value='LOGAR']")).click();
 }
示例#11
0
  public void uploadProfile(String provider, String name, String context, String version)
      throws InterruptedException, IOException {

    driver.findElement(By.id(uiElementMapper.getElement("my.profile.region.tab.id"))).click();

    driver
        .findElement(By.linkText(uiElementMapper.getElement("my.profile.new.profile.add.link")))
        .click();

    WebElement profileName =
        driver.findElement(By.id(uiElementMapper.getElement("my.profile.name.id")));
    profileName.sendKeys(provider);

    WebElement profileFirstName =
        driver.findElement(By.id(uiElementMapper.getElement("my.profile.first.name.id")));
    profileFirstName.sendKeys(name);

    WebElement profileLastName =
        driver.findElement(By.id(uiElementMapper.getElement("my.profile.last.name.id")));
    profileLastName.sendKeys(context);

    WebElement profileEmail =
        driver.findElement(By.id(uiElementMapper.getElement("my.profile.email.id")));
    profileEmail.sendKeys(version);

    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("validate()");

    log.info("successfully Saved");
  }
示例#12
0
  @Test
  public void testGetElementExists() throws Exception {
    seleniumNavigationService.navigate_to_url(BUTTON_TEST_PAGE_URL);

    assertTrue(seleniumElementService.getElementExists(By.id("text")));
    assertFalse(seleniumElementService.getElementExists(By.id("NotÉxisting")));
  }
示例#13
0
  protected void waitForFolderToLoad(final String folderName) throws Exception {
    logMsg("Waiting for folder: " + folderName);
    int count = 0;
    try {
      getJspTestUtils().waitSec();
      String crumb =
          getJspTestUtils()
              .findElement(By.id("auto_folder_search_dialog_breadcrumbs"))
              .findElement(By.xpath("//strong"))
              .getText();
      while (count < 12 && !crumb.toLowerCase().contains(folderName.toLowerCase())) {

        logMsg("    Found: " + crumb);
        if (getJspTestUtils().isElement(By.id(folderName))) {
          logMsg("Clicking " + folderName);
          getJspTestUtils().findElement(By.id(folderName)).click();
        }
        count++;
        getJspTestUtils().waitSec();
        crumb =
            getJspTestUtils()
                .findElement(By.id("auto_folder_search_dialog_breadcrumbs"))
                .findElement(By.xpath("//strong"))
                .getText();
      }
    } catch (ErrorHandler.UnknownServerException e) {
      logMsg("Threw UnknownServerException");
    }
  }
示例#14
0
  public boolean deleteWebApp(String webAppContext) throws Exception {
    WebElement table_element = driver.findElement(By.id("webappsTable"));
    List<WebElement> tr_collection =
        table_element.findElement(By.tagName("tbody")).findElements(By.tagName("tr"));
    if (tr_collection.size() == 0) {
      throw new Exception("Web App you are trying to delete not exists");
    }
    List<WebElement> td_collection;
    for (WebElement tr : tr_collection) {
      td_collection = tr.findElements(By.tagName("td"));
      if (webAppContext.equals(td_collection.get(1).getText())) {
        td_collection.get(0).findElement(By.tagName("input")).click();
        driver.findElement(By.id("delete2")).click();
        Assert.assertEquals(
            driver.findElement(By.id("messagebox-confirm")).getText(),
            "Do you want to delete the selected applications?",
            "Delete Confirmation message mismatched");
        List<WebElement> buttons = driver.findElements(By.tagName("button"));
        for (WebElement button : buttons) {
          if ("yes".equalsIgnoreCase(button.getText())) {
            button.click();
            break;
          }
        }

        Assert.assertEquals(
            driver.findElement(By.id("messagebox-info")).getText(),
            "Successfully deleted selected applications",
            "Web Application deletion failed" + ". Message box content mis matched");
        driver.findElement(By.xpath("/html/body/div[3]/div[2]/button")).click();
        return true;
      }
    }
    throw new Exception("Web App you are trying to delete not exists");
  }
  @JavascriptEnabled
  @Test
  @Ignore(
      value = {SAFARI, MARIONETTE},
      reason = "Advanced mouse actions only implemented in rendered browsers",
      issues = {4136})
  @NotYetImplemented(HTMLUNIT)
  @NoDriverAfterTest
  public void testCanMoveOverAndOutOfAnElement() {
    driver.get(pages.mouseOverPage);

    WebElement greenbox = driver.findElement(By.id("greenbox"));
    WebElement redbox = driver.findElement(By.id("redbox"));
    Dimension size = redbox.getSize();

    new Actions(driver).moveToElement(greenbox, 1, 1).perform();

    assertEquals(
        Colors.GREEN.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));

    new Actions(driver).moveToElement(redbox).perform();
    assertEquals(
        Colors.RED.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));

    // IE8 (and *only* IE8) requires a move of 2 pixels. All other browsers
    // would be happy with 1.
    new Actions(driver).moveToElement(redbox, size.getWidth() + 2, size.getHeight() + 2).perform();
    assertEquals(
        Colors.GREEN.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));
  }
  public String addNewProject(String projectName) throws InterruptedException {

    WebElement btnNewProj =
        driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.id("new_project")));

    btnNewProj.click();
    TimeUnit.SECONDS.sleep(2);

    executeJavascript("document.getElementsByClassName('edit_me')[0].click();");
    TimeUnit.SECONDS.sleep(2);

    WebElement txtName = getWebDriver().findElement(By.id("projects_project_title"));
    txtName.click();
    txtName.clear();
    txtName.sendKeys(projectName);

    List<WebElement> saveBtnList =
        getWebDriver().findElements(By.xpath(".//*[@id='projects_project_submit_action']/input"));
    for (WebElement btnSave : saveBtnList) {
      if (btnSave.isDisplayed()) btnSave.click();
    }

    TimeUnit.SECONDS.sleep(1);
    String name = "";
    List<WebElement> txtist = getWebDriver().findElements(By.cssSelector(".element-plain-text"));
    for (WebElement title : txtist) {
      if (title.getText().equals(projectName)) {
        name = title.getText();
        break;
      }
    }
    return name;
  }
  private void performDragAndDropWithMouse() {
    driver.get(pages.draggableLists);

    WebElement dragReporter = driver.findElement(By.id("dragging_reports"));

    WebElement toDrag = driver.findElement(By.id("rightitem-3"));
    WebElement dragInto = driver.findElement(By.id("sortable1"));

    Action holdItem = getBuilder(driver).clickAndHold(toDrag).build();

    Action moveToSpecificItem =
        getBuilder(driver).moveToElement(driver.findElement(By.id("leftitem-4"))).build();

    Action moveToOtherList = getBuilder(driver).moveToElement(dragInto).build();

    Action drop = getBuilder(driver).release(dragInto).build();

    assertEquals("Nothing happened.", dragReporter.getText());

    try {
      holdItem.perform();
      moveToSpecificItem.perform();
      moveToOtherList.perform();

      String text = dragReporter.getText();
      assertTrue(text, text.matches("Nothing happened. (?:DragOut *)+"));
    } finally {
      drop.perform();
    }
  }
  @Test
  public void basicPromptConfirmHandlingDismissTest() {

    WebElement promptButton;
    WebElement promptResult;

    promptButton = driver.findElement(By.id("promptexample"));
    promptResult = driver.findElement(By.id("promptreturn"));

    assertEquals("pret", promptResult.getText());
    promptButton.click();

    String alertMessage = "I prompt you";

    Alert promptAlert = driver.switchTo().alert();

    if (Driver.currentDriver == Driver.BrowserName.IE) {
      // In IE the alert always returns "Script Prompt:" and not the
      // actual prompt text, so this line is just to alert me if the
      // functionality changes
      if (!promptAlert.getText().equals("Script Prompt:")) {
        throw new RuntimeException("IE now does not do Script Prompt");
      }

    } else {
      // only check the alert prompt if not in IE
      assertEquals(alertMessage, promptAlert.getText());
    }

    promptAlert.dismiss();

    assertEquals("pret", promptResult.getText());
  }
示例#19
0
  @Test
  public void testStableSort() throws Exception {
    page.click(By.id("button_sortid"));
    page.click(By.id("button_sortid"));
    page.click(By.id("button_sortname"));

    String[] idList = {
      "15", "0", "-13.5", "2", "-2", "-1.3", "10.01", "24", "1", "10.7", "3", "33", "10.35",
      "-0.001", "10.3"
    };

    String searchString = "";
    for (int i = 0; i < idList.length; i++) {
      searchString += idList[i] + "{*}";
    }
    page.verifyContains(searchString);

    page.click(By.id("button_sortname"));
    String[] reversedIdList = {
      "10.3", "-0.001", "10.35", "33", "3", "10.7", "1", "-2", "-1.3", "10.01", "24", "2", "-13.5",
      "0", "15"
    };

    searchString = "";
    for (int i = 0; i < reversedIdList.length; i++) {
      searchString += reversedIdList[i] + "{*}";
    }
    page.verifyContains(searchString);
  }
  @Test
  public void basicPromptConfirmHandlingAcceptTest() {

    WebElement promptButton;
    WebElement promptResult;

    promptButton = driver.findElement(By.id("promptexample"));
    promptResult = driver.findElement(By.id("promptreturn"));

    assertEquals("pret", promptResult.getText());
    promptButton.click();

    String alertMessage = "I prompt you";

    Alert promptAlert = driver.switchTo().alert();

    if (Driver.currentDriver != Driver.BrowserName.IE) {
      // no point doing this in IE as we know it isn't the actual prompt
      assertEquals(alertMessage, promptAlert.getText());
    }

    promptAlert.accept();

    assertEquals("change me", promptResult.getText());
  }
示例#21
0
  public void testAwsppWebDriver(int docs, int times) throws InterruptedException {
    init();
    WebDriver driver = new FirefoxDriver();
    //		WebDriver driver = new HtmlUnitDriver();
    for (int j = 0; j < times; j++) {
      driver.get(baseUrl);
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      // create/resume transaction

      WebElement docs_input = driver.findElement(By.id("create_docs_1"));
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      docs_input.clear();
      docs_input.sendKeys("" + docs);

      WebElement createButton = driver.findElement(By.id("resume"));
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      createButton.click();
      for (int i = 0; i < docs; i++) {

        WebElement img = driver.findElement(By.xpath("//img[@alt='Click to sign']"));
        driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
        img.click();

        WebElement submitButton = driver.findElement(By.name("button"));
        driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);

        submitButton.click();
      }
      WebElement link = driver.findElement(By.linkText("Go Back to Parent Page"));
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      link.click();
    }
    driver.close();
  }
 public static void loginfb(WebDriver driver) {
   driver.findElement(By.id("email")).clear();
   driver.findElement(By.id("email")).sendKeys("Enter your username");
   driver.findElement(By.id("pass")).clear();
   driver.findElement(By.id("pass")).sendKeys("Enter your password");
   driver.findElement(By.id("loginbutton")).click();
 }
public class ProviderPage extends AdminManagementPage {

  static final By IDENTIFIER = By.name("identifier");
  static final By PERSON = By.id("providerName");
  static final By SEARCH_ELEMENT = By.id("inputNode");
  static final By ERROR = By.cssSelector("span.error");

  public ProviderPage(WebDriver driver) {
    super(driver);
    MANAGE = By.linkText("Manage Providers");
    ADD = By.linkText("Add Provider");
    RETIRE = By.name("retireProviderButton");
    SAVE = By.name("saveProviderButton");
  }

  public void fillInIdentifier(String text) {
    fillInField(findElement(IDENTIFIER), text);
  }

  public void fillInPerson(String text) {
    fillInField(findElement(PERSON), text);
  }

  public void waitForError() {
    waitForElement(ERROR);
  }

  @Override
  public String getPageUrl() {
    return "/admin/provider/index.htm";
  }
}
  @JavascriptEnabled
  @Test
  public void testDragAndDrop() throws InterruptedException {
    driver.get(pages.droppableItems);

    long waitEndTime = System.currentTimeMillis() + 15000;

    while (!isElementAvailable(driver, By.id("draggable"))
        && (System.currentTimeMillis() < waitEndTime)) {
      Thread.sleep(200);
    }

    if (!isElementAvailable(driver, By.id("draggable"))) {
      throw new RuntimeException("Could not find draggable element after 15 seconds.");
    }

    WebElement toDrag = driver.findElement(By.id("draggable"));
    WebElement dropInto = driver.findElement(By.id("droppable"));

    Action holdDrag = getBuilder(driver).clickAndHold(toDrag).build();

    Action move = getBuilder(driver).moveToElement(dropInto).build();

    Action drop = getBuilder(driver).release(dropInto).build();

    holdDrag.perform();
    move.perform();
    drop.perform();

    dropInto = driver.findElement(By.id("droppable"));
    String text = dropInto.findElement(By.tagName("p")).getText();

    assertEquals("Dropped!", text);
  }
 public void verifyCommentRowContent(
     String commentRowIdSuffix, String commentText, String giverName) {
   WebDriverWait wait = new WebDriverWait(browser.driver, 30);
   WebElement commentRow;
   try {
     commentRow =
         wait.until(
             ExpectedConditions.presenceOfElementLocated(
                 By.id("responseCommentRow" + commentRowIdSuffix)));
   } catch (TimeoutException e) {
     fail("Timeout!");
     commentRow = null;
   }
   try {
     wait.until(
         ExpectedConditions.textToBePresentInElement(
             commentRow.findElement(By.id("plainCommentText" + commentRowIdSuffix)), commentText));
   } catch (TimeoutException e) {
     fail("Not expected message");
   }
   try {
     assertTrue(commentRow.findElement(By.className("text-muted")).getText().contains(giverName));
   } catch (AssertionError e) {
     assertTrue(commentRow.findElement(By.className("text-muted")).getText().contains("you"));
   }
 }
  @Ignore(
      value = {IE, CHROME, FIREFOX},
      reason = "Not implemented yet.")
  @NotYetImplemented(HTMLUNIT)
  @Test
  public void testMovingMouseBackAndForthPastViewPort() {
    driver.get(pages.veryLargeCanvas);

    WebElement firstTarget = driver.findElement(By.id("r1"));
    new Actions(driver).moveToElement(firstTarget).click().perform();

    WebElement resultArea = driver.findElement(By.id("result"));
    String expectedEvents = "First";
    wait.until(elementTextToEqual(resultArea, expectedEvents));

    // Move to element with id 'r2', at (2500, 50) to (2580, 100)
    new Actions(driver).moveByOffset(2540 - 150, 75 - 125).click().perform();
    expectedEvents += " Second";
    wait.until(elementTextToEqual(resultArea, expectedEvents));

    // Move to element with id 'r3' at (60, 1500) to (140, 1550)
    new Actions(driver).moveByOffset(100 - 2540, 1525 - 75).click().perform();
    expectedEvents += " Third";
    wait.until(elementTextToEqual(resultArea, expectedEvents));

    // Move to element with id 'r4' at (220,180) to (320, 230)
    new Actions(driver).moveByOffset(270 - 100, 205 - 1525).click().perform();
    expectedEvents += " Fourth";
    wait.until(elementTextToEqual(resultArea, expectedEvents));
  }
 private void TypesOfSchool() throws IOException {
   // Click Type of School
   driver.findElement(By.cssSelector("strong")).click();
   // Click Private
   driver.findElement(By.id("edit-public-private-private")).click();
   // Move School Size Slider
   // TODO Slider not working properly
   WebElement Slider1 = driver.findElement(By.id("population_jq_slider"));
   Actions moveSlider1 = new Actions(driver);
   Action action1 = moveSlider1.dragAndDropBy(Slider1, 0, 10).build();
   action1.perform();
   // Select Religious Affiliation
   new Select(driver.findElement(By.id("edit-religious-affiliation")))
       .selectByVisibleText("Church of Christ");
   // Move Tuition Range Slider
   // TODO Slider not working properly
   WebElement Slider2 = driver.findElement(By.id("tuition_range_jq_slider"));
   Actions moveSlider2 = new Actions(driver);
   Action action2 = moveSlider2.dragAndDropBy(Slider2, 0, 10).build();
   action2.perform();
   // Click Apply
   driver.findElement(By.id("edit-type-of-school-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
  @JavascriptEnabled
  @Ignore(
      value = {SAFARI, MARIONETTE},
      issues = {4136})
  @Test
  public void testHoverPersists() throws Exception {
    driver.get(pages.javascriptPage);
    // Move to a different element to make sure the mouse is not over the
    // element with id 'item1' (from a previous test).
    new Actions(driver).moveToElement(driver.findElement(By.id("dynamo"))).build().perform();

    WebElement element = driver.findElement(By.id("menu1"));

    final WebElement item = driver.findElement(By.id("item1"));
    assertEquals("", item.getText());

    ((JavascriptExecutor) driver).executeScript("arguments[0].style.background = 'green'", element);
    new Actions(driver).moveToElement(element).build().perform();

    // Intentionally wait to make sure hover persists.
    Thread.sleep(2000);

    wait.until(not(elementTextToEqual(item, "")));

    assertEquals("Item 1", item.getText());
  }
public enum GroupEdit implements Element {
  EDIT_GROUP(By.id("action-button-edit-0")),
  MEMBERSHIP_GROUP(By.id("action-button-member-0")),
  EXTERNAL_ID_GROUP(By.id("externalId")),
  ADD_USER_GROUP(By.id("move-to-member")),
  REMOVE_USER_GROUP(By.id("remove-from-member")),

  // adavies
  EXTERN_USER(
      By.xpath(
          "//select[contains(@id, 'outsider')]/..//option[contains(@value, '03dc8f50-acaa-44d6-9401-bdfc5e10e821')]")),
  GROUP_USER(
      By.xpath(
          "//select[contains(@id, 'member')]/..//option[contains(@value, '03dc8f50-acaa-44d6-9401-bdfc5e10e821')]"));

  private By by;

  private GroupEdit(By by) {
    this.by = by;
  }

  @Override
  public By by() {
    return this.by;
  }
}
  @Test
  public static void main(String[] args) throws InterruptedException {
    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.spicejet.com/");
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.findElement(By.id("ctl00_mainContent_rbtnl_Trip_1")).click();
    driver.findElement(By.id("ctl00_mainContent_ddl_originStation1_CTXT")).click();
    driver.findElement(By.linkText("Hyderabad (HYD)")).click();
    Thread.sleep(1000);
    driver.findElement(By.linkText("Delhi (DEL)")).click();
    driver
        .findElement(By.xpath("//table[@class='ui-datepicker-calendar']/tbody/tr[4]/td[6]/a"))
        .click();
    driver.findElement(By.id("ctl00_mainContent_btn_FindFlights")).click();

    String mainwindow = driver.getWindowHandle();
    driver.findElement(By.id("popUpConverter")).click();
    Set<String> allwindows = driver.getWindowHandles();
    for (String child : allwindows) {
      if (child.equals(allwindows)) {
        System.out.println("Don't switch");
      } else {
        driver.switchTo().window(child);
        // System.out.println(child);
        /*Thread.sleep(10000);
        //driver.manage().window().maximize();
        driver.findElement(By.id("CurrencyConverterCurrencyConverterView_TextBoxAmount")).sendKeys("10000");
        driver.switchTo().defaultContent();*/

      }
    }
  }