I am loading a webpage in selenium firefox webdriver, then i am zooming in into the page at 500%, and then i wish to take the screenshot of the page in the zoomed in resolution at 500%, but it is not working
DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
desiredCapabilities.setPlatform(Platform.WINDOWS);
WebDriver driver = new FirefoxDriver(desiredCapabilities);
driver.get(url);
driver.manage().window().setSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height));
WebElement html = driver.findElement(By.tagName("html"));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));
html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));
This code zooms into the url. Now i want to take the screenshot in the zoomed in resolution.
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\"+url.substring(url.lastIndexOf("/"),url.lastIndexOf("."))+".png"));
This is taking the screenshot but only at the normal resolution and not the zoomed in resolution.
Please someone help how can it be done in selenium, or even if selenium is the right tools for this. If not then, please suggest something else that is working for my requirement.
Chrome()
instead ofFirefox()
- does it make any difference? Thanks. – alecxe