当前位置: 首页>>代码示例>>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;未经允许,请勿转载。