Package org.openqa.selenium

Examples of org.openqa.selenium.WebDriver


        this.indexOfFrame = indexOfFrame;
    }

    @Override
    public Object intercept(InvocationContext context) throws Throwable {
        WebDriver browser = context.getGrapheneContext().getWebDriver();
        if (indexOfFrame != -1) {
            browser.switchTo().frame(indexOfFrame);
        } else if (nameOrIdOfFrame != null) {
            browser.switchTo().frame(nameOrIdOfFrame);
        }
        Object result = null;
        try {
            result = context.invoke();
        } finally {
            browser.switchTo().defaultContent();
        }
        if (result instanceof GrapheneProxyInstance) {
            ((GrapheneProxyInstance) result).registerInterceptor(this);
        }
        return result;
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"));

            WebElement submit = form.findElement(By.id("allow"));

            userField.sendKeys(username);
            passwordField.sendKeys(password);

            submit.click();

            Cookie session = driver.manage().getCookieNamed("JSESSIONID");
            sessionId = session.getValue();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if(driver != null) {
                driver.close();
            }
        }
        return sessionId;
    }
View Full Code Here

        }

        public void setDroneSession(@Observes AfterDroneInstantiated event) {
            System.out.println("Setting WebDriver session: " + holder.get().getSessionId());
            if(WebDriver.class.isAssignableFrom(event.getDroneType())) {
                WebDriver driver = event.getInstance().asInstance(WebDriver.class);
                // We need to navigate somewhere before we can set a cookie.
                // https://www.w3.org/Bugs/Public/show_bug.cgi?id=20975
                driver.get(holder.get().getURI() + "/../");
                driver.manage().deleteAllCookies();
                driver.manage().addCookie(new Cookie("JSESSIONID", holder.get().getSessionId()));
            }
        }
View Full Code Here

    }
   
    //如果selenium没初始化,初始化selenium
    if (s == null) {
      //System.setProperty ( "webdriver.firefox.bin" , "E:/Firefox/firefox.exe" );
      WebDriver driver = WebDriverFactory.createDriver(SELENIUM_DRIVER);
      s = new Selenium2(driver, URL);
      s.setStopAtShutdown();
    }
   
    //载入新的数据
View Full Code Here

   *
   * 当持续集成服务器安装在非Windows机器上, 没有IE浏览器与XWindows时, 又希望使用真正的浏览器时,需要使用remote driver调用远程的Windows机器.
   * drivername如remote:192.168.0.2:4444:firefox, 此时要求远程服务器在http://192.168.0.2:4444/wd/hub上启动selenium remote服务.
   */
  public static WebDriver createDriver(String driverName) {
    WebDriver driver = null;

    if (BrowserType.firefox.name().equals(driverName)) {
      driver = new FirefoxDriver();
    } else if (BrowserType.ie.name().equals(driverName)) {
      driver = new InternetExplorerDriver();
View Full Code Here

        if (instantiator != null && instantiator.getClass() != this.getClass()) {
            return (WebDriver) instantiator.createInstance(configuration);
        }

        // this is a simple constructor which does not know anything advanced
        WebDriver driver = SecurityActions.newInstance(configuration.getImplementationClass(), new Class<?>[0], new Object[0],
                WebDriver.class);
        return driver;
    }
View Full Code Here

    @Test
    public void testNoError() {
        setAuthType(AuthType.NONE,true);
      ResultPage p = launchSnippet("Authentication_Authentication_Summary");
       
        WebDriver webDriver = p.getWebDriver();
    webDriver.findElement(By.id("logoutsmartcloudOA2"));
        webDriver.findElement(By.id("loginsmartcloudOA2"));
        webDriver.findElement(By.id("logoutconnections"));
        webDriver.findElement(By.id("loginconnections"));
        webDriver.findElement(By.id("logoutconnectionsOA2"));
        webDriver.findElement(By.id("loginconnectionsOA2"));
        webDriver.findElement(By.id("logoutsmartcloud"));
        webDriver.findElement(By.id("loginsmartcloud"));
        //Disabling the domino endpoint login/logout buttons.
        //webDriver.findElement(By.id("logoutdomino"));
       // webDriver.findElement(By.id("logindomino"));
       
    }
View Full Code Here

   
    protected void saveTestDataAndResults() {
      String fileBase = getSnippetFile();
      File testData = getTestDataDir();
     
      WebDriver webDriver = environment.getWebDriver();
     
      WebElement jsonElement = webDriver.findElement(By.id("json"));
        String jsonText = jsonElement.getText();
        writeFile(testData, fileBase + ".result", jsonText);
       
      WebElement mockDataElement = webDriver.findElement(By.id("mockData"));
        String mockDataText = mockDataElement.getText();
        writeFile(testData, fileBase + ".mock", mockDataText);
    }
View Full Code Here

      return (new WebDriverWait(getPageObject().getWebDriver(), secs))
          .until(new ExpectedCondition<WebElement>() {
            @Override
            public WebElement apply(WebDriver webDriver) {
              failIfPageCrashed(webDriver);
              WebDriver popup = findPopup(titles);
              if (popup != null) {
                return popup.findElement(By.tagName("body"));
              }
              return null;
            }
          });
    } catch (Exception e) {
View Full Code Here

      return loginForm;
    }

    if (titles != null) {
      // look for authentication popup
      WebDriver popup = findPopup(titles);
      if (popup != null) {
        loginForm = findLoginForm(popup, ids, xpathExprs);
        if (loginForm != null) {
          return loginForm;
        }
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.