JAVAを使用してWebテストを実行しているときに、Webページが画面に表示されないようにします。プログラムが実行され、Webページが表示されない方法がありますか?テスト中にセレンのwebdriverでWebページを非表示にする
2
A
答えて
1
あなたがテストを実行するための専用のマシンのための予算を持っていない場合は、簡単なトリックがオフスクリーンブラウザを起動することです:
ChromeOptions options = new ChromeOptions();
options.addArguments("--window-position=-32000,-32000");
WebDriver driver = new ChromeDriver(options);
driver.get("http://stackoverflow.com");
0
はい、あなたが使用HtmlUnitDriverそれ以下のようにこれを行うことができますあなたのWebページには、ヘッドレスモードで開きがありません
https://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.html
もvisit http://stackoverflow.com/questions/12807689/selenium-vs-htmlunit
をご覧くださいHTMLユニットのドライバについての詳細は、任意のWebページのない可視性、すなわちん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
PhantomJSドライバを試すことができます。 – JRodDynamite