【发布时间】:2012-01-09 12:57:45
【问题描述】:
我是 Selenium Webdriver 的新手。当我使用此代码时,我得到了输出和警告。请帮助我,我怎么能忽略这个警告。我的代码是:
package com.webdriver.Webdriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class Example {
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( "https://mobile.twitter.com/andres/about" );
// Find the text input element by its name
//WebElement element = driver.findElement(By.xpath("//title"));
WebElement element = driver.findElement(By.xpath("//div[@class='footer']/strong/a"));
String s=element.getText();
// 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());
System.out.println(s);
driver.quit();
}
}
警告:
2011 年 11 月 30 日下午 2:54:23 com.gargoylesoftware.htmlunit.DefaultCssErrorHandler 错误
警告:CSS 错误:[1:1724] @media 规则中的错误。无效的令牌“屏幕”。期待以下之一: , , .
2011 年 11 月 30 日下午 2:54:23 com.gargoylesoftware.htmlunit.DefaultCssErrorHandler 警告
警告:CSS 警告:[1:1724] 忽略整个规则。
2011 年 11 月 30 日下午 2:54:23 com.gargoylesoftware.htmlunit.DefaultCssErrorHandler 错误
警告:CSS 错误:[1:1908] @media 规则中的错误。无效的令牌“屏幕”。期待以下之一: , , .
2011 年 11 月 30 日下午 2:54:23 com.gargoylesoftware.htmlunit.DefaultCssErrorHandler 警告
警告:CSS 警告:[1:1908] 忽略整个规则。
2011 年 11 月 30 日下午 2:54:23 com.gargoylesoftware.htmlunit.DefaultCssErrorHandler 错误
警告:CSS 错误:[1:3437] @media 规则错误。无效的令牌“屏幕”。期待以下之一: , , .
2011 年 11 月 30 日下午 2:54:23 com.gargoylesoftware.htmlunit.DefaultCssErrorHandler 警告
警告:CSS 警告:[1:3437] 忽略整个规则。
页面标题是:Twitter 立即刷新
谢谢
【问题讨论】: