當前位置: 首頁>>代碼示例>>Java>>正文


Java HtmlUnitDriver.setJavascriptEnabled方法代碼示例

本文整理匯總了Java中org.openqa.selenium.htmlunit.HtmlUnitDriver.setJavascriptEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java HtmlUnitDriver.setJavascriptEnabled方法的具體用法?Java HtmlUnitDriver.setJavascriptEnabled怎麽用?Java HtmlUnitDriver.setJavascriptEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openqa.selenium.htmlunit.HtmlUnitDriver的用法示例。


在下文中一共展示了HtmlUnitDriver.setJavascriptEnabled方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
  System.out.println("Fake Google OAuth2 server up at: " + fakeGoogleServer.getEndpoint());
  System.out.println("Fake Hackpad server up at: " + fakeHackpadServer.getEndpoint());
  System.out.println("AwesomeAgile web application up at: " + getEndpoint());
  fakeGoogleServer.setClientId(CLIENT_ID);
  fakeGoogleServer.setClientSecret(CLIENT_SECRET);
  fakeGoogleServer.setRedirectUriPrefixes(
      ImmutableList.of("http://localhost:" + port + "/"));
  fakeGoogleServer.setPerson(createUser());
  fakeHackpadServer.setClientId(HACKPAD_CLIENT_ID);
  fakeHackpadServer.setClientSecret(HACKPAD_CLIENT_SECRET);
  fakeHackpadServer.getHackpads().clear();
  fakeHackpadServer.addHackpad(
      new PadIdentity(DEFINITION_OF_READY_TEMPLATE_ID),
      DEFINITION_OF_READY_CONTENTS);
  fakeHackpadServer.addHackpad(
      new PadIdentity(DEFINITION_OF_DONE_TEMPLATE_ID),
      DEFINITION_OF_DONE_CONTENTS);

  driver = new HtmlUnitDriver(BrowserVersion.CHROME);
  driver.setJavascriptEnabled(true);
}
 
開發者ID:cs71-caffeine,項目名稱:awesome-agile,代碼行數:24,代碼來源:AwesomeAgileFunctionalTest.java

示例2: testDashboardReopenBrowser

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
@Test
public void testDashboardReopenBrowser() throws Exception {
  LandingPage landingPage = PageFactory.initElements(driver, LandingPage.class);
  landingPage.loginWithGoogle(getEndpoint());
  assertThat(driver.getWindowHandles(), hasSize(1));
  landingPage.createDefinitionOfReady();

  HtmlUnitDriver driverTwo = new HtmlUnitDriver(BrowserVersion.CHROME);
  driverTwo.setJavascriptEnabled(true);

  // Open a completely new browser with no cookies
  // Verify that view button is visible for this same user,
  // and we're able to open his Definition of ready hackpad
  LandingPage landingPageTwo = PageFactory.initElements(driverTwo, LandingPage.class);
  landingPageTwo.loginWithGoogle(getEndpoint());
  landingPageTwo.waitForDefinitionOfReady();
  assertTrue(landingPageTwo.isDefinitionOfReadyViewable());
  landingPageTwo.viewDefinitionOfReady();
  String newWindow = Iterables.getFirst(Sets.difference(
      driverTwo.getWindowHandles(),
      ImmutableSet.of(driverTwo.getWindowHandle())), null);
  driverTwo.switchTo().window(newWindow);
  HackpadPage hackpadPage = PageFactory.initElements(driverTwo, HackpadPage.class);
  assertEquals(DEFINITION_OF_READY_CONTENTS, hackpadPage.getContent());
}
 
開發者ID:cs71-caffeine,項目名稱:awesome-agile,代碼行數:26,代碼來源:AwesomeAgileFunctionalTest.java

示例3: main

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    Executor executor = new Executor() {
        @Override
        public void execute(CrawlDatum datum, CrawlDatums next) throws Exception {
            
            HtmlUnitDriver driver = new HtmlUnitDriver();
            driver.setJavascriptEnabled(true);
            
            driver.get(datum.url());
            
            List<WebElement> elementList = driver.findElementsByCssSelector("h3.vrTitle a");
            for(WebElement element:elementList){
                System.out.println("title:"+element.getText());
            }
        }
    };

    //創建一個基於伯克利DB的DBManager
    DBManager manager = new BerkeleyDBManager("crawl");
    //創建一個Crawler需要有DBManager和Executor
    Crawler crawler = new Crawler(manager, executor);
    crawler.addSeed("https://www.sogou.com/web?query=%E6%B7%98%E5%AE%9D");
    crawler.start(1);
}
 
開發者ID:CrawlScript,項目名稱:WebCollector,代碼行數:25,代碼來源:DemoSelenium.java

示例4: start

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
@Override
@PublicAtsApi
public void start() {

    webDriver = new HtmlUnitDriver(this.browserVersion);
    webDriver.setJavascriptEnabled(true);

    setProxyIfAvailable();

    fixHtmlUnitBehaviour();

    log.info("Openning URL: " + url);
    webDriver.get(url);
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:15,代碼來源:HiddenBrowserDriver.java

示例5: getHtmlUnitDriver

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
public static WebDriver getHtmlUnitDriver()
{
	HtmlUnitDriver driver = new HtmlUnitDriver();
	driver.setJavascriptEnabled(true);

	return driver;
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:8,代碼來源:SeleniumTestUtilities.java

示例6: createDriver

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
@Override
public WebDriver createDriver() throws Exception {
    final HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.BEST_SUPPORTED);
    driver.setJavascriptEnabled(true);
    manage(driver);
    return driver;
}
 
開發者ID:LearnLib,項目名稱:alex,代碼行數:8,代碼來源:HtmlUnitDriverConfig.java

示例7: getHtmlUnitWebDriver

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
/**
 * Default implementation of getting a local HTMLUnit Driver
 * 
 * @return {@link WebDriver} for HTMLUnit
 */
protected WebDriver getHtmlUnitWebDriver()
{
  // Set to firefox 24 to emulate a friendly javascript engine
  HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_38);
  driver.setJavascriptEnabled(true);
  return driver;
}
 
開發者ID:partnet,項目名稱:seauto,代碼行數:13,代碼來源:AbstractConfigurableDriverProvider.java

示例8: initializeTokenStore

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
protected void initializeTokenStore() throws Exception {
    final Optional<URL> authorizeUrl = createHmrc().getAuthorizeUrl(getScope());
    final HtmlUnitDriver browser = new HtmlUnitDriver();
    browser.setJavascriptEnabled(true);
    browser.get(authorizeUrl.map(URL::toString).orElseThrow(() -> new IllegalStateException("no authorize url found")));
    browser.findElement(By.id("userId")).sendKeys("user1");
    browser.findElement(By.id("password")).sendKeys("password1");
    browser.findElement(By.tagName("button")).click();
    browser.findElement(By.id("authorise")).click();
    while (!initialized) {
        Thread.sleep(100);
    }
}
 
開發者ID:shaneagibson,項目名稱:hmrc4j,代碼行數:14,代碼來源:AbstractUserRestrictedIT.java

示例9: createDriver

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
protected final WebDriver createDriver(final String url) {
    final HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.INTERNET_EXPLORER_10) {
        {
            this.getWebClient().setRefreshHandler(new AllOrNothingRefreshHandler());
        }
    };


    driver.setJavascriptEnabled(true);
    driver.manage().timeouts().implicitlyWait(WAIT_TIME, TimeUnit.SECONDS);
    driver.get(url);
    return driver;
}
 
開發者ID:tobiasbaum,項目名稱:portalsammler,代碼行數:14,代碼來源:DocumentSource.java

示例10: testSeparateDashboards

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
/**
 * Verifies that different users get different dashboards with links to different documents
 * @throws Exception
 */
@Test
public void testSeparateDashboards() throws Exception {
  String templateOne = DEFINITION_OF_READY_CONTENTS + "1";
  String templateTwo = DEFINITION_OF_READY_CONTENTS + "2";

  Person userOne = createUser();
  Person userTwo = createUser();

  // Create hackpad for user #1
  fakeGoogleServer.setPerson(userOne);

  LandingPage landingPage = PageFactory.initElements(driver, LandingPage.class);
  landingPage.loginWithGoogle(getEndpoint());
  fakeHackpadServer.addHackpad(
      new PadIdentity(DEFINITION_OF_READY_TEMPLATE_ID),
      templateOne);
  String currentWindow = driver.getWindowHandle();
  landingPage.createDefinitionOfReady();
  closeWindowsExceptFor(driver, currentWindow);


  // Log in with user #2, there should be no definition of ready on the dashboard
  fakeGoogleServer.setPerson(userTwo);

  HtmlUnitDriver driverTwo = new HtmlUnitDriver(BrowserVersion.CHROME);
  driverTwo.setJavascriptEnabled(true);
  LandingPage landingPageTwo = PageFactory.initElements(driverTwo, LandingPage.class);
  landingPageTwo.loginWithGoogle(getEndpoint());
  assertFalse(landingPageTwo.isDefinitionOfReadyViewable());

  // Create another definition of ready
  fakeHackpadServer.addHackpad(
      new PadIdentity(DEFINITION_OF_READY_TEMPLATE_ID),
      templateTwo);
  String currentWindowTwo = driverTwo.getWindowHandle();
  landingPageTwo.createDefinitionOfReady();
  closeWindowsExceptFor(driverTwo, currentWindowTwo);

  assertDefinitionOfReadyContents(driver, templateOne);

  assertDefinitionOfReadyContents(driverTwo, templateTwo);
}
 
開發者ID:cs71-caffeine,項目名稱:awesome-agile,代碼行數:47,代碼來源:AwesomeAgileFunctionalTest.java

示例11: getDriver

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
public static HtmlUnitDriver getDriver(Page page) {
    HtmlUnitDriver driver = new HtmlUnitDriver();
    driver.setJavascriptEnabled(true);
    driver.get(page.getUrl());
    return driver;
}
 
開發者ID:SH-Allegion,項目名稱:StuJava,代碼行數:7,代碼來源:PageUtils.java

示例12: htmlUnitDriver

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private static WebDriver htmlUnitDriver() {
	HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_24);
	driver.setJavascriptEnabled(true);
	return driver;
}
 
開發者ID:caelum,項目名稱:mamute,代碼行數:7,代碼來源:AcceptanceTestBase.java

示例13: init

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //導入方法依賴的package包/類
@Before
    public void init() {
        if (urls == null) {
            Urls.initUrls(env.getRequiredProperty(PropertyNames.baseURL), env.getProperty(PropertyNames.superSearchBaseUrl));
            urls = Urls.FI;
        }

        String driverType = env.getProperty("test.web-driver", "hu");
        System.out.println("*** driverType = " + driverType);
        if ("ie".equals(driverType)) {
            driver = new InternetExplorerDriver();
            driver.get(urls.frontpage());
            driver.navigate().to("javascript:document.getElementById('overridelink').click()"); // to skip security certificate problem page
        }
        else if ("ff".equals(driverType)) {
            driver = new FirefoxDriver();
        }
//        else if ("safari".equals(driverType)) {
//            driver = new SafariDriver();
//        }
        else {
        	HtmlUnitDriver htmlUnitDriver =	new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
            htmlUnitDriver.setJavascriptEnabled(true);
        	driver = htmlUnitDriver;
        }

        driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); // default is 0!!!
        driver.manage().timeouts().setScriptTimeout(50, TimeUnit.SECONDS); // default is 0!!!
        driver.manage().window().setSize(new Dimension(1024, 768));
        //driver.manage().timeouts().pageLoadTimeout(50, TimeUnit.SECONDS); // default is 0!!!
        
        if (urls == null) {
            Urls.initUrls("https://localhost:" + PORT, env.getProperty(PropertyNames.superSearchBaseUrl));
            urls = Urls.FI;
        }
        testHelper.dbCleanup();
        Long userIdOM = testHelper.createOMTestUserWithHash(OM_USER_SSN);
        System.out.println("*** OM user " + OM_USER_SSN + " created with id " + userIdOM);
        Long userIdVRK = testHelper.createVRKTestUserWithHash(VRK_USER_SSN);
        System.out.println("*** VRK user " + VRK_USER_SSN + " created with id " + userIdVRK);
    }
 
開發者ID:solita,項目名稱:kansalaisaloite,代碼行數:42,代碼來源:WebTestBase.java


注:本文中的org.openqa.selenium.htmlunit.HtmlUnitDriver.setJavascriptEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。