コード例 #1
0
ファイル: testff.java プロジェクト: rosttok/autotesting
 @Test
 public void testUntitled() throws Exception {
   driver.get(baseUrl + "en/login");
   driver.findElement(By.id("signin_username")).clear();
   driver.findElement(By.id("signin_username")).sendKeys("admin");
   driver.findElement(By.id("signin_password")).clear();
   driver.findElement(By.id("signin_password")).sendKeys("admin");
   driver.findElement(By.cssSelector("button.button")).click();
   driver.get(baseUrl + "/en/profile/edit");
   driver.findElement(By.xpath("(//img[@alt='Leave this community'])[3]")).click();
   assertTrue(closeAlertAndGetItsText().matches("^Are you sure[\\s\\S]$"));
   driver.findElement(By.xpath("(//img[@alt='Leave this community'])[2]")).click();
   assertTrue(closeAlertAndGetItsText().matches("^Are you sure[\\s\\S]$"));
   driver.findElement(By.cssSelector("a[alt=\"Leave\"]")).click();
   assertTrue(closeAlertAndGetItsText().matches("^Are you sure[\\s\\S]$"));
   driver.findElement(By.id("profile_community_comunity")).click();
   new Select(driver.findElement(By.id("profile_community_community")))
       .selectByVisibleText("My Sample Community #1");
   driver.findElement(By.cssSelector("button")).click();
   new Select(driver.findElement(By.id("profile_community_community")))
       .selectByVisibleText("My Sample Community #2");
   driver.findElement(By.cssSelector("button")).click();
   new Select(driver.findElement(By.id("profile_community_community")))
       .selectByVisibleText("CAPS");
   driver.findElement(By.cssSelector("button")).click();
   driver.findElement(By.cssSelector("button.button.submitButton")).click();
 }
コード例 #2
0
  @Before
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    func = new COTFunctions(driver);
    driver.manage().timeouts().implicitlyWait(func.timeoutOFAllElement, TimeUnit.SECONDS);

    driver.get(func.baseUrl + "/");
    func.CheckLogin();
    func.LoginRole("SchoolAdmin");
    driver.get(func.baseUrl + "/college-search");
  }
コード例 #3
0
  @Before
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    func = new COTFunctions(driver);
    wait = new WebDriverWait(driver, func.timeoutOfOneElement);
    driver.manage().timeouts().implicitlyWait(func.timeoutOFAllElement, TimeUnit.SECONDS);

    driver.get(func.baseUrl + "/");
    func.CheckLogin();
    func.LoginRole("Student");
    driver.get(func.baseUrl + "/document-locker");
  }
コード例 #4
0
  @Test(expected = ElementNotVisibleException.class)
  public void throwExceptionWhenInteractingWithInvisibleElement() {
    server.setGetHandler(
        new HttpRequestCallback() {
          @Override
          public void call(HttpServletRequest req, HttpServletResponse res) throws IOException {
            res.getOutputStream()
                .println(
                    "<!DOCTYPE html>"
                        + "<html>"
                        + "    <head>\n"
                        + "        <title>test</title>\n"
                        + "    </head>\n"
                        + "    <body>\n"
                        + "        <input id=\"visible\">\n"
                        + "        <input style=\"display:none\" id=\"invisible\">\n"
                        + "    </body>"
                        + "</html>");
          }
        });

    WebDriver d = getDriver();
    d.get(server.getBaseUrl());

    WebElement visibleInput = d.findElement(By.id("visible"));
    WebElement invisibleInput = d.findElement(By.id("invisible"));

    String textToType = "text to type";
    visibleInput.sendKeys(textToType);
    assertEquals(textToType, visibleInput.getAttribute("value"));

    invisibleInput.sendKeys(textToType);
  }
コード例 #5
0
ファイル: New4.java プロジェクト: TKosmacki/CS1632
 @Test
 public void testEditProfile() throws Exception {
   driver.get(baseUrl + "/");
   driver.findElement(By.xpath("(//a[contains(text(),'log in')])[2]")).click();
   driver.findElement(By.xpath("(//a[contains(text(),'log in')])[2]")).click();
   driver.findElement(By.id("email")).click();
   driver.findElement(By.id("email")).clear();
   driver.findElement(By.id("email")).sendKeys("*****@*****.**");
   driver.findElement(By.id("password")).clear();
   driver.findElement(By.id("password")).sendKeys("Eliandtyler1");
   driver.findElement(By.id("submit-button")).click();
   driver.findElement(By.id("submit-button")).click();
   driver.findElement(By.cssSelector("img.avatar-me.js-avatar-me")).click();
   driver.findElement(By.cssSelector("img.avatar-me.js-avatar-me")).click();
   driver.findElement(By.linkText("Edit Profile & Settings")).click();
   driver.findElement(By.linkText("Edit Profile & Settings")).click();
   // Warning: assertTextPresent may require manual changes
   assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
   // Warning: assertTextPresent may require manual changes
   assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
   // Warning: assertTextPresent may require manual changes
   assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
   // Warning: assertTextPresent may require manual changes
   assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
   // Warning: assertTextPresent may require manual changes
   assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
 }
コード例 #6
0
  @Ignore({ANDROID, CHROME, HTMLUNIT, IE, IPHONE, OPERA, OPERA_MOBILE, PHANTOMJS, SAFARI})
  @NeedsLocalEnvironment
  @Test
  public void requiredProxyCapabilityShouldHavePriority() {
    ProxyServer desiredProxyServer = new ProxyServer();
    registerProxyTeardown(desiredProxyServer);

    Proxy desiredProxy = desiredProxyServer.asProxy();
    Proxy requiredProxy = proxyServer.asProxy();

    DesiredCapabilities desiredCaps = new DesiredCapabilities();
    desiredCaps.setCapability(PROXY, desiredProxy);
    DesiredCapabilities requiredCaps = new DesiredCapabilities();
    requiredCaps.setCapability(PROXY, requiredProxy);

    WebDriver driver =
        new WebDriverBuilder()
            .setDesiredCapabilities(desiredCaps)
            .setRequiredCapabilities(requiredCaps)
            .get();
    registerDriverTeardown(driver);

    driver.get(pages.simpleTestPage);

    assertFalse(
        "Desired proxy should not have been called.",
        desiredProxyServer.hasBeenCalled("simpleTest.html"));
    assertTrue(
        "Required proxy should have been called.", proxyServer.hasBeenCalled("simpleTest.html"));
  }
コード例 #7
0
  @Test(expected = NoSuchElementException.class)
  public void shouldBeAbleToClickInAFrame() throws InterruptedException {
    WebDriver d = getDriver();

    d.get("http://docs.wpm.neustar.biz/testscript-api/index.html");
    assertEquals("__MAIN_FRAME__", getCurrentFrameName(d));

    d.switchTo().frame("classFrame");
    assertEquals("classFrame", getCurrentFrameName(d));

    // This should cause a reload in the frame "classFrame"
    d.findElement(By.linkText("HttpClient")).click();

    // Wait for new content to load in the frame.
    WebDriverWait wait = new WebDriverWait(d, 10);
    wait.until(ExpectedConditions.titleContains("HttpClient"));

    // Frame should still be "classFrame"
    assertEquals("classFrame", getCurrentFrameName(d));

    // Check if a link "clearCookies()" is there where expected
    assertEquals("clearCookies", d.findElement(By.linkText("clearCookies")).getText());

    // Make sure it was really frame "classFrame" which was replaced:
    // 1. move to the other frame "packageFrame"
    d.switchTo().defaultContent().switchTo().frame("packageFrame");
    assertEquals("packageFrame", getCurrentFrameName(d));
    // 2. the link "clearCookies()" shouldn't be there anymore
    d.findElement(By.linkText("clearCookies"));
  }
コード例 #8
0
  @Ignore(
      value = {ANDROID, IPHONE, OPERA_MOBILE, PHANTOMJS, SAFARI},
      reason = "Android/Iphone/PhantomJS - not tested," + "Opera mobile/Safari - not implemented")
  @NeedsLocalEnvironment
  @Test
  public void canConfigureProxyThroughPACFile() {
    WebServer helloServer =
        createSimpleHttpServer("<!DOCTYPE html><title>Hello</title><h3>Hello, world!</h3>");
    WebServer pacFileServer =
        createPacfileServer(
            Joiner.on('\n')
                .join(
                    "function FindProxyForURL(url, host) {",
                    "  return 'PROXY " + getHostAndPort(helloServer) + "';",
                    "}"));

    Proxy proxy = new Proxy();
    proxy.setProxyAutoconfigUrl("http://" + getHostAndPort(pacFileServer) + "/proxy.pac");

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability(PROXY, proxy);

    WebDriver driver = new WebDriverBuilder().setDesiredCapabilities(caps).get();
    registerDriverTeardown(driver);

    driver.get(pages.mouseOverPage);
    assertEquals(
        "Should follow proxy to another server",
        "Hello, world!",
        driver.findElement(By.tagName("h3")).getText());
  }
コード例 #9
0
ファイル: Test5 - копия.java プロジェクト: Dmitro13/Test
  //  Delete CSR
  @Test
  public void Test5() throws Exception {
    driver.get(baseUrl + "/#/host/magehostmanager.magemojo.com/configuration/ssl");
    driver.findElement(By.xpath("//a[contains(text(),'www.Testing5.com')]")).click();
    assertEquals(
        "Download CSR www.Testing5.com", driver.findElement(By.xpath("//legend[4]")).getText());
    driver.findElement(By.xpath("(//button[@type='button'])[8]")).click();
    assertEquals(
        "Confirmation Window",
        driver.findElement(By.cssSelector("h3.modal-title.ng-binding")).getText());
    assertTrue(isElementPresent(By.xpath("//div[3]/button[2]")));
    driver.findElement(By.xpath("//div[3]/button")).click();

    for (int second = 0; ; second++) {
      if (second >= 60) fail("timeout");
      try {
        if ("Successfully deleted the CSR."
            .equals(driver.findElement(By.xpath("//div[@id='toast-container']/div")).getText()))
          break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    for (int second = 0; ; second++) {
      if (second >= 60) fail("timeout");
      try {
        if (!isElementPresent(By.xpath("//a[contains(text(),'www.Testing5.com')]"))) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }
  }
コード例 #10
0
ファイル: test24.java プロジェクト: Mouna1991/FinalTest
 @Test
 public void testTemp() throws Exception {
   driver.get("http://cse.unl.edu/~mouna/WebApps/AddressBook/addressbookv3.4.7/index.php");
   driver
       .findElement(
           By.cssSelector(
               "html > body > table > tbody > tr:nth-child(2) > td:nth-child(3) > form > table:nth-child(2) > tbody > tr:nth-child(1) > td:nth-child(7) > a > img"))
       .click();
   driver.findElement(By.name("firstname")).clear();
   driver.findElement(By.name("firstname")).sendKeys("JamesEDIT");
   driver.findElement(By.name("lastname")).clear();
   driver.findElement(By.name("lastname")).sendKeys("PittEDIT");
   driver.findElement(By.name("address")).clear();
   driver.findElement(By.name("address")).sendKeys("44545 R street EDIT");
   driver.findElement(By.name("home")).clear();
   driver.findElement(By.name("home")).sendKeys("454545455 8989");
   driver.findElement(By.name("mobile")).clear();
   driver.findElement(By.name("mobile")).sendKeys("454554555 2398");
   driver.findElement(By.name("work")).clear();
   driver.findElement(By.name("work")).sendKeys("455455555 32323");
   driver.findElement(By.name("email")).clear();
   driver.findElement(By.name("email")).sendKeys("[email protected] EDIT");
   driver.findElement(By.name("email2")).clear();
   driver.findElement(By.name("email2")).sendKeys("[email protected] EDIT");
   driver.findElement(By.name("address2")).clear();
   driver.findElement(By.name("address2")).sendKeys("EDIT");
   driver.findElement(By.name("phone2")).clear();
   driver.findElement(By.name("phone2")).sendKeys("EDIT");
   driver.findElement(By.name("update")).click();
 }
コード例 #11
0
  public static void main(String[] args) {
    String baseUrl = "http://newtours.demoaut.com/";
    WebDriver driver = new FirefoxDriver();
    String underConsTitle = "Under Construction: Mercury Tours"; // Creates result string
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

    driver.get(baseUrl);
    List<WebElement> linkElements =
        driver.findElements(By.tagName("a")); // Creates lists from <a> tags
    String[] linkTexts = new String[linkElements.size()];
    int i = 0;

    // extract the link texts of each link element
    for (WebElement e : linkElements) {
      linkTexts[i] = e.getText();
      i++;
    }

    // test each link by looping over them
    for (String t : linkTexts) {
      driver.findElement(By.linkText(t)).click();
      if (driver.getTitle().equals(underConsTitle)) {
        System.out.println("\"" + t + "\"" + " is under construction.");
      } else {
        System.out.println(
            "\""
                + t
                + "\"" // print results to console
                + " is working.");
      }
      driver.navigate().back();
    }
    driver.quit();
  }
コード例 #12
0
 // *** Supression des risques de banques
 @Test
 public void testSSV8VALDEBTA997IntegrationTests() throws Exception {
   driver.get(baseUrl + "/selectsystem-view-tomcat-oracle/login.xhtml");
   Thread.sleep(1000);
   findElement(By.id("j_username")).clear();
   findElement(By.id("j_username")).sendKeys("usercenter");
   Thread.sleep(1000);
   findElement(By.id("j_password")).clear();
   findElement(By.id("j_password")).sendKeys("pwd8888");
   findElement(By.cssSelector("#login > img[alt=\"Frensh\"]")).click();
   optionalClick(By.xpath("//span/a"));
   findElement(By.id("form:table:0:sdksds")).click();
   findElement(By.xpath("(//img[@alt='English'])[11]")).click();
   findElement(By.linkText("Managing Risk")).click();
   new Select(findElement(By.id("globalIssuerRiskBankManagementForm:titletttrrrr")))
       .selectByVisibleText("banque test 1");
   Thread.sleep(1000);
   findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click();
   findElement(By.xpath("//td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[3]/a")).click();
   findElement(By.xpath("//tr[2]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[3]/a")).click();
   findElement(By.xpath("//tr[3]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[3]/a")).click();
   findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click();
   new Select(findElement(By.id("globalIssuerRiskBankManagementForm:titletttrrrr")))
       .selectByVisibleText("banque test 2");
   Thread.sleep(1000);
   findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click();
   findElement(By.xpath("//td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[2]/a")).click();
   findElement(By.xpath("//tr[2]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[2]/a")).click();
   findElement(By.xpath("//tr[3]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[2]/a")).click();
   findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click();
   new Select(findElement(By.id("globalIssuerRiskBankManagementForm:titletttrrrr")))
       .selectByVisibleText("banque test 3");
   Thread.sleep(1000);
   findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click();
   findElement(By.xpath("//td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[3]/a")).click();
   findElement(By.xpath("//tr[2]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[3]/a")).click();
   findElement(By.xpath("//tr[3]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[3]/a")).click();
   findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click();
   new Select(findElement(By.id("globalIssuerRiskBankManagementForm:titletttrrrr")))
       .selectByVisibleText("banque test 2");
   Thread.sleep(1000);
   findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click();
   findElement(By.xpath("//td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[3]/a")).click();
   findElement(By.xpath("//tr[2]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[3]/a")).click();
   findElement(By.xpath("//tr[3]/td[3]/center/table/tbody/tr/td[3]/span/a/img")).click();
   findElement(By.xpath("//td/div[3]/a")).click();
   findElement(By.id("globalIssuerRiskBankManagementForm:hs5414")).click();
   findElement(By.xpath("(//img[@alt='English'])[2]")).click();
 }
コード例 #13
0
ファイル: EbselenCommands.java プロジェクト: windsoul/Ebselen
 /**
  * Open site homepage and check that it has loaded correctly. This will set the currently selected
  * site to the value of page
  *
  * @param homepageURL URL of the homepage
  * @param homePageElement If homePageElement is not null kill tests if it does not exist
  */
 public void openHomepage(String homepageURL, WebElement homePageElement) throws Exception {
   driver.get(homepageURL);
   if (homePageElement != null) {
     if (!homePageElement.isDisplayed()) {
       throw new HomepageNotLoadedException();
     }
   }
 }
コード例 #14
0
 @Test
 public void testSigninNotificador() throws Exception {
   driver.get(baseUrl + "/sincap/");
   driver.findElement(By.id("username")).clear();
   driver.findElement(By.id("username")).sendKeys("222.222.222-22");
   driver.findElement(By.id("password")).clear();
   driver.findElement(By.id("password")).sendKeys("abc123");
   driver.findElement(By.id("botaoLogin")).click();
 }
コード例 #15
0
 private void runScenarioWithUnhandledAlert(String expectedAlertText) {
   driver2.get(pages.alertsPage);
   driver2.findElement(By.id("prompt-with-default")).click();
   try {
     driver2.findElement(By.id("text")).getText();
   } catch (UnhandledAlertException expected) {
   }
   waitFor(elementTextToEqual(driver2, By.id("text"), expectedAlertText));
 }
コード例 #16
0
 // *** l'utilisation des données "......"
 // ** et des données de longeurs de "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn"
 // pour le champ nom
 // * l'impossibilité de modifier l'id d'un motif de remplacemnt une fois enregistré
 @Test
 public void testSSV8VALDEBTA008cIntegrationTests() throws Exception {
   driver.get(baseUrl + "/selectsystem-view-tomcat-oracle/login.xhtml");
   Thread.sleep(1000);
   findElement(By.id("j_username")).clear();
   findElement(By.id("j_username")).sendKeys("usercenter");
   Thread.sleep(1000);
   findElement(By.id("j_password")).clear();
   findElement(By.id("j_password")).sendKeys("pwd8888");
   findElement(By.cssSelector("#login > img[alt=\"Frensh\"]")).click();
   optionalClick(By.xpath("//span/a"));
   findElement(By.id("form:table:1:sdksds")).click();
   findElement(By.xpath("(//img[@alt='English'])[4]")).click();
   findElement(By.xpath("(//a[contains(text(),'Card Replacement Motif')])[2]")).click();
   new Select(findElement(By.id("globalCardReplacementMotifForm:bank")))
       .selectByVisibleText("banque test 3");
   Thread.sleep(1000);
   findElement(By.xpath("//table[@id='globalCardReplacementMotifForm:AZ']/tbody/tr/td/a[3]/img"))
       .click();
   Thread.sleep(1000);
   findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).clear();
   findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).sendKeys("..........");
   Thread.sleep(1000);
   findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).clear();
   findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).sendKeys("ReasRp_031");
   findElement(By.cssSelector("img[alt=\"save2\"]")).click();
   findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click();
   findElement(By.xpath("//table[@id='globalCardReplacementMotifForm:AZ']/tbody/tr/td/a[3]/img"))
       .click();
   Thread.sleep(1000);
   findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).clear();
   findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).sendKeys("ReasRp_031");
   Thread.sleep(1000);
   findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).clear();
   findElement(By.id("globalCardReplacementMotifForm:inputLabeeee"))
       .sendKeys("nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn");
   findElement(By.cssSelector("img[alt=\"save2\"]")).click();
   findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click();
   findElement(By.xpath("//table[@id='globalCardReplacementMotifForm:AZ']/tbody/tr/td/a[3]/img"))
       .click();
   Thread.sleep(1000);
   findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).clear();
   findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).sendKeys("ReasRp_033");
   Thread.sleep(1000);
   findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).clear();
   findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).sendKeys("ReasRp_033");
   findElement(By.cssSelector("img[alt=\"save2\"]")).click();
   findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click();
   findElement(
           By.id(
               "globalCardReplacementMotifForm:searchCardDesignFeesResultsId:0:scxqsjhvcqjshcvhqsceee"))
       .click();
   findElement(By.cssSelector("img[alt=\"save2\"]")).click();
   findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click();
   findElement(By.xpath("(//img[@alt='English'])[2]")).click();
 }
コード例 #17
0
 @Test
 public void testBookSearch5() throws Exception {
   driver.get(baseUrl + "/proyectoBiblioteca/");
   new Select(driver.findElement(By.name("type"))).selectByVisibleText("Editorial");
   driver.findElement(By.name("search")).clear();
   driver.findElement(By.name("search")).sendKeys("De Bolsillo");
   driver.findElement(By.xpath("//button[@type='submit']")).click();
   assertEquals(
       "Libros Encontrados", driver.findElement(By.cssSelector("div.panel-heading")).getText());
 }
コード例 #18
0
 @Test
 public void testLoginMaster2() throws Exception {
   driver.get(baseUrl + "/login.html");
   driver.findElement(By.name("j_username")).clear();
   driver.findElement(By.name("j_username")).sendKeys("*****@*****.**");
   driver.findElement(By.name("j_password")).clear();
   driver.findElement(By.name("j_password")).sendKeys("master");
   driver.findElement(By.xpath("//input[@value='Login']")).click();
   driver.findElement(By.linkText("Sign out")).click();
 }
コード例 #19
0
ファイル: TestBase.java プロジェクト: rubyraj/insanity
 public static WebDriver navigateToPage(String url) {
   String baseUrl = "http://demo.opensourcecms.com/";
   driver = TestBase.setDriver("firefox");
   driver.get(baseUrl + url);
   driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
   //		Boolean myDynamicElement = (new WebDriverWait(driver, 10))
   //				.until( ExpectedConditions.titleContains("WordPress") );
   //		System.out.println(myDynamicElement);
   return driver;
 }
コード例 #20
0
  @Test(expected = TimeoutException.class)
  public void shouldTimeoutWhileChangingIframeSource() {
    final String iFrameId = "iframeId";

    // Define HTTP response for test
    server.setGetHandler(
        new HttpRequestCallback() {
          @Override
          public void call(HttpServletRequest req, HttpServletResponse res) throws IOException {
            String pathInfo = req.getPathInfo();
            ServletOutputStream out = res.getOutputStream();

            if (pathInfo.endsWith("iframe_content.html")) {
              // nested frame 1
              out.println("iframe content");
            } else {
              // main page
              out.println(
                  "<html>\n"
                      + "<body>\n"
                      + "  <iframe id='"
                      + iFrameId
                      + "'></iframe>\n"
                      + "  <script>\n"
                      + "  setTimeout(function() {\n"
                      + "    document.getElementById('"
                      + iFrameId
                      + "').src='iframe_content.html';\n"
                      + "  }, 2000);\n"
                      + "  </script>\n"
                      + "</body>\n"
                      + "</html>");
            }
          }
        });

    // Launch Driver against the above defined server
    WebDriver d = getDriver();
    d.get(server.getBaseUrl());

    // Switch to iframe
    d.switchTo().frame(iFrameId);
    assertEquals(0, d.findElements(By.id(iFrameId)).size());
    assertFalse(d.getPageSource().toLowerCase().contains("iframe content"));

    new WebDriverWait(d, 5)
        .until(
            new Predicate<WebDriver>() {
              @Override
              public boolean apply(@Nullable WebDriver driver) {
                assertEquals(0, driver.findElements(By.id(iFrameId)).size());
                return (Boolean) ((JavascriptExecutor) driver).executeScript("return false;");
              }
            });
  }
コード例 #21
0
  @Ignore(
      value = {ANDROID, IPHONE, OPERA_MOBILE, PHANTOMJS, SAFARI},
      reason = "Android/Iphone/PhantomJS - not tested," + "Opera mobile/Safari - not implemented")
  @NeedsLocalEnvironment
  @Test
  public void canUsePACThatOnlyProxiesCertainHosts() throws Exception {
    WebServer helloServer =
        createSimpleHttpServer("<!DOCTYPE html><title>Hello</title><h3>Hello, world!</h3>");
    WebServer goodbyeServer =
        createSimpleHttpServer("<!DOCTYPE html><title>Goodbye</title><h3>Goodbye, world!</h3>");
    WebServer pacFileServer =
        createPacfileServer(
            Joiner.on('\n')
                .join(
                    "function FindProxyForURL(url, host) {",
                    "  if (url.indexOf('" + getHostAndPort(helloServer) + "') != -1) {",
                    "    return 'PROXY " + getHostAndPort(goodbyeServer) + "';",
                    "  }",
                    "  return 'DIRECT';",
                    "}"));

    Proxy proxy = new Proxy();
    proxy.setProxyAutoconfigUrl("http://" + getHostAndPort(pacFileServer) + "/proxy.pac");

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability(PROXY, proxy);

    WebDriver driver = new WebDriverBuilder().setDesiredCapabilities(caps).get();
    registerDriverTeardown(driver);

    driver.get("http://" + getHostAndPort(helloServer));
    assertEquals(
        "Should follow proxy to another server",
        "Goodbye, world!",
        driver.findElement(By.tagName("h3")).getText());

    driver.get(pages.simpleTestPage);
    assertEquals(
        "Proxy should have permitted direct access to host",
        "Heading",
        driver.findElement(By.tagName("h1")).getText());
  }
コード例 #22
0
  /**
   * Basically visits your baseUrl link and starts over
   *
   * @throws InterruptedException
   */
  public void startNewChat(ArrayList<String> topics) throws InterruptedException {
    chatTranscript = "";
    newMessage = "";
    driver.get(baseUrl);

    for (String topic : topics) {
      addTopic(topic);
    }

    driver.findElement(By.id("textbtn")).click();
  }
コード例 #23
0
  @Test
  public void checkAttributesOnGoogleSearchBox() {
    WebDriver d = getDriver();

    d.get("http://www.google.com");
    WebElement el = d.findElement(By.cssSelector("input[name*='q']"));

    assertTrue(el.getAttribute("name").toLowerCase().contains("q"));
    assertTrue(el.getAttribute("type").toLowerCase().contains("text"));
    assertTrue(el.getAttribute("style").length() > 0);
    assertTrue(el.getAttribute("type").length() > 0);
  }
コード例 #24
0
 @Test
 public void testIncorrectIncorrect() throws Exception {
   driver.get(baseUrl + "/");
   driver.findElement(By.linkText("Log In")).click();
   driver.findElement(By.id("navbar_username")).clear();
   driver.findElement(By.id("navbar_username")).sendKeys("wrong");
   driver.findElement(By.id("navbar_password")).clear();
   driver.findElement(By.id("navbar_password")).sendKeys("wrong");
   driver.findElement(By.cssSelector("input.button")).click();
   assertEquals("Log In", driver.findElement(By.linkText("Log In")).getText());
   driver.findElement(By.cssSelector("img[alt=\"Myth-Weavers\"]")).click();
 }
コード例 #25
0
 @Test
 public void switchToFrameByElement() {
   WebDriver d = getDriver();
   d.get("http://docs.wpm.neustar.biz/testscript-api/index.html");
   assertEquals("__MAIN_FRAME__", getCurrentFrameName(d));
   d.switchTo().frame(d.findElement(By.name("packageFrame")));
   assertEquals("packageFrame", getCurrentFrameName(d));
   d.switchTo().defaultContent();
   assertEquals("__MAIN_FRAME__", getCurrentFrameName(d));
   d.switchTo().frame(d.findElement(By.name("packageFrame")));
   assertEquals("packageFrame", getCurrentFrameName(d));
 }
コード例 #26
0
 @Test
 public void titleShouldReturnWindowTitle() {
   WebDriver d = getDriver();
   d.get("http://docs.wpm.neustar.biz/testscript-api/index.html");
   assertEquals("__MAIN_FRAME__", getCurrentFrameName(d));
   String topLevelTitle = d.getTitle();
   d.switchTo().frame("packageFrame");
   assertEquals("packageFrame", getCurrentFrameName(d));
   assertEquals(topLevelTitle, d.getTitle());
   d.switchTo().defaultContent();
   assertEquals(topLevelTitle, d.getTitle());
 }
コード例 #27
0
 @Test
 public void testMyFirstWebDriver() throws Exception {
   driver.get(baseUrl + "/HotelApp/");
   driver.findElement(By.linkText("New User Register Here")).isDisplayed();
   driver.findElement(By.xpath(".//*[@id='username']")).clear();
   driver.findElement(By.xpath(".//*[@id='username']")).sendKeys("");
   driver.findElement(By.id("password")).clear();
   driver.findElement(By.id("password")).sendKeys("");
   driver.findElement(By.id("login")).click();
   //   actualText = driver.findElement(By.id("username_span")).getText();
   actualText = driver.findElement(By.cssSelector(".login_error")).getText();
   assertEquals(expectedText, actualText);
 }
コード例 #28
0
  @Test
  public void scrollElementIntoView() {
    WebDriver d = getDriver();

    d.get("https://developer.mozilla.org/en/CSS/Attribute_selectors");
    WebElement aboutGoogleLink = d.findElement(By.partialLinkText("About MDN"));
    Point locationBeforeScroll = aboutGoogleLink.getLocation();
    Point locationAfterScroll =
        ((Locatable) aboutGoogleLink).getLocationOnScreenOnceScrolledIntoView();

    assertTrue(locationBeforeScroll.x >= locationAfterScroll.x);
    assertTrue(locationBeforeScroll.y >= locationAfterScroll.y);
  }
  @Test
  public void testAbcd() throws Exception {
    driver.get(baseUrl + "/");
    driver.findElement(By.linkText("Sign In")).click();

    driver.findElement(By.linkText("Sign In")).getText();
    driver.findElement(By.xpath("//input[@name='loginName']")).clear();
    driver.findElement(By.xpath("//input[@name='loginName']")).sendKeys("*****@*****.**");
    driver.findElement(By.xpath("//input[@name='password']")).clear();
    driver.findElement(By.xpath("//input[@name='password']")).sendKeys("demo123");
    driver.findElement(By.xpath("//input[@type='image']")).click();
    driver.findElement(By.linkText("Money")).click();

    driver.findElement(By.linkText("Portfolio")).click();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    WebElement table = driver.findElement(By.id("table-holding-data"));

    if (table.isDisplayed()) {

      List<WebElement> rows = table.findElements(By.tagName("tr"));

      System.out.println("Row Count - " + rows.size());

      Iterator<WebElement> i = rows.iterator();

      System.out.println("Table has following content");

      while (i.hasNext()) {

        WebElement row = i.next();

        List<WebElement> columns = row.findElements(By.tagName("td"));

        Iterator<WebElement> j = columns.iterator();

        while (j.hasNext()) {

          WebElement column = j.next();

          System.out.print(column.getText());

          System.out.print("    |  ");
        }
        System.out.println("--------------------");
      }
      System.out.println("Table content is printed");
    } else {
      System.out.println("Table not found");
    }
  }
コード例 #30
0
 @Test
 public void testNotificacaoObito() throws Exception {
   driver.get(baseUrl + "/sincap/");
   driver.findElement(By.id("username")).clear();
   driver.findElement(By.id("username")).sendKeys("111.111.111-11");
   driver.findElement(By.id("password")).clear();
   driver.findElement(By.id("password")).sendKeys("abc123");
   driver.findElement(By.id("botaoLogin")).click();
   driver.findElement(By.xpath("//ul[@id='dashboard-menu']/li[2]/a/span")).click();
   driver.findElement(By.id("obito-tipoObito")).click();
   new Select(driver.findElement(By.id("obito-tipoObito"))).selectByVisibleText("PCR");
   driver.findElement(By.cssSelector("option[value=\"PCR\"]")).click();
   new Select(driver.findElement(By.id("obito-paciente-documentoSocial-tipoDocumentoComFoto")))
       .selectByVisibleText("RG");
   driver.findElement(By.id("obito-paciente-documentoSocial-documento")).clear();
   driver.findElement(By.id("obito-paciente-documentoSocial-documento")).sendKeys("3546545333");
   driver.findElement(By.id("obito-paciente-nome")).clear();
   driver.findElement(By.id("obito-paciente-nome")).sendKeys("Notificacao de obito");
   driver.findElement(By.id("obito-paciente-dataNascimento")).clear();
   driver.findElement(By.id("obito-paciente-dataNascimento")).sendKeys("12/04/1985");
   driver.findElement(By.id("obito-paciente-dataInternacao")).clear();
   driver.findElement(By.id("obito-paciente-dataInternacao")).sendKeys("10/08/2015");
   driver.findElement(By.cssSelector("span.checked")).click();
   driver.findElement(By.id("obito-paciente-sexo:0")).click();
   driver.findElement(By.id("obito-paciente-nomeMae")).clear();
   driver.findElement(By.id("obito-paciente-nomeMae")).sendKeys("Mae do obito");
   driver.findElement(By.id("obito-paciente-numeroSUS")).clear();
   driver.findElement(By.id("obito-paciente-numeroSUS")).sendKeys("156234434345");
   driver.findElement(By.id("obito-paciente-numeroProntuario")).clear();
   driver.findElement(By.id("obito-paciente-numeroProntuario")).sendKeys("2564554643");
   driver.findElement(By.id("descricaoComentario")).clear();
   driver.findElement(By.id("descricaoComentario")).sendKeys("comentario 1");
   driver.findElement(By.id("btn-next")).click();
   driver.findElement(By.id("obito-dataObito")).clear();
   driver.findElement(By.id("obito-dataObito")).sendKeys("13/08/2015");
   driver.findElement(By.id("horarioObito")).clear();
   driver.findElement(By.id("horarioObito")).sendKeys("10:21");
   new Select(driver.findElement(By.id("obito-setor"))).selectByVisibleText("CIRURGIA GERAL");
   new Select(driver.findElement(By.id("obito-corpoEncaminhamento"))).selectByVisibleText("IML");
   driver.findElement(By.xpath("//div[@id='uniform-obito-aptoDoacao:0']/span")).click();
   driver.findElement(By.id("obito-aptoDoacao:0")).click();
   driver.findElement(By.id("obito-primeiraCausaMortis")).clear();
   driver.findElement(By.id("obito-primeiraCausaMortis")).sendKeys("causa 1");
   driver.findElement(By.id("obito-segundaCausaMortis")).clear();
   driver.findElement(By.id("obito-segundaCausaMortis")).sendKeys("causa 2");
   driver.findElement(By.id("obito-terceiraCausaMortis")).clear();
   driver.findElement(By.id("obito-terceiraCausaMortis")).sendKeys("causa 3");
   driver.findElement(By.id("obito-quartaCausaMortis")).clear();
   driver.findElement(By.id("obito-quartaCausaMortis")).sendKeys("causa 4");
   driver.findElement(By.xpath("(//button[@type='button'])[3]")).click();
 }