I’m trying to execute a basic test using a headless browser. While attempting to capture a screenshot of my staging site, I only see a blank screen, whereas production sites like www.google.co.uk load perfectly. This makes me think that we might need to configure the headers to access our staging site.
Does anyone have insights on how to accomplish this using Selenium with a headless browser?
Here’s my current code snippet:
public void executeHeadlessTest() throws IOException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "phantomjs");
WebDriver driver = new PhantomJSDriver(capabilities);
driver.get("https://mywebsite.staging.com/");
captureScreenshot("StagingWebsite");
}