为什么WebDriver输出这个html异常?



CODE:

package com.funcybernation.yndextesting;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
/**
 * Hello world!
 *
 */
public class App {
    public static void main(String[] args) {
        // Create a new instance of the html unit driver
        // Notice that the remainder of the code relies on the interface, 
        // not the implementation.
        WebDriver driver = new HtmlUnitDriver();
        // And now use this to visit Google
        driver.get("http://www.google.com");
        // Find the text input element by its name
        WebElement element = driver.findElement(By.name("q"));
        // Enter something to search for
        element.sendKeys("Cheese!");
        // Now submit the form. WebDriver will find the form for us from the element
        element.submit();
        // Check the title of the page
        System.out.println("Page title is: " + driver.getTitle());
    }
}

= = = = =

HtmlTextInput[<input autocomplete="off" class="lst tiah" value="" title="Пошук Google" maxlength="2048" name="q" size="57" style="color:#000;margin:0;padding:5px 8px 0 6px;vertical-align:top;padding-right:38px" type="text">] -> HtmlHtml[<html itemscope="itemscope" itemtype="http://schema.org/WebPage">]
HtmlTextInput[<input autocomplete="off" class="lst tiah" value="" title="Пошук Google" maxlength="2048" name="q" size="57" style="color:#000;margin:0;padding:5px 8px 0 6px;vertical-align:top;padding-right:38px" type="text">] -> HtmlHtml[<html itemscope="itemscope" itemtype="http://schema.org/WebPage">]
HtmlTextInput[<input autocomplete="off" class="lst tiah" value="" title="Пошук Google" maxlength="2048" name="q" size="57" style="color:#000;margin:0;padding:5px 8px 0 6px;vertical-align:top;padding-right:38px" type="text">] -> HtmlHtml[<html itemscope="itemscope" itemtype="http://schema.org/WebPage">]
HtmlBody[<body bgcolor="#fff">] -> HtmlHtml[<html itemscope="itemscope" itemtype="http://schema.org/WebPage">]
HtmlTextInput[<input autocomplete="off" class="lst tiah" value="" title="Пошук Google" maxlength="2048" name="q" size="57" style="color:#000;margin:0;padding:5px 8px 0 6px;vertical-align:top;padding-right:38px" type="text">] -> HtmlHtml[<html itemscope="itemscope" itemtype="http://schema.org/WebPage">]
HtmlTextInput[<input autocomplete="off" class="lst tiah" value="Cheese!" title="Пошук Google" maxlength="2048" name="q" size="57" style="color:#000;margin:0;padding:5px 8px 0 6px;vertical-align:top;padding-right:38px" type="text">] -> HtmlHtml[<html itemscope="itemscope" itemtype="http://schema.org/WebPage">]
    Page title is: Cheese! - Search Google

该日志信息可能来自HtmlUnit。如果是这样,你应该可以配置HtmlUnit来减少日志记录。

相关内容

最新更新