Package org.openqa.selenium.htmlunit

Examples of org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitTargetLocator


  protected AuthorizationCodeRequestHandler getAuthorizationCodeRequestHandler() {
    return authorizationCodeRequestHandler;
  }

  private static void initHtmlUnitDriver() {
    initDriver(new HtmlUnitDriver());
  }
View Full Code Here


            {
               for (int i = 0; i < REQUESTS_PER_THREAD; i++)
               {
                  String uuid = UUID.randomUUID().toString();

                  WebDriver driver = new HtmlUnitDriver();
                  driver.get(baseUrl + "test/" + uuid + "/");

                  if (driver.getPageSource().contains("The parameter is [" + uuid + "]")) {
                     successCounter.addAndGet(1);
                  }
                  else {
                     System.out.println("foo!");
                  }
View Full Code Here

    }

    @Test
    public void runOnlyIfHtmlUnit() {
        Assume.assumeTrue(driver instanceof HtmlUnitDriver);
        HtmlUnitDriver htmlDriver = (HtmlUnitDriver) driver;
        Assert.assertTrue("JavaScript is enabled", htmlDriver.isJavascriptEnabled());
    }
View Full Code Here

   @Test
   public void formUrlShouldBeSameAsRenderedView() throws Exception
   {

      HtmlUnitDriver driver = new HtmlUnitDriver();

      // Load page1 and click on the button which will render page2 (without faces-redirect=true)
      driver.get(baseUrl + "page1.jsf");
      driver.findElementById("form1:goto-page2").click();

      // The form URL on page2 should NOT point to page1
      String actionUrl = driver.findElementById("form2").getAttribute("action");
      assertThat(actionUrl, Matchers.containsString("page2"));

      // Click the button which creates a FacesMessage. Due to #166 this fails with a ViewExpiredException
      driver.findElementById("form2:create-message").click();
      assertThat(driver.getPageSource(), Matchers.containsString("Action method got executed"));

   }
View Full Code Here

   private java.net.URL baseUrl;

   @Test
   public void testRedirectToUrlWithAnchor() throws Exception
   {
      WebDriver driver = new HtmlUnitDriver();
      driver.get(baseUrl.toString() + "do");
      assertThat(driver.getCurrentUrl()).endsWith("/it#now");
   }
View Full Code Here

   private WebDriver createBrowserAndLoadPage(final boolean cookies)
   {

      // custom HtmlUnitDriver with cookies enabled or disabled
      WebDriver driver = new HtmlUnitDriver() {
         @Override
         protected WebClient modifyWebClient(WebClient client)
         {
            client.getCookieManager().setCookiesEnabled(cookies);
            return client;
         }
      };

      // load the page twice to get rid of jsessionid if cookies are enabled
      driver.get(baseUrl + "test");
      driver.get(baseUrl + "test");

      return driver;

   }
View Full Code Here

               for (int i = 0; i < REQUESTS_PER_THREAD; i++) {

                  String uuid = UUID.randomUUID().toString();

                  WebDriver driver = new HtmlUnitDriver();
                  driver.get(baseUrl + "test/" + uuid + "/");

                  if (driver.getPageSource().contains("The parameter is [" + uuid + "]")) {
                     successCounter.addAndGet(1);
                  }

               }
View Full Code Here

    public String login(String url) {
        String sessionId;
        WebDriver driver = null;
        try {
            driver = new HtmlUnitDriver();
            driver.navigate().to(url);

            WebElement form = driver.findElement(By.id("oauth_form"));
            WebElement userField = form.findElement(By.id("username_or_email"));
            WebElement passwordField = form.findElement(By.id("password"));
View Full Code Here

        } else if ("chrome".equals(browserName)) {
          initChromeDriver();
        } else if ("safari".equals(browserName)) {
          webDriver = new SafariDriver();
        } else if ("headless".equals(browserName)) {
          HtmlUnitDriver driver = new HtmlUnitDriver(true);
          webDriver = driver;
        } else {
          webDriver = new FirefoxDriver();
        }
      } else {
View Full Code Here

        }
      }
     
      public static void testGoogleSearch(){
          // Create a new instance of the html unit driver
          WebDriver driver = new HtmlUnitDriver();

          // And now use this to visit Google
          driver.get("http://www.google.com");

          // Find the text input element by its name
          WebElement element = driver.findElement(By.name("q"));

          // Enter something to search for
          element.sendKeys("Cheese!");

          // Now submit the form. WebDriver will find the form for us from the element
          element.submit();
         
          //*** return the next page object

          // Check the title of the page
          String pageTitle = driver.getTitle();
          System.out.println("Page title is: " + pageTitle);
          assertTrue("Got title: " + pageTitle, pageTitle.contains("Cheese!"));
      }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitTargetLocator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.