2016-04-01 65 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