当前位置: 首页>>代码示例>>Java>>正文


Java HtmlUnitDriver.get方法代码示例

本文整理汇总了Java中org.openqa.selenium.htmlunit.HtmlUnitDriver.get方法的典型用法代码示例。如果您正苦于以下问题:Java HtmlUnitDriver.get方法的具体用法?Java HtmlUnitDriver.get怎么用?Java HtmlUnitDriver.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.htmlunit.HtmlUnitDriver的用法示例。


在下文中一共展示了HtmlUnitDriver.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: testWithHeadlessBrowsers

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //导入方法依赖的package包/类
@Test
public void testWithHeadlessBrowsers(HtmlUnitDriver htmlUnit,
        PhantomJSDriver phantomjs) {
    htmlUnit.get("https://bonigarcia.github.io/selenium-jupiter/");
    phantomjs.get("https://bonigarcia.github.io/selenium-jupiter/");

    assertTrue(htmlUnit.getTitle().contains("JUnit 5 extension"));
    assertNotNull(phantomjs.getPageSource());
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:10,代码来源:LocalWebDriverTest.java

示例3: 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

示例4: quicklyPartAjaxHtml

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //导入方法依赖的package包/类
public static String quicklyPartAjaxHtml(final String url, final String expression) {
  String _xblockexpression = null;
  {
    final HtmlUnitDriver webDriver = new HtmlUnitDriver(true);
    webDriver.get(url);
    final WebElement webElement = webDriver.findElementByCssSelector(expression);
    webDriver.close();
    _xblockexpression = webElement.getText();
  }
  return _xblockexpression;
}
 
开发者ID:East196,项目名称:maker,代码行数:12,代码来源:TungParser.java

示例5: setUp

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //导入方法依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {

    final String chrome_driver = System.getenv("CHROME_DRIVER");
    if (chrome_driver != null) {
        System.setProperty("webdriver.chrome.driver", chrome_driver);
        webDriver = new ChromeDriver();
    } else {
        webDriver = new HtmlUnitDriver();
    }
    wait = new WebDriverWait(webDriver, 10);
    webDriver.get("http://localhost:8080");
    webDriver.manage().window().maximize();
}
 
开发者ID:tudoNoob,项目名称:poseidon,代码行数:15,代码来源:UserJourney.java

示例6: doTable

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //导入方法依赖的package包/类
public List doTable(List<List<String>> fitnesse_table) throws InterruptedException { 
  	System.out.println("------------------------------ Check content element on html page Fixture ------------------------------------------");
  		  
  	//Get url
  	url = fitnesse_table.get(0).get(1);
  	//Get element identifier
  	element_identifier = fitnesse_table.get(1).get(1);
  	
  	//populate return row with 'pass'
	return_row.add("pass"); //return "pass" in next cell
	return_row.add("pass"); //return "pass" in next cell
  	//First 2 rows green
	getTextAndReturnPass (fitnesse_table.get(0));
	getTextAndReturnPass (fitnesse_table.get(1));

    // Create a new instance of the driver    
  	driver = new HtmlUnitDriver();
 	System.out.println("driver = htmlunit");  		  		
  	System.out.println("url = " + url);
  	System.out.println("element = " + element_identifier);
 
    // And now use this to visit url
 	driver.get(url);
 	element = driver.findElement(By.id(element_identifier));

 	element_text = element.getText();
  	System.out.println("element text = " + element_text);
 	Thread.sleep(500);
	driver.quit();
	
	CompareExpectedTableWithPageTable (fitnesse_table);
	return return_table;
}
 
开发者ID:consag,项目名称:fitnessefixtures,代码行数:34,代码来源:CheckContentElementOnHtmlPage.java

示例7: doTable

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //导入方法依赖的package包/类
public List doTable(List<List<String>> fitnesse_table) throws InterruptedException { 
  	System.out.println("------------------------------ Check Content Table On HTML Page ------------------------------------------");
  	
  	//Get url
  	url = fitnesse_table.get(0).get(1);
  	//Get element identifier
  	element_identifier = fitnesse_table.get(1).get(1);
  	
  	//populate return row with 'pass'
  	//First row green
	getTextAndReturnPass (fitnesse_table.get(0));
  	//Second row green
	getTextAndReturnPass (fitnesse_table.get(1));
		  	
  	// Create a new instance of the driver    
  	driver = new HtmlUnitDriver();
 	System.out.println("driver = htmlunit");  		  		
 	System.out.println("url = " + url);
  	System.out.println("element = " + element_identifier);
 
    // And now use this to visit url
 	driver.get(url);
 	element = driver.findElement(By.id(element_identifier));
    element_text = element.getText();
 	Thread.sleep(500);
	driver.quit();
	  
	//Return number of columns in fitnesse table
	number_of_table_columns = fitnesse_table.get(2).size();	  
	CompareExpectedTableWithPageTable (fitnesse_table);
	return return_table;
}
 
开发者ID:consag,项目名称:fitnessefixtures,代码行数:33,代码来源:CheckContentTableOnHtmlPage.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: handle

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //导入方法依赖的package包/类
@Override
public void handle(String channel, String user, String link) throws Exception
{
	HtmlUnitDriver driver = new HtmlUnitDriver();
	String title = "";

	if(link.startsWith("www."))
		link = "http://" + link;

	driver.get(link);
	title = driver.getTitle();
	driver.quit();

	if(link.startsWith("http://"))
		link = link.substring(7);
	else if(link.startsWith("https://"))
		link = link.substring(8);

	if(link.length() > 21)
	{
		link = link.substring(0, 21);
		link += "...";
	}

	if(title.equals("") || title.equals("null"))
		Utilities.sendMessage(channel, l10n.translate("notFound", channel).replace("#link", link));
	else
		Utilities.sendMessage(channel, l10n.translate("available", channel).replace("#link", link).replace("#title", title));
}
 
开发者ID:bl4ckscor3,项目名称:bl4ckb0t,代码行数:30,代码来源:LinkTitle.java

示例10: 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

示例11: test

import org.openqa.selenium.htmlunit.HtmlUnitDriver; //导入方法依赖的package包/类
@Test
public void test(HtmlUnitDriver driver) {
    driver.get("https://bonigarcia.github.io/selenium-jupiter/");
    assertThat(driver.getTitle(),
            containsString("A JUnit 5 extension for Selenium WebDriver"));
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:7,代码来源:HtmlUnitJupiterTest.java

示例12: 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


注:本文中的org.openqa.selenium.htmlunit.HtmlUnitDriver.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。