简体   繁体   中英

Can not take a full page screenshot in Applitools C#

I'm trying to take a full screen screenshot of my page by using this code:

public void OpenEyesForVisualTesting(string testName) {
 this.seleniumDriver.Driver = this.eyes.Open(this.seleniumDriver.Driver, "Zinc", testName);

}

public void CheckScreenForVisualTesting() {
 this.eyes.Check("Zinc", Applitools.Selenium.Target.Window().Fully());
}

public void CloseEyes() {
 this.eyes.close();
}

but instead I just get a half a page of the screenshot, I tried to contact Applitools but they just told me to replace eyes.checkwindow() to eyes.Check("tag", Target.Window().Fully()); which still didn't work.

If anyone can help me that would be great.

I work for Applitools and sorry for your troubles. Maybe you did not see our replies or they went to your spam folder. You need to set ForceFullPageScreenshot = true and StitchMode = StitchModes.CSS in order to capture a full page screenshot.

The below code example is everything you'd need to do in order to capture a full page image. Also, please make sure your .Net Eyes.Sdk version is >= 2.6.0 and Eyes.Selenium >= 2.5.0.

If you have any further questions or still encountering issues with this please feel free to email me directly. Thanks.

var eyes = new Eyes();
eyes.ApiKey = "your-api-key";
eyes.ForceFullPageScreenshot = true;
eyes.StitchMode = StitchModes.CSS;

eyes.Open(driver, "Zinc", testName, new Size(800, 600)); //last parameter is your viewport size IF testing on a browser. Do not set if testing on a mobile devices.
eyes.CheckWindow("Zinc");
//or new Fluet API method
eyes.Check("Zinc", Applitools.Selenium.Target.Window().Fully();
eyes.Close();

Use extent Reporting library, in that you can take screen shot as well as an interactive report on pass and fail cases. here is the link how it works:http://www.softwaretestingmaterial.com/generate-extent-reports/

If you want to take complete page Screenshot/ Particular element with Applitools. You can use lines of code:-

Full Screenshot

eyes.setHideScrollbars(false);
eyes.setStitchMode(StitchMode.CSS);
eyes.setForceFullPageScreenshot(true);
eyes.checkWindow();

Take screenshot for particular element

WebElement Button = driver.findElement(By.xpath("//button[@id='login-btn']"));
eyes.setHideScrollbars(false);
eyes.setStitchMode(StitchMode.CSS);     
eyes.open(driver, projectName, testName);
eyes.setMatchLevel(MatchLevel.EXACT);       
eyes.checkElement(Button );

(I am from Applitools.)

When setting forcefullpagescreenshoot to true, applitools will try to scroll the HTML element in the page, if the HTML is not the scrollable element then you will need to set it yourself:

eyes.Check(Target.Window().ScrollRootElement(selector))

In Firefox, you can see a scroll tag near elements that are scrollable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM