在 Grid 上运行的多个实例如何处理 Selenium 屏幕截图?假设我有一个 Grid Hub 驱动一个 Grid 节点,在一台 Node 机器上同时运行 3 个 Firefox 浏览器,我如何从 3 个节点线程中的每个线程中获取 3 个不同的屏幕截图?
例如,以这个用于单线程测试的代码片段为例:
RemoteWebDriver driver;
driver = new RemoteWebDriver(new URL("http://127.1/wd/hub"), DesiredCapabilities
.firefox() );
driver.get( "http://www.google.com/" );
WebDriver augmentedDriver = new Augmenter().augment(driver);
File screenshot = (TakesScreenshot)augmentedDriver.getScreenshotAs(OutputType
.FILE);
System.out.println( "Page title is: " + driver.getTitle() );
System.out.println( "Screenshot is located at: " + screenshot.getAbsolutePath());
assertTrue( "Page did not contain string.", driver.getSource().contains(
"search") );
driver.quit();