This commit is contained in:
Simon Cropp 2021-12-09 23:57:29 +11:00
Родитель 8300ad629e
Коммит 414d5fdaf2
6 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -29,8 +29,9 @@ Enable VerifyPlaywright once at assembly load time:
<a id='snippet-playwrightenable'></a>
```cs
VerifyPlaywright.Enable();
Microsoft.Playwright.Program.Main(new[] {"install"});
```
<sup><a href='/src/Tests/ModuleInitializer.cs#L14-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-playwrightenable' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/ModuleInitializer.cs#L14-L19' title='Snippet source file'>snippet source</a> | <a href='#snippet-playwrightenable' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -148,7 +149,7 @@ Enable VerifyPuppeteer once at assembly load time:
```cs
VerifyPuppeteer.Enable();
```
<sup><a href='/src/Tests/ModuleInitializer.cs#L20-L24' title='Snippet source file'>snippet source</a> | <a href='#snippet-puppeteerenable' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Tests/ModuleInitializer.cs#L21-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-puppeteerenable' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Просмотреть файл

@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649;CS8632</NoWarn>
<Version>1.3.0</Version>
<Version>1.4.0</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
</PropertyGroup>
</Project>

Просмотреть файл

@ -15,6 +15,7 @@ public static class ModuleInitializer
VerifyPlaywright.Enable();
Microsoft.Playwright.Program.Main(new[] {"install"});
#endregion
#region PuppeteerEnable

Просмотреть файл

@ -23,8 +23,8 @@ public class SeleniumFixture :
public Task DisposeAsync()
{
Driver.Quit();
Driver.Dispose();
Driver?.Quit();
Driver?.Dispose();
return Task.CompletedTask;
}
}

Просмотреть файл

@ -1,10 +1,9 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
static class SeleniumExtensions
{
public static void WaitForIsReady(this RemoteWebDriver driver)
public static void WaitForIsReady(this WebDriver driver)
{
WebDriverWait wait = new(driver, TimeSpan.FromSeconds(10));
wait.Until(_ =>

Просмотреть файл

@ -1,5 +1,4 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
namespace VerifyTests;
@ -7,14 +6,14 @@ public static class VerifySelenium
{
public static void Enable()
{
VerifierSettings.RegisterFileConverter<RemoteWebDriver>(DriverToImage);
VerifierSettings.RegisterFileConverter<WebDriver>(DriverToImage);
VerifierSettings.RegisterFileConverter<IWebElement>(ElementToImage);
}
static ConversionResult ElementToImage(IWebElement target, IReadOnlyDictionary<string, object> context)
{
var element = (WebElement)target;
var driver = (RemoteWebDriver)element.WrappedDriver;
var driver = (WebDriver)element.WrappedDriver;
driver.WaitForIsReady();
var bytes = element.GetScreenshot().AsByteArray;
return new(
@ -27,7 +26,7 @@ public static class VerifySelenium
);
}
static ConversionResult DriverToImage(RemoteWebDriver driver, IReadOnlyDictionary<string, object> context)
static ConversionResult DriverToImage(WebDriver driver, IReadOnlyDictionary<string, object> context)
{
driver.WaitForIsReady();
var bytes = driver.GetScreenshot().AsByteArray;