Open vishruth143 opened 7 years ago
hello, @vishruth143. You don't actually need to use ShootingStrategies.viewportPasting()
strategy with Firefox. It makes full page screenshot itself. Try to use stable version of Selenium to avoid exceptions like WebDriverException: Permission denied to access property "H"
Hi @pazone , Did you mean I can use the below line directly without the ShootingStrategies.viewportPasting() strategy when working with Firefox.
Screenshot screenshot = new AShot().takeScreenshot(driver);
Can I use 2.53 for the stable version of Selenium?
Yes, you are right in both questions.
@pazone, ashot wont work with the current version of Selenium (i.e. Selenium Version 3.0.1)?
Hi @pazone,
yesterday I downloaded ashot and used it with Selenium 3.0.1.
It works very good.
Did you that you have to inject JQuery?
Ingo
Gesendet: Sonntag, 20. November 2016 um 04:54 Uhr Von: vishruth143 notifications@github.com An: yandex-qatools/ashot ashot@noreply.github.com Betreff: Re: [yandex-qatools/ashot] Unable to scroll and capture full screen shot of the webpage (#82)
@pazone, ashot wont work with the current version of Selenium (i.e. Selenium Version 3.0.1)?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hi @pazone, yesterday I downloaded ashot and used it with Selenium 3.0.1. It works very good. Did you know that you have to inject JQuery?
Ingo
@pazone,
I have written the below code and when I run it, I'm getting the below error:
I'm Using: Firefox Version: 50.0 Selenium Version: 3.0.1 OS: Win10 64 bit Java: 1.8
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.shooting.ShootingStrategies;
public class ScreenShot {
public static WebDriver driver = null;
public static void main(String[] args) throws IOException, InterruptedException {
System.setProperty("webdriver.gecko.driver","C:\\Eclipse\\Drivers\\geckodriver.exe");
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://www.flipkart.com/");
Thread.sleep(10000);
Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(100)).takeScreenshot(driver);
//Screenshot screenshot = new AShot().takeScreenshot(driver);
//Screenshot screenshot = new AShot().takeScreenshot(driver, driver.findElement(By.xpath(".//*[@id='container']")));
ImageIO.write(screenshot.getImage(), "PNG", new File("C:\\Users\\Vishvambruth JT\\Desktop\\home.png"));
driver.quit();
}
}
Console Output:
1479697451447 geckodriver INFO Listening on 127.0.0.1:23248
Nov 20, 2016 9:04:12 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
1479697452267 mozprofile::profile INFO Using profile path C:\Users\VISHVA~1\AppData\Local\Temp\rust_mozprofile.cnwXGnikdGeA
1479697452280 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe
1479697452289 geckodriver::marionette INFO Connecting to Marionette on localhost:62637
1479697453031 Marionette INFO Listening on port 62637
Nov 20, 2016 9:04:14 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Exception in thread "main" java.lang.RuntimeException: org.openqa.selenium.WebDriverException: Permission denied to access property "H"
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'LAPTOP-JUUNTJIC', ip: '10.0.0.112', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20161104212021, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=12392, browserVersion=50.0, platformVersion=10.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt}]
Session ID: 39bbcdaf-718a-48ca-bd33-c973037b83d4
at ru.yandex.qatools.ashot.util.InnerScript.execute(InnerScript.java:29)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getFullHeight(ViewportPastingDecorator.java:67)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:41)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:35)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:143)
at ScreenShot.main(ScreenShot.java:35)
Caused by: org.openqa.selenium.WebDriverException: Permission denied to access property "H"
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'LAPTOP-JUUNTJIC', ip: '10.0.0.112', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20161104212021, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=12392, browserVersion=50.0, platformVersion=10.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt}]
Session ID: 39bbcdaf-718a-48ca-bd33-c973037b83d4
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:537)
at ru.yandex.qatools.ashot.util.InnerScript.execute(InnerScript.java:27)
... 5 more
@vishruth143 This problem is related to WebDriver 3.0. This version is not very stable. Are you sure that you already want to use it?
Any update in this regards, I'm getting the same issue, however only with IE 11. Using
Hi pazone, I want to take full page screenshot in IE11. I tried following code but I am still not able to capture screenshot by scrolling down down. Screenshot screenshot = new AShot().takeScreenshot(driver); ImageIO.write(screenshot.getImage(),"PNG",new File(fileWithPath));
Can you please help?
Hi, @shiv3015. Could you please share the web page and result screenshot?
Hi @pazone I am trying to take screenshot for web page for amazon site. Please check screenshot below. home If you see the above screenshot, web page is not scrolled to take screenshot.
The actual web page details can't be shared hence tried to show on amazon site. I am able to take screenshot in chrome with following code: Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver); ImageIO.write(screenshot.getImage(),"PNG",new File(fileWithPath)); But when trying to take screenshot in IE by removing shootingStrategy I am not able to capture.
@shiv3015 Actually you don't need to use viewportPasting
with ie11. When you are taking the screenshot browser adjusts the window size to the size of your page for a moment. So it should work our of the box. Have you tried Screenshot screenshot = new AShot().takeScreenshot(driver)
?
@pazone Yes, I tried with Screenshot screenshot = new AShot().takeScreenshot(driver) in IE11. Screenshot is taken only for available page and not by scrolling down. screenshot captured in IE11 already shared in above comment. I am not aware how to adjusts the window size to the size of your page. I will be thankful to you if you could help me with this. My project requires testing in IE browser only so its very important for me to capture screenshot of whole web page in IE11.
Hi all! I have the same issue with IE11. It seems to be a JavaScript compatibility issue. See: https://github.com/imgix/drift/issues/33
Here is (what I think) would be needed for this to work:
DesiredCapabilities.internetExplorer() .setCapability("takesScreenShot", true); .setCapability("ie.enableFullPageScreenshot", false);
return new AShot().shootingStrategy(ShootingStrategies.viewportPasting(2000)).takeScreenshot(webDriver).getImage();
But most important, a fix into ViewportPastingDecorator.getCurrentScrollY(JavascriptExecutor js)
js.executeScript("var scrY = window.pageYOffset;"
instead of
js.executeScript("var scrY = window.scrollY;"
The same fix has already been applied for: https://github.com/redbadger/website-honestly/commit/67ca40b00005aa8dcbeeebbc9a145cce0e28b858
Note: Default mode and setting IE11 to enableFullPageScreenshot is NOT working.
Hi All,
use below lines of code, this will fix this issue:
final Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportRetina(100,0,0,2)).takeScreenshot(driver); final BufferedImage image = screenshot.getImage(); try { ImageIO.write(image, "PNG", new File(fileToCopy)); } catch (IOException e) { e.printStackTrace(); }
This worked for me on: mac version 10.12.1, selenium 3.5.3 geckodriver Refer the attached screenshot. local_screenshot.png
However when i am running the same code on ubuntu via jenkins, the screenshot is not captured properly, pls refer screenshot remote_screenshot.png
Does anyone have idea why on ubuntu the screenshot is not correctly being captured. Ubuntu 5.4.0-6ubuntu1~16.04.9 selenium 3.5.3 geckodriver-v0.17.0-linux64.tar.gz
can some one help me on this, why is this black background appearing when there is scroll action. pls check screenshots.
Thanks in advance.
Hi All,
I have written the below code to capture the entire webpage of [www.flipkart.com]
But I'm facing the below error. Please suggest. the code is not working even with the below line.
Screenshot screenshot = new AShot().takeScreenshot(driver, driver.findElement(By.xpath(".//*[@id='container']")));
I'm Using: Firefox Version: 49.0.1 Selenium Version: Version 3.0.0-beta4 OS: Win10 64 bit Java: 1.8