Package org.openqa.selenium

Examples of org.openqa.selenium.WebDriver


    performImplicitGrant(false);
  }

  private void performImplicitGrant(boolean needConsent) {

    WebDriver webdriver = getWebDriver();

    String responseType = "token";
    String clientId = "it-test-client-grant";
    String redirectUri = "http://localhost:8080/fourOhFour";

    String url = String.format(
        "%s/oauth2/authorize?response_type=%s&client_id=%s&redirect_uri=%s",
        baseUrl(), responseType, clientId, redirectUri);
    webdriver.get(url);

    login(webdriver, needConsent);

    // Token response
    URI responseURI = URI.create(webdriver.getCurrentUrl());

    assertThat(responseURI.getFragment(), containsString("access_token="));
    assertThat(responseURI.getPath(), equalTo("/fourOhFour"));
    assertThat(responseURI.getHost(), equalTo("localhost"));
  }
View Full Code Here


  @Test
  public void authCode() throws Exception {
    String accessTokenRedirectUri = startAuthorizationCallbackServer(clientId, secret);

    WebDriver webdriver = getWebDriver();
    String responseType = "code";
    String scopes = "read,write";
    String url = String.format(
        "%s/oauth2/authorize?response_type=%s&scope=%s&client_id=%s&redirect_uri=%s",
        baseUrl(), responseType, scopes, clientId, accessTokenRedirectUri);
    webdriver.get(url);

    login(webdriver,false);
   
    // get token response
    String tokenResponse = getAuthorizationCodeRequestHandler().getTokenResponseBlocking();
View Full Code Here

    assertEquals(accessTokenResponse.getExpiresIn(), 0L);
  }

  @Test
  public void invalidParams() {
    final WebDriver webdriver = getWebDriver();
    webdriver.get(baseUrlWith("/oauth2/authorize"));

    String pageSource = webdriver.getPageSource();
    assertThat(pageSource, containsString("The supported response_type values are 'token' and 'code'"));
  }
View Full Code Here

  }

  @Test
  public void stateParam() throws Exception {
    String accessTokenRedirectUri = startAuthorizationCallbackServer(clientId, secret);
    WebDriver webdriver = getWebDriver();

    /*
    The RFC says (http://tools.ietf.org/html/rfc6749#appendix-A.5):
           state      = 1*VSCHAR
    Defined in http://tools.ietf.org/html/rfc6749#appendix-A:
         VSCHAR     = %x20-7E

    The variable 'state' below contains all chars in 0x20-0x7E
     */
    String state = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmno0070pqrstuvwxyz{|}~";
    String url = String.format(
            "%s/oauth2/authorize?response_type=%s&scope=%s&client_id=%s&redirect_uri=%s&state=%s",
            baseUrl(), "code", "read,write", clientId,
            URLEncoder.encode(accessTokenRedirectUri, "UTF-8"),
            URLEncoder.encode(state, "UTF-8"));
    webdriver.get(url);

    login(webdriver,false);

    // wait for token response to arrive, therefore block
    getAuthorizationCodeRequestHandler().getTokenResponseBlocking();
View Full Code Here

     * First do a normal authorization and obtain a AccessToken (with refreshToken)
     */
    String accessTokenRedirectUri = startAuthorizationCallbackServer(clientId, secret);

    restartBrowserSession();
    WebDriver webdriver = getWebDriver();

    String responseType = "code";
    String url = String.format("%s/oauth2/authorize?response_type=%s&client_id=%s&scope=read&redirect_uri=%s",
            baseUrl(), responseType, clientId, accessTokenRedirectUri);
    webdriver.get(url);

    /*
     * Consent is not necessary for this Client
     */
    login(webdriver, false);
View Full Code Here

  public void testGoogleSearch() {
    EventFiringWebDriver driverWithReporting;
    {
      // System.setProperty("webdriver.chrome.driver", "/opt/google/chrome/chrome");
      // WebDriver driver = new ChromeDriver();
      WebDriver driver = new FirefoxDriver();

      WebDriverEventListener loggingListener = new LoggingWebDriverEventListener(LOG_FILE_WRITER);;
      driverWithReporting = new EventFiringWebDriver(driver);
      driverWithReporting.register(loggingListener);
    }
View Full Code Here

*
* @author Kohsuke Kawaguchi
*/
public class Selenium2Test extends TestCase {
    public void testFoo() throws Exception {
        WebDriver wd = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), DesiredCapabilities.firefox());
        try {
            wd.get("http://www.yahoo.com/");
            wd.findElement(By.name("p")).sendKeys("hello world");
            wd.findElement(By.id("search-submit")).click();
//        wd.waitForPageToLoad("10000");

            assertTrue(wd.getTitle().contains("hello world"));
            assertTrue(wd.getTitle().contains("Yahoo"));
        } finally {
            wd.close();
        }
    }
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

                        InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING,
                        false);
            }
        }

        WebDriver dr = TestBench.createDriver(new RemoteWebDriver(new URL(
                getHubURL()), capabilities));
        setDriver(dr);
    }
View Full Code Here

        return true;
    }

    // FIXME: Remove this once TB4 getRemoteControlName works properly
    private RemoteWebDriver getRemoteDriver() {
        WebDriver d = getDriver();
        if (d instanceof TestBenchDriverProxy) {
            try {
                Field f = TestBenchDriverProxy.class
                        .getDeclaredField("actualDriver");
                f.setAccessible(true);
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.