@Test
  public void testFindKioskFlow() throws Exception {
    driver.findElement(By.xpath("//a[contains(@href, '/fluffbox-rwx/kiosk/find')]")).click();
    driver.findElement(By.id("searchCriteria")).sendKeys("Ft. Lauderdale");
    driver.findElement(By.id("searchButton")).click();

    WebElement walgreensInsideLink = waitForDynamicElement(By.linkText("Walgreens (Inside)"));
    walgreensInsideLink.click();

    WebElement gMapInfoWindow =
        waitForDynamicElement(By.cssSelector("div.gmnoprint > div.gmnoprint > div > div"));
    assertThat(gMapInfoWindow.getText(), containsString("3895 W Broward Blvd"));

    WebElement winnDixieOutsideLink = waitForDynamicElement(By.linkText("Winn Dixie (Outside)"));
    winnDixieOutsideLink.click();

    gMapInfoWindow =
        waitForDynamicElement(By.cssSelector("div.gmnoprint > div.gmnoprint > div > div"));
    assertThat(gMapInfoWindow.getText(), containsString("1531 N State Road 7"));
  }
 @Test
 public void testUntitled2() throws Exception {
   driver.get(baseUrl + "php4dvd/");
   WebElement userNameWebEdit = driver.findElement(By.id("username"));
   WebElement passwordWebEdit = driver.findElement(By.name("password"));
   WebElement subminButton = driver.findElement(By.name("submit"));
   userNameWebEdit.clear();
   userNameWebEdit.sendKeys("admin");
   passwordWebEdit.clear();
   passwordWebEdit.sendKeys("admin");
   subminButton.click();
 }
  public void optionalClick(final By locator) {
    WebElement we = null;
    try {
      we = driver.findElement(locator);
      we.click();
    } catch (StaleElementReferenceException ser) {

    } catch (NoSuchElementException nse) {

    } catch (Exception e) {
      // staticlogger.info( e.getMessage() );
    }
  }
示例#4
0
  private void checkDemoPage(String lang) throws InterruptedException {
    checkElementVisible("page_loader", false);
    checkElementVisible("login_widget", false);
    checkElementVisible("webapp_ctx", true);
    checkElementVisible("error_window", false);
    checkElementVisible("success_window", true);

    // Extra check
    checkWidgetsOnLogin();

    // Check success message
    assertEquals(
        "Success message doesn't match",
        getLabelText(lang, "LL_DEMO_MSG"),
        driver.findElement(By.id("ok_msg")).getText());
    // Click on close button
    driver.findElement(By.id("success_window")).findElement(By.className("b-close")).click();

    Thread.sleep(1000);

    checkElementVisible("webapp_ctx", true);
    checkElementVisible("error_window", false);
    checkElementVisible("success_window", false);

    // Check color of message
    WebElement dmsg = driver.findElement(By.className("demo"));
    assertEquals(
        "demo message color doesn't match", "rgba(128, 128, 128, 1)", dmsg.getCssValue("color"));

    checkButtonById(lang, "ll_error", true);
    checkButtonById(lang, "ll_logout", true);

    // Check &  Press error button
    WebElement err = driver.findElement(By.id("ll_error"));
    err.click();
    Thread.sleep(500);
    checkErrorWin(
        lang,
        "C-DEMO",
        getLabelText(lang, "LL_INFO_MSG"),
        getLabelText(lang, "LL_DETAIL_MSG_1") + "\n" + getLabelText(lang, "LL_DETAIL_MSG_2"));
  }
示例#5
0
文件: LFT.java 项目: qarocks/SPW
  @Test
  public void LFTMain() throws Exception {
    JavascriptExecutor js = (JavascriptExecutor) webDriver;
    selenium.open(baseUrl);
    selenium.type("id=id_username", sender);
    selenium.type("id=id_password", "123abc");
    selenium.click("css=input[type=\"submit\"]");

    selenium.waitForPageToLoad("2000");

    System.out.println("First: The page title is " + selenium.getTitle());
    // code to upload file

    driver.findElement(By.linkText("Compose")).click();

    selenium.waitForPageToLoad("3000");

    // Runtime.getRuntime().exec("C:\\Users\\Sneha\\Desktop\\IE.exe");
    Runtime.getRuntime().exec("C:\\Users\\Sneha\\Desktop\\silver_autoit.exe");

    Functions.MyWaitfunc(driver, "//*[@id='uploader_browse']");
    WebElement ele = driver.findElement(By.xpath("//*[@id='uploader_browse']"));
    ele.click();

    // ele.sendKeys("C:\\Users\\Sneha\\Desktop\\Lighthouse.jpg");

    // send secure mail
    // driver.findElement(By.id("secure")).click();

    driver.findElement(By.id("addrin")).sendKeys(recipient);

    driver.findElement(By.id("id_subject")).sendKeys(stringToTest_tc001);

    String torun = "document.getElementById('tinymce').innerHTML='Hi there!'";

    driver.findElement(By.id("addrsubmit")).click();

    /*selenium.waitForPageToLoad("3000");

    		Thread.sleep(100);
    		js.executeScript(torun);

    		System.out.println((String)js.executeScript("return document.title"));

    */

    driver.switchTo().frame("id_body_ifr");

    selenium.typeKeys("//body[@id='tinymce']", "Finally wohoooo!!");
    driver.switchTo().defaultContent();

    driver.findElement(By.id("submitter")).click();

    /* code only if it is LFT

    String per_done="//html/body/div/div[2]/div[4]/form/fieldset/div[9]/div/div/div/div[2]/table[2]/tbody/tr/td[3]/span";
    NoSuchElementException e1 = null;

    // code to wait for file to be uploaded
    for (int second = 0;; second++) {

    	if (second >= 60) {fail("timeout");}
    	try { if (driver.findElement(By.xpath(per_done)).getText().equalsIgnoreCase("548 KB")) break; } catch (Exception e) {}
    	Thread.sleep(1000);


    }
    */
    // mail body

    /* code to run if LFT
    //System.out.println((String)js.
    if((this.doesWebElementExist(driver,By.xpath(per_done))) && (driver.findElement(By.xpath(per_done)).getText().equalsIgnoreCase("548 KB")))

    	{//driver.findElement(By.id("submitter")).click();
    	}

    else
    	throw e1;

    */

    /* this section if confirm dialog pops up!

    this.MyWaitfunc("//html/body/div[4]/div[11]/div/button/span");

          if(driver.findElement(By.xpath("//html/body/div[4]/div[11]/div/button/span")).isDisplayed())

    	driver.findElement(By.xpath("//html/body/div[4]/div[11]/div/button/span")).click();
    else
    	System.out.println("Confirm dialog not up yet!");
    */

    // to check if mail was sent successfully

    String success_str_xpath = "//html/body/div/div[2]/div[3]/ul/li";

    Functions.MyWaitfunc(driver, success_str_xpath);
    if ((Functions.doesWebElementExist(driver, By.xpath(success_str_xpath)))
        && (driver
            .findElement(By.xpath(success_str_xpath))
            .getText()
            .contains("Successfully sent the email")))
      System.out.println("SUCCESS:Mail successfully sent !");
    else {
      System.out.println("FAIL:Mail NOT SENT !");
      System.out.println(driver.findElement(By.xpath(success_str_xpath)).getText());
      Exception e1 = null;
      throw e1;
    }
  }
示例#6
0
  private void test_image_picker(WebDriver driver) {
    // Check both files exist
    File f1 = null;
    File f2 = null;
    try {
      ClassLoader cl = ImagePickerTest.class.getClassLoader();
      f1 = new File(cl.getResource("image_picker_1.png").toURI());
      assertTrue(f1.exists());
      f2 = new File(cl.getResource("image_picker_2.png").toURI());
      assertTrue(f2.exists());
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }
    assertNotNull(f1);
    assertNotNull(f2);

    // Login
    CStudioSeleniumUtil.try_login(
        driver, CStudioSeleniumUtil.AUTHOR_USER, CStudioSeleniumUtil.AUTHOR_PASSWORD, true);

    // Navigate to Widget
    CStudioSeleniumUtil.navigate_to_image_picker_widget(driver);

    // Upload right file size
    CStudioSeleniumUtil.click_on(driver, By.id("xf-4$xf-20$imageSrcAltTextTest-imageButton"));

    // Check popup dialog appears
    WebElement popup = driver.findElement(By.id("cstudio-wcm-popup-div_c"));
    assertTrue(popup.isDisplayed());

    WebElement input =
        driver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/div/div/form/input"));
    input.sendKeys(f1.getAbsolutePath());

    WebElement upload =
        driver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/div/div/form/input[2]"));
    upload.click();

    new WebDriverWait(driver, CStudioSeleniumUtil.SHORT_TIMEOUT)
        .until(
            new ExpectedCondition<Boolean>() {
              public Boolean apply(WebDriver d) {
                WebElement e = d.findElement(By.id("xf-4$xf-20$imageSrcAltTextTest$xf-206$$a"));
                return e != null && e.getAttribute("class").contains("xforms-alert-inactive");
              }
            });
    WebElement mark = driver.findElement(By.id("xf-4$xf-20$imageSrcAltTextTest$xf-206$$a"));
    assertTrue(mark.getAttribute("class").contains("xforms-alert-inactive"));

    // Delete uploaded image
    CStudioSeleniumUtil.click_on(driver, By.id("xf-4$xf-20$imageSrcAltTextTest-deleteButton"));
    WebElement filename =
        driver.findElement(By.id("xf-4$xf-20$imageSrcAltTextTest$xf-206-filename"));
    assertTrue(filename.getText().equals("250W X 130H"));

    // Upload any image
    CStudioSeleniumUtil.click_on(driver, By.id("xf-4$xf-20$imageSrcTest-imageButton"));

    // Check popup dialog appears
    popup = driver.findElement(By.id("cstudio-wcm-popup-div_c"));
    assertTrue(popup.isDisplayed());

    input = driver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/div/div/form/input"));
    input.sendKeys(f2.getAbsolutePath());

    upload = driver.findElement(By.xpath("/html/body/div[3]/div/div[2]/div/div/div/form/input[2]"));
    upload.click();

    new WebDriverWait(driver, CStudioSeleniumUtil.SHORT_TIMEOUT)
        .until(
            new ExpectedCondition<Boolean>() {
              public Boolean apply(WebDriver d) {
                WebElement e = d.findElement(By.id("xf-4$xf-20$imageSrcTest$xf-237-filename"));
                return e != null && e.getText().equals("/static-assets/images/image_picker_2.png");
              }
            });

    // Delete uploaded image
    CStudioSeleniumUtil.click_on(driver, By.id("xf-4$xf-20$imageSrcTest-deleteButton"));
    filename = driver.findElement(By.id("xf-4$xf-20$imageSrcTest$xf-237-filename"));
    assertTrue(filename.getText().equals(""));

    // Close driver
    CStudioSeleniumUtil.exit(driver);
  }