Package org.openqa.selenium

Examples of org.openqa.selenium.WebDriver


    public void register_interceptor(@Observes EventContext<Test> ctx) {
        invoked = false;
        try {
            Test event = ctx.getEvent();
            if (event.getTestClass().getJavaClass() == TestInterceptorRegistration.class) {
                WebDriver browser = org.jboss.arquillian.graphene.context.GrapheneContext.getContextFor(Default.class).getWebDriver();
                ((GrapheneProxyInstance) browser).registerInterceptor(new Interceptor() {

                    @Override
                    public Object intercept(InvocationContext context) throws Throwable {
                        invoked = true;
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

      }
     
      public static void testGoogleSuggest() throws Exception {
     
          // The Firefox driver supports javascript
          WebDriver driver = new FirefoxDriver();
         
          // Go to the Google Suggest home page
          driver.get("http://www.google.com/webhp?complete=1&hl=en");
         
          // Enter the query string "Cheese"
          WebElement query = driver.findElement(By.name("q"));
          query.sendKeys("Cheese");

          // Sleep until the div we want is visible or 5 seconds is over
          long end = System.currentTimeMillis() + 5000;
          while (System.currentTimeMillis() < end) {
              WebElement resultsDiv = driver.findElement(By.className("gsq_a"));

              // If results have been returned, the results are displayed in a drop down.
              if (resultsDiv.isDisplayed()) {
                break;
              }
          }

          // And now list the suggestions
          List<WebElement> allSuggestions = driver.findElements(By.className("gsq_a"));
         
          for (WebElement suggestion : allSuggestions) {
              System.out.println(suggestion.getText());
          }
       }
View Full Code Here

        waitForRC();

        DesiredCapabilities dc = DesiredCapabilities.htmlUnit();
        dc.setCapability("jenkins.label", "foo");
        WebDriver wd = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), dc);

        try {
            wd.get("http://www.google.com/");
            new WebDriverWait(wd, 10).until(ExpectedConditions.presenceOfElementLocated(By.tagName("title")));
        } finally {
            wd.quit();
        }

        dc = DesiredCapabilities.htmlUnit();
        System.out.println("jenkins.label=foolabel");
        dc.setCapability("jenkins.label", "foolabel");
        try {
            WebDriver dr = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), dc);
            dr.quit();
        } catch (Exception e) {
            fail(e.getMessage()); // should have passed
        }

        System.out.println("jenkins.nodeName=foo");
        dc = DesiredCapabilities.htmlUnit();
        dc.setCapability("jenkins.nodeName", "foo");
        try {
            WebDriver dr = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), dc);
            dr.quit();
        } catch (Exception e) {
            fail(e.getMessage()); // should have passed
        }

        dc.setCapability("jenkins.label", "foolabel");
        System.out.println("jenkins.label=foolabel & jenkins.nodeName=foo");
        try {
            WebDriver dr = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), dc);
            dr.quit();
        } catch (Exception e) {
            fail(e.getMessage()); // should have passed
        }

        dc = DesiredCapabilities.htmlUnit();
View Full Code Here

*/
public class PrepareBrowserSession {

    public void prepare(@Observes AfterDroneEnhanced event) {

        WebDriver browser = event.getInstance().asInstance(WebDriver.class);
        if (BrowserUtils.isPhantomjs(browser)) {
            browser.manage().window().setSize(new Dimension(1280, 1024));
        }
    }
View Full Code Here

     *
     * @see org.jboss.arquillian.drone.spi.Instantiator#createInstance(org.jboss.arquillian.drone.spi.DroneConfiguration)
     */
    @Override
    public WebDriver createInstance(TypedWebDriverConfiguration<WebDriverConfiguration> configuration) {
        WebDriver driver = super.createInstance(configuration);

        if (GrapheneProxy.isProxyInstance(driver)) {
            return driver;
        }

        WebDriver proxy = GrapheneContext.getProxyForDriver(WebDriver.class);
        GrapheneContext.set(driver);
        return proxy;
    }
View Full Code Here

        url += "?" + Joiner.on("&").join(params);
      }
      Echo.echo("- Running " + url);

      try {
        WebDriver driver = wdh.begin();
        driver.get(url);
        result = driveBrowser(driver);
        passed = true;
      } finally {
        captureResults(label, passed);
        wdh.end(passed || isKnownFailure);
View Full Code Here

  @Override
  public void stop() {
    logger.info(">> stopRC... ");
    // Get the underlying WebDriver implementation back. This will refer to the
    // same WebDriver instance as the "driver" variable above.
    WebDriver driverInstance = ((WebDriverBackedSelenium) selenium)
        .getWrappedDriver();

    // Finally, close the browser. Call stop on the WebDriverBackedSelenium
    // instance
    // instead of calling driver.quit(). Otherwise, the JVM will continue
View Full Code Here

     * Unwraps the proxy
     */
    @Override
    public WebDriver deenhance(WebDriver enhancedDriver, Class<? extends Annotation> qualifier) {
        if (enhancedDriver instanceof GrapheneProxyInstance) {
            WebDriver driver = ((GrapheneProxyInstance) enhancedDriver).unwrap();
            GrapheneContext.removeContextFor(qualifier);
            return driver;
        }
        return enhancedDriver;
    }
View Full Code Here

    }

    public <T> T goTo(Class<T> pageObject, Class<?> browserQualifier) {
        T result = null;
        GrapheneContext grapheneContext = GrapheneContext.getContextFor(browserQualifier);
        WebDriver browser = grapheneContext.getWebDriver();
        try {
            result = PageObjectEnricher.setupPage(grapheneContext, browser, pageObject);
        } catch (Exception e) {
            throw new GrapheneTestEnricherException("Error while initializing: " + pageObject, e);
        }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.WebDriver

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.