當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。