pazone / ashot Goto Github PK
View Code? Open in Web Editor NEWWebDriver Screenshot utility. Take screenshots, crop, prettify, compare
License: Other
WebDriver Screenshot utility. Take screenshots, crop, prettify, compare
License: Other
Hi,
I don't seem to figure a way to be able to take a screenshot of a div element that is scrollable.
Is this supported?
Thanks!
Jason
Hey,
I don't suppose there is a .net version of this library available?
Hi all,
I'm using Ghost Driver + Selenium in order to create a headless browser testing.
Using aShot for full page screenshot does not return the desired result - only the actual state (same result is I would use Selenium)
pom:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.ashot</groupId>
<artifactId>ashot</artifactId>
<version>1.5.2</version>
</dependency>`
block code:
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true); // enabled by default
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
"phantomjs.exe"
);
WebDriver driver = new PhantomJSDriver(caps);
driver.manage().window().maximize(); //!!!
//driver.manage().window().setSize(new Dimension(1920, 2080));///??? not s solution
driver.get("http://some.url");
WebElement userName = driver.findElement(By.id("login-form-username"));
WebElement passWord = driver.findElement(By.id("login-form-password"));
userName.sendKeys("username");
passWord.sendKeys("password");
passWord.submit();
Thread.sleep(2500);
Screenshot screenshot =
new AShot().takeScreenshot(driver);
ImageIO.write(screenshot.getImage(), "PNG", new File("screenshot_1.png"));
driver.quit();
Any suggestions?
I have been experimenting with using the blur feature of aShot. I have been able to get it to work, but the imageCropper is cropping too much of the page. Is there a way to configure this to still show the entire page, but blur everything except the given webElement?
Hey guys,
This is more of a doubt than an issue. I have been using AShot to take full screenshots in Android. The recommendation I have followed was using ShootingStrategies.viewportRetina method passing the DPR parameter to capture the complete mobile device screen.
From my perspective, this strategy was used since the Browser width/height in the DOM do not match the actual device rendering specification. Hence, we have to pass the DPR parameter indicating the proportional rate between the device resolution and the webpage DOM dimensions.
Is there a reason for not calculating this proportional rate using the BufferedImage.getWidth obtained directly from WebDriver (SimpleShootingStrategy) and DOM width in ViewportPastingDecorator class?
Willian.
I wrote the below code take the screenshots in iOS and Android devices. While capturing screenshot, it is capturing complete screen view by scrolling the page until the timeout session I have given ViewPortPastingStrategy. But after merging all the screenshots, the final screenshot showing a portion of screenshot only not complete screenview.
Attached individual screenshots and finals screenshot. Code is below
final Screenshot screenshot = new AShot().shootingStrategy(new ViewportPastingStrategy(1000)).takeScreenshot(driver);
final BufferedImage image = screenshot.getImage();
ImageIO.write(image, "PNG", "screenshot_1.png"));
Firefox has also removed the feature of taking full page screenshot using Selenium
Is there any plan or workaround to support Firefox in Ashot?
For more information, please see this discussion.
SeleniumHQ/selenium#1141 (comment)
The readme states that I should using the following code but ViewportPastingStrategy() doesn't exist in 1.5.2.
new AShot()
.shootingStrategy(new ViewportPastingStrategy())
.takeScreenshot(webDriver);
Hi
In my application, the scroll bar is in an iframe and all content populate inside that. With the statements mentioned in readme, I am not able to get the complete screenshot. It is skipping few sections to get populate on screen shot. Is there any workaround on same.
You can take any force.com console application to repro this.
Thanks.
I am using this method to crop element screenshot:
private static BufferedImage blurElementOnScreenShot(WebDriver driver,
WebElement element) {
Screenshot imageScreen = new AShot()
.coordsProvider(new WebDriverCoordsProvider())
.imageCropper(new IndentCropper() // overwriting cropper
.addIndentFilter(new BlurFilter()))
.takeScreenshot(driver, element); // adding filter for indent
return imageScreen.getImage();
}
and I am using MAcBook Pro with retina - images are cropped incorrectly in Chrome. The blur effect highlight images incorrectly.
!!! But everything is fine for Firefox browser.
result variable is overwritten two times in ImageMarkupPolicy.
@Override
public int hashCode() {
int result = diffPointCount;
result = 31 * result + xSum - diffPointCount * xReference;
result = 31 * result + ySum - diffPointCount * yReference;
return result;
}
Looks like it should be +=
instead of =
Hi AShot Team,
When I am executing below Java program, I am getting WebDriver Exception for takescreenshot method. Please look into the issue and help me to resolve this. I am using AShot version 1.4.12
System.setProperty("webdriver.chrome.driver",
"src/main/resources/drivers/chromedriver");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.bbc.com");
Thread.sleep(10000);
WebElement element = driver
.findElement(By.cssSelector("#worldService"));
final Screenshot screenshot = new AShot().shootingStrategy(
new ViewportPastingStrategy(500)).takeScreenshot(driver,
element);
final BufferedImage image = screenshot.getImage();
ImageIO.write(image, "PNG", new File(System.getProperty("user.home")
+ "/Documents/AShot_BBC_WebElement.png"));
driver.quit();
Exception:
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: undefined is not a function
(Session info: chrome=43.0.2357.81)
(Driver info: chromedriver=2.15.322455 (ae8db840dac8d0c453355d3d922c91adfb61df8f),platform=Mac OS X 10.10.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 6 milliseconds
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
System info: host: 'Abhisheks-MacBook-Pro.local', ip: '192.168.1.34', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.3', java.version: '1.7.0_79'
Session ID: 3282b4dba0e5dfaf74c935d511ab485e
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/var/folders/fm/thrpfvws2dj9kglbtz3278wstl_32s/T/.org.chromium.Chromium.F8GFJ2}, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=43.0.2357.81, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:508)
at ru.yandex.qatools.ashot.util.JsCoords.findCoordsWithJquery(JsCoords.java:26)
at ru.yandex.qatools.ashot.coordinates.JqueryCoordsProvider.ofElement(JqueryCoordsProvider.java:13)
at ru.yandex.qatools.ashot.coordinates.CoordsProvider.ofElements(CoordsProvider.java:21)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:138)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:155)
at com.tribune.uiautomation.testscripts.AShotTestEntirePage.main(AShotTestEntirePage.java:33)
I'm having trouble capturing the entire page. It appears to only be capturing the top-left corner of the page.
webDriver.navigate().to("https://www.reddit.com/");
String screenshotDirectoryPath = "target/site/screenshots/test/";
new File(screenshotDirectoryPath).mkdirs();
String outputFileName = "reddit.jpg";
File outputFile = new File(screenshotDirectoryPath + "/" + outputFileName);
Screenshot takeScreenshot = new AShot()
.shootingStrategy(ShootingStrategies.viewportPasting(100))
.takeScreenshot(Browser.getDriver());
BufferedImage image = takeScreenshot.getImage();
try {
ImageIO.write(image, "jpg", outputFile);
} catch (IOException e1) {
System.out.println("Unable to save screenshot");
e1.printStackTrace();
}
Here's the screenshot I get with this code:
And here's a comparable screenshot I got using a chrome plugin:
Specs:
It would be nice if the colour for the difference markings could be changed.
If the screenshot contains many red elements, it can be difficult to see where the markings are since they currently are of a pale red.
This is more like question and not an issue.
I wonder whether there is any working example project on github using Ashot where everything required is already programmed.. For example:
Frist run:
The baseline creation of full page or elements on a page
Second run:
The compare
This way i don't have to build all functionalities from scratch
getting below error:
java.lang.NullPointerException
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getCurrentScrollY(ViewportPastingDecorator.java:79)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:54)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:35)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:143)
Hi!
Some image types support transparent color, such as .PNG. So, how can use it property in comparing images (if it is possible)?
Thanks!
I am using MacBook Pro with Retina screen. Chrome Driver 14 and Firefox 36.
On Windows with Full HD screen I am getting same resolution screenshots.
On Mac with Retina I've got for Chrome 2560x1274 screenshot and for FF 1280x630.
How can I get smaller screens for Chrome ?
I'm using this construction to exclude elements on my page from diff comparison:
AShot shooter = new AShot().shootingStrategy(ShootingStrategies.simple())
.ignoredElements(ignoredElements).coordsProvider(new WebDriverCoordsProvider());
However my test is failing and I see marked image with areas it's supposed to ignore.
Ashot version 1.5.2
@pazone
i have read on the link bellow you have mentioned that using Ashot you could successfully get full screenshot.
http://yuluer.sc0713.com/page/cdjjhhab-selenium-webdriver-screenshots-in-opera.shtml#f_pst
Its not working for me, could you please give me the details of your drivers version and browser version you are using, plus if you can provide me with a working code would be much appreciated.
@smecsia @vbauer @eroshenkoam @BorisNaguet @andreas Bovens @cosimo Streppone
please feel free to provide code sample if you feel generous to help new comer
thx SeekingKowledge
If you need to make screenshots on your local monitor (for example, laptop display) there might occur difference between
$(window).height()
and
BufferedImage baseImage = simple().getScreenshot(wd);
int h = baseImage.getHeight();
This is because high-resolution monitors (like retina displays) perform image scaling.
For example, I get following values:
$(window).height(); 728
BufferedImage baseImage = simple().getScreenshot(wd);
int h = baseImage.getHeight(); 1456
and finally this causes missing part of image when parts are combined:
for (int n = 0; n < scrollTimes; n++) {
js.executeScript("scrollTo(0, arguments[0])", winH * n);
waitForScrolling();
BufferedImage part = super.getScreenshot(wd);
graphics.drawImage(part, 0, n * winH, null);
}
On readme.md may see following code:
new AShot()
.shootingStrategy(new ViewportPastingStrategy())
.takeScreenshot(webDriver);
But class ViewportPastingStrategy doesn't exists.
When taking screenshot on iPad horizontally, the screenshot is kept as portrait http://screencast.com/t/vfrXpGlhrs. How should we deal with this?
Thanks
Hi, thanks for AShot and please look at this feature request:
I am using 1.4.12
I am getting following warning on using the ashot lib
Jun 01, 2015 1:45:24 PM org.openqa.selenium.remote.Augmenter extractRemoteWebDriver
WARNING: Augmenter should be applied to the instances of @augmentable classes or previously augmented instances only
Code that I am using
WebDriver webDriver = new FirefoxDriver();
webDriver.get("http://www.google.com");
WebElement element = webDriver.findElement(By.name("q"));
element.sendKeys("Cheese!");
Screenshot screenshot = new AShot()
.shootingStrategy(new ViewportPastingStrategy(0))
.takeScreenshot(webDriver);
File outputfile = new File("saved.png");
ImageIO.write(screenshot.getImage(), "png", outputfile);
element.submit();
Any reason why I am getting this warning ?
Hello,
I am getting erorr on "Screenshot screenshot = new AShot().takeScreenshot(driver, driver.findElement(By.xpath("//*[@id='rc-imageselect-target']")));"
Any advice?
`<dependency>
<groupId>ru.yandex.qatools.ashot</groupId>
<artifactId>ashot</artifactId>
<version>1.5.2</version>
</dependency>`
Code:
private void downloadImg(String imageName, String userCode) { try { Screenshot screenshot = new AShot().takeScreenshot(driver, driver.findElement(By.xpath("//*[@id='rc-imageselect-target']"))); ImageIO.write(screenshot.getImage(), "PNG", new File(imageName)); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
org.openqa.selenium.WebDriverException: unknown error: $ is not defined
(Session info: chrome=55.0.2883.95)
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Mac OS X 10.12.2 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'ITs-MacBook-Pro-7.local', ip: '10.0.0.249', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9), userDataDir=/var/folders/41/pzbtm1m57h9fpx78wl8hvp6mh6vxg_/T/.org.chromium.Chromium.nEk9HB}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=55.0.2883.95, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
Session ID: 8126033dc0318682269890c03bd41228
Hi AShot Team,
When I run the below java code it runs properly,but it captures only current screen. The below part of screen is not captured by this code. please see the below code ๐
System.setProperty("webdriver.chrome.driver", "D:\\selenium\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.bbc.com");
Thread.sleep(5000);
(new WebDriverWait(driver, 60)).until(new ExpectedCondition<WebElement>() {
public WebElement apply(WebDriver newDriver) {
return newDriver.findElement(By.cssSelector(".wsradio__title__link"));
}
});
final Screenshot screenshot = new AShot().coordsProvider(new WebDriverCoordsProvider()).takeScreenshot(driver);
final BufferedImage image = screenshot.getImage();
ImageIO.write(image, "PNG", new File("D:\\temp\\"+ "AShot_BBC_Entire.png"));
driver.quit();
Please provide the solution. It works perfectly in Firefox browser.
Hii Ashot Team,
I'm getting WebDriver Exception for taking screenshot of an invisible element (need to scroll down to find this element).
Exception:
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: $ is not defined
Code :
WebElement element = driver.findElement(By.cssSelector("#imgId"));
Screenshot screenshot = new AShot().shootingStrategy(new ViewportPastingStrategy(1000)).takeScreenshot(driver,element);
ImageIO.write(screenshot.getImage(), "PNG", new File("C:\screenshot.png"));
I use method takeScreenshot(driver, webElement); but it doesn't work in page http://193.0.171.22/23/29/48/1508849232/1508868043_square_incognito.jpg?hash=VFTT1R5jMmaVBTrO253rmQ&expires=1442437199&updated=1442335699
Is it because the page doesn't have JS?
How I can to take screenshon on this page?
I am trying to capture full mobile web page view using Ashot latest jar. Following are the code I used
Screenshot sh = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(500)).takeScreenshot(driver);
BufferedImage fullScreen = sh.getImage();
ImageIO.write(fullScreen, "png", new File("D:\test"+"coool.png"));
Site: http://www.rapidvaluesolutions.com/
Loaded in Mobile Web and captured using above code.
Hi,
I'm trying to feed ashot a bunch of different elements to screenshot, like this:
ru.yandex.qatools.ashot.Screenshot myScreenshot = new AShot() .takeScreenshot(_driver.getWebDriver(), element);
But despite the element size being 94*36px, Ashot will instead take a regular screenshot of the visible bit of the page, not even scrolling to the actual position of the element.
Am I doing something wrong?
I have screenshots that have minor differences and I would like to ignore them. I don't want to ignore webElements while capturing screenshots, - I just want to set some comparison rate during compare procedure, let say like uncertainty 5% between screenshots. Is it possible ?
I'm afraid i can not find the class ViewportPastingStrategy,where is it?
Hi All,
I have written the below code to capture the entire webpage of [www.flipkart.com]
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.openqa.selenium.By;
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);
//Take the screenshot of the entire home page and save it to a png file
Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(100)).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();
}
}
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']")));
Oct 08, 2016 2:29:09 AM 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.
1475911750672 Marionette INFO Listening on port 54373
1475911752234 Marionette INFO startBrowser 7fc07847-22bf-484b-ac3b-5dfaf2f7f45f
Oct 08, 2016 2:29:12 AM 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: '3169782', time: '2016-09-29 10:24:50 -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_101'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, appBuildId=20160922113459, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=11664, browserVersion=49.0.1, platformVersion=10.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop}]
Session ID: 7fc07847-22bf-484b-ac3b-5dfaf2f7f45f
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: '3169782', time: '2016-09-29 10:24:50 -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_101'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, appBuildId=20160922113459, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=11664, browserVersion=49.0.1, platformVersion=10.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop}]
Session ID: 7fc07847-22bf-484b-ac3b-5dfaf2f7f45f
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:126)
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:602)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:538)
at ru.yandex.qatools.ashot.util.InnerScript.execute(InnerScript.java:27)
... 5 more
I'm Using:
Firefox Version: 49.0.1
Selenium Version: Version 3.0.0-beta4
OS: Win10 64 bit
Java: 1.8
I am getting following warning on using the ashot lib
lis 30, 2016 12:57:14 PM org.openqa.selenium.remote.Augmenter extractRemoteWebDriver
WARNING: Augmenter should be applied to the instances of @augmentable classes or previously augmented instances only
lis 30, 2016 12:57:16 PM org.openqa.selenium.remote.Augmenter extractRemoteWebDriver
WARNING: Augmenter should be applied to the instances of @augmentable classes or previously augmented instances only
ashot 1.5.2
selenium 2.53.0
code:
public class ashot {
private static WebDriver driver;
@BeforeTest
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver", "./libs/chromedriver.exe");
DesiredCapabilities cap = DesiredCapabilities.chrome();
driver = new ChromeDriver(cap);
}
@Test
public void github() throws IOException{
driver.get("https://github.com");
Screenshot screenshot = new AShot()
.shootingStrategy(ShootingStrategies.viewportPasting(100))
.takeScreenshot(driver);
ImageIO.write(screenshot.getImage(), "PNG", new File("./ashot/screen.png"));
}
@AfterTest
public void close() {
driver.quit();
}
}
Please write here found with WebDriver 3.0 and AShot
http://prntscr.com/75f7x7
Here is screenshot;
May be it is my fault, but all my elements selenium successfully finds in other tests, only trying to make the shot of the element xpath got cut;
@eroshenkoam, @lanwen, @qatools-ci
Hi!
Can you release latest version of the AShot ? A lot of changes awaits =)
Thanks.
public class IndiaTimes {
public static void main(String[] args) throws IOException, InterruptedException {
WebDriver wd = new SafariDriver();
wd.get("http://www.indiatimes.com");
Thread.sleep(5000);
((JavascriptExecutor) wd).executeScript("$('#wrap header').hide();");
Thread.sleep(500);
WebElement we = wd.findElement(By.cssSelector("#hp_block_2"));
final Screenshot screenshot = new AShot()
.shootingStrategy(new ViewportPastingStrategy(1500))
.takeScreenshot(wd, we);
final BufferedImage image = screenshot.getImage();
ImageIO.write(image, "PNG",
new File(System.getProperty("user.home") + "/AShot_indiatimes.png"));
}
}
@abhishekkyd @pazone @frolovs I am using the code that you are suggesting that it will work for safari, but it is not working for me on safari... I have attached the screenshot I obtained using the code above... please provide any configuration i need for Safari and IE.
I am new sorry if i ask some silly question or use inappropriate words...
thank you
hello everyone , I am very new with Ashot, I was trying to get browser full screenshot, I can take it fine with Opera, Chrome but it repeat the first display screen image for the rest of the browser. Is there different function i need to use for different browser (safari, IE and fireforx).
please provide me a sample code and help.
your time and sample code will be much appreciated.
Cheeers
Hello,
I try to get a screenshot in headless Chrome (inside Docker) via
Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(10)).takeScreenshot(driver)
and on-time get the Execption:
java.lang.RuntimeException: Unexpected result for screenshot command: null
at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:391)
at ru.yandex.qatools.ashot.shooting.SimpleShootingStrategy.getScreenshot(SimpleShootingStrategy.java:31)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:53)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:35)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:145)
and next time another:
java.lang.NullPointerException
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getCurrentScrollY(ViewportPastingDecorator.java:80)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:54)
at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:35)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:145)
but never without error :(
Maybe I must use another Strategy? Without ViewPortPasting I get no errors, but the created screenshot has only the viewable part of page without scrolling.
Could You please help me?
Thanks.
Getting black spot on the Chrome-Tablet emulator screenshot while Capturing the entire page by using
new AShot()
.shootingStrategy(ShootingStrategies.viewportPasting(100))
.takeScreenshot(webDriver);
Same works fine for Chrome- Phone emulator.
Please provide resolution for this issue.
Here is the code.
String baseUrl = "https://github.com/yandex-qatools/ashot";
Map<String, String> mobileEmulation = new HashMap<String, String>();
mobileEmulation.put("deviceName", "Apple iPad");
Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("mobileEmulation", mobileEmulation);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
WebDriver driver = new ChromeDriver(capabilities);
driver.manage().window().maximize();
driver.get(baseUrl);
final Screenshot screenshot = new AShot()
.shootingStrategy(ShootingStrategies.viewportPasting(100))
.takeScreenshot(driver);
final BufferedImage image = screenshot.getImage();
ImageIO.write(image, "PNG", new File("C:\\Selenium\\"+ "Ahot-Tablet.png"));
I have added maven dependency and injected Ashot to my code for selenium tests, but it is not working at all.
I was trying screenshot of whole page, screenshots of separate leements.
I receive such error after executin mvn clean test:
demoTest(framework.utils.tests.WebDriverDemoTest) Time elapsed: 16.161 sec <<<
FAILURE!
org.openqa.selenium.WebDriverException: $ is not defined
Command duration or timeout: 1.04 seconds
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43a
d8', time: '2014-10-23 13:11:40'
System info: host: 'CP0528', ip: '172.25.113.47', os.name: 'Windows 7', os.arch:
'amd64', os.version: '6.1', java.version: '1.7.0_67'
Session ID: 49c82632-7ae3-4066-b813-d5c263ae6c05
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, acceptSslCerts=true, javascriptEnabled=true, cs
sSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts
=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationConte
xtEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=33.0
.2}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.
java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHa
ndler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.ja
va:599)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDri
ver.java:508)
at ru.yandex.qatools.ashot.util.JsCoords.findCoordsWithJquery(JsCoords.j
ava:26)
at ru.yandex.qatools.ashot.coordinates.JqueryCoordsProvider.ofElement(Jq
ueryCoordsProvider.java:13)
at ru.yandex.qatools.ashot.coordinates.CoordsProvider.ofElements(CoordsP
rovider.java:20)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:110)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:127)
at framework.utils.tests.WebDriverDemoTest.searchGoogleEleks(WebDriverDe
moTest.java:65)
at framework.utils.tests.WebDriverDemoTest.demoTest(WebDriverDemoTest.ja
va:49)
Caused by: org.openqa.selenium.WebDriverException: $ is not defined
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43a
d8', time: '2014-10-23 13:11:40'
System info: host: 'CP0528', ip: '172.25.113.47', os.name: 'Windows 7', os.arch:
'amd64', os.version: '6.1', java.version: '1.7.0_67'
Driver info: driver.version: unknown
at .anonymous(https://www.google.com.ua/?gfe_rd=cr&ei=7
I1XVKGaLaaH8Qfo-oHIAw&gws_rd=ssl#q=eleks line 68 > Function:19:10)
at .handleEvaluateEvent(https://www.google.com.ua/?gfe_
rd=cr&ei=7I1XVKGaLaaH8Qfo-oHIAw&gws_rd=ssl#q=eleks:68:20)
Is there a way to snap all entries in a drop-down having scrollbars?
Using aShot 1.5.2 version in project. And have a problem. How to set transparent color for ignorred regions of image?
Try use
ImageDiffer imageDifferWithIgnored = new ImageDiffer().withIgnoredColor(Color.MAGENTA);
but method withIgnoredColor() is not found in lib.
Thanks!
I am working on below code
WebDriver wd = new FirefoxDriver();
wd.get("http://www.indiatimes.com");
new AShot()
.shootingStrategy(new ViewportPastingStrategy(0))
.takeScreenshot(wd);
getting below error, please suggest the solution
Exception in thread "main" java.lang.NullPointerException
at ru.yandex.qatools.ashot.screentaker.VerticalPastingShootingStrategy.shiftCoords(VerticalPastingShootingStrategy.java:90)
at ru.yandex.qatools.ashot.screentaker.VerticalPastingShootingStrategy.getScreenshot(VerticalPastingShootingStrategy.java:43)
at ru.yandex.qatools.ashot.screentaker.VerticalPastingShootingStrategy.getScreenshot(VerticalPastingShootingStrategy.java:33)
at ru.yandex.qatools.ashot.screentaker.ScreenTaker.take(ScreenTaker.java:25)
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:166)
at ru.yandex.qatools.elementscompare.tests.MyTest.main(MyTest.java:28)
I am using below code to capture screenshot in chrome but it capture same thing multiple times in screenshot. I just want to take full screenshot of page in chrome browser.
Screenshot screenshot = new AShot()
.shootingStrategy(ShootingStrategies.viewportPasting(500))
.takeScreenshot(driver);
When a website site have a fixed navigation menu. It's appear on all the segment
of the screenshot.
Try a screenshot of http://stackoverflow.com
It's will be nice if we can avoid that
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.