2016-04-01 66 views

回答

1

如果你没有足够的预算有专门的机器来运行测试,那么一个简单的窍门是运行浏览器关闭屏幕:

ChromeOptions options = new ChromeOptions(); 
options.addArguments("--window-position=-32000,-32000"); 

WebDriver driver = new ChromeDriver(options); 
driver.get("http://stackoverflow.com"); 
0

是的,你可以做到这一点像下面使用HtmlUnitDriver它打开在无头的模式下您的网页,即没有任何网页的知名度有关HTML单元驱动器的详细信息,请访问

https://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.html 

visit http://stackoverflow.com/questions/12807689/selenium-vs-htmlunit

无w回到问题

WebDriver driver = new HtmlUnitDriver(); 
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
// do some action with html unit driver 
// for example open google home page 
driver.get("http://www.google.com"); 
// now verify that google home page is loaded properly 
System.out.println("Printing Title of the Google Home Page : " + driver.getTitle()); 

// above line prints on console : Printing Title of the Google Home Page : Google