本文整理匯總了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);
}
示例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());
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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));
}
示例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;
}
示例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"));
}
示例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;
}