-
Notifications
You must be signed in to change notification settings - Fork 130
Visual Testing
Jakub Raczek edited this page Mar 8, 2021
·
2 revisions
Screenshots of elements can be saved to allow you images comparison with e.g baseline:
var el = this.Driver.GetElement(this.menu);
TakeScreenShot.TakeScreenShotOfElement(el, TestContext.CurrentContext.TestDirectory + BaseConfiguration.ScreenShotFolder, "MenuOutSideTheIFrame");
more details here
Screenshots of specific element within iframe can be taken by passing location of iframe to TakeScreenShotOfElement method:
var iFrame = this.Driver.GetElement(this.iframe);
int x = iFrame.Location.X;
int y = iFrame.Location.Y;
this.Driver.SwitchTo().Frame(0);
var el = this.Driver.GetElement(this.elelemtInIFrame);
TakeScreenShot.TakeScreenShotOfElement(x, y, el, TestContext.CurrentContext.TestDirectory + BaseConfiguration.ScreenShotFolder, "MenuOutSideTheIFrame");
more details here
Test example of comparing screen shot of elements using ImageMagick, more details here
[Test]
public void TakingScreehShotsOfElementInIFrameTest()
{
var internetPage = new InternetPage(this.DriverContext).OpenHomePage();
internetPage.GoToIFramePage();
IFramePage page = new IFramePage(this.DriverContext);
var path = page.TakeScreenShotsOfTextInIFrame(TestContext.CurrentContext.TestDirectory + BaseConfiguration.ScreenShotFolder, "TextWithinIFrame" + BaseConfiguration.TestBrowser);
var path2 = TestContext.CurrentContext.TestDirectory + BaseConfiguration.ScreenShotFolder + "\\TextWithinIFrameChromeError.png";
bool flag = true;
using (var img1 = new MagickImage(path))
{
using (var img2 = new MagickImage(path2))
{
using (var imgDiff = new MagickImage())
{
img1.Compose = CompositeOperator.Src;
img1.Compare(img2, new ErrorMetric(), imgDiff);
flag = img1.Equals(img2);
imgDiff.Write(TestContext.CurrentContext.TestDirectory + BaseConfiguration.ScreenShotFolder + "\\" + BaseConfiguration.TestBrowser + "TextWithinIFrameDIFF.png");
}
}
}
Assert.IsFalse(flag);
}
Result of image comparison:
Expected result:
Actual result:
Result with marked differences:
- Home
- Getting started
- Parallel tests execution
- MsTest DataDriven tests from Xml and CSV files
- NUnit DataDriven tests from Xml, CSV and Excel files
- Comparing files by NUnit DataDriven tests
- Visual Testing
- Screen shots: full desktop, selenium. PageSource saving
- Verify-asserts without stop tests
- Downloading files
- Helpers
- Override browser profile preferences, install browser extensions, Headless mode
- Debugging Test.Automation framework
- Logging
- Performance measures
- Webdriver Extends
- More common locators
- Selenium-Grid-support
- Advanced Browser Capabilities and Options
- AngularJS synchronization
- Update App.config or appsettings.json
- Cross browser parallel test execution with testing-Cloud-Providers\SeleniumGrid
- Verifying Javascript Errors from browser
- Enabling Performance Log for Chrome
- Azure DevOps Support
- Edge browser Support
- Downloading and running Selenium Grid with Powershell
- Run Ocaramba tests with Docker container
- HTTP auth in Internet explorer
- ExtentReports Support