xUnit test, runner, delete Playwright

This commit is contained in:
Lukáš Kaňka 2023-08-25 06:54:49 +02:00
parent 37fc3e4933
commit 7ad075bd58
487 changed files with 8139 additions and 103422 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

View File

@ -0,0 +1,5 @@
{
"recommendations": [
"ms-vscode.test-adapter-converter"
]
}

View File

@ -1,2 +1,18 @@
{
"dotnet-test-explorer.testProjectPath": "*Tests*",
"nunitTestRunner.projectsPatterns": [
"**/bin/*.Tests.dll",
"*Tests*"
],
"nunitTestRunner.testsCategory": [
{
"projectName": "Foo.dll",
"categories": [
"IntegrationTests",
"FunctionalTests"
]
}
]
}

View File

@ -17,27 +17,18 @@ using LukanPOM.PageObjects;
using LukanPOM.Common;
namespace LukanPOM.Tests
{
{
//private IWebDriver? _driver;
internal class TitleTest : TestBase
{
[Test]
public void TitleVerifiTest()
{
home
home
.Titulek()
.TestProsel();
}
}
}
}
}

View File

@ -1,30 +1,48 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v7.0",
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v7.0": {
"PlaywrightTests/1.0.0": {
".NETCoreApp,Version=v6.0": {
"LukanPOM.Tests/1.0.0": {
"dependencies": {
"DotNetSeleniumExtras.PageObjects.Core": "4.3.0",
"Microsoft.NET.Test.Sdk": "17.6.0",
"Microsoft.Playwright.NUnit": "1.37.1",
"NUnit": "3.13.3",
"NUnit.Analyzers": "3.6.1",
"NUnit3TestAdapter": "4.4.2",
"NUnit.ConsoleRunner": "3.16.3",
"NUnit3TestAdapter": "4.5.0",
"Selenium.Support": "4.11.0",
"Selenium.WebDriver": "4.11.0",
"WebDriverManager": "2.17.1",
"coverlet.collector": "3.2.0"
},
"runtime": {
"PlaywrightTests.dll": {}
"LukanPOM.Tests.dll": {}
}
},
"AngleSharp/1.0.4": {
"dependencies": {
"System.Text.Encoding.CodePages": "6.0.0"
},
"runtime": {
"lib/net6.0/AngleSharp.dll": {
"assemblyVersion": "1.0.4.0",
"fileVersion": "1.0.4.0"
}
}
},
"coverlet.collector/3.2.0": {},
"Microsoft.Bcl.AsyncInterfaces/7.0.0": {
"DotNetSeleniumExtras.PageObjects.Core/4.3.0": {
"dependencies": {
"Selenium.WebDriver": "4.11.0"
},
"runtime": {
"lib/netstandard2.1/Microsoft.Bcl.AsyncInterfaces.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
"lib/net5.0/SeleniumExtras.PageObjects.dll": {
"assemblyVersion": "4.3.0.0",
"fileVersion": "4.3.0.0"
}
}
},
@ -42,47 +60,7 @@
"Microsoft.TestPlatform.TestHost": "17.6.0"
}
},
"Microsoft.NETCore.Platforms/1.1.0": {},
"Microsoft.Playwright/1.37.1": {
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "7.0.0",
"System.ComponentModel.Annotations": "5.0.0",
"System.Text.Json": "7.0.0"
},
"runtime": {
"lib/netstandard2.0/Microsoft.Playwright.dll": {
"assemblyVersion": "1.37.1.0",
"fileVersion": "1.37.1.0"
}
}
},
"Microsoft.Playwright.NUnit/1.37.1": {
"dependencies": {
"Microsoft.NET.Test.Sdk": "17.6.0",
"Microsoft.Playwright": "1.37.1",
"Microsoft.Playwright.TestAdapter": "1.37.1",
"NUnit": "3.13.3",
"NUnit3TestAdapter": "4.4.2"
},
"runtime": {
"lib/netstandard2.0/Microsoft.Playwright.NUnit.dll": {
"assemblyVersion": "1.37.1.0",
"fileVersion": "1.37.1.0"
}
}
},
"Microsoft.Playwright.TestAdapter/1.37.1": {
"dependencies": {
"Microsoft.Playwright": "1.37.1",
"Microsoft.TestPlatform.ObjectModel": "17.6.0"
},
"runtime": {
"lib/netstandard2.0/Microsoft.Playwright.TestAdapter.dll": {
"assemblyVersion": "1.37.1.0",
"fileVersion": "1.37.1.0"
}
}
},
"Microsoft.NETCore.Platforms/5.0.0": {},
"Microsoft.TestPlatform.ObjectModel/17.6.0": {
"dependencies": {
"NuGet.Frameworks": "5.11.0",
@ -330,9 +308,15 @@
}
}
},
"Microsoft.Win32.Registry/5.0.0": {
"dependencies": {
"System.Security.AccessControl": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"NETStandard.Library/2.0.0": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
"Microsoft.NETCore.Platforms": "5.0.0"
}
},
"Newtonsoft.Json/13.0.1": {
@ -363,23 +347,112 @@
}
},
"NUnit.Analyzers/3.6.1": {},
"NUnit3TestAdapter/4.4.2": {},
"System.ComponentModel.Annotations/5.0.0": {},
"System.Reflection.Metadata/1.6.0": {},
"System.Text.Encodings.Web/7.0.0": {},
"System.Text.Json/7.0.0": {
"NUnit.ConsoleRunner/3.16.3": {},
"NUnit3TestAdapter/4.5.0": {},
"Selenium.Support/4.11.0": {
"dependencies": {
"Selenium.WebDriver": "4.11.0"
},
"runtime": {
"lib/net6.0/WebDriver.Support.dll": {
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.0.0.0"
}
}
},
"Selenium.WebDriver/4.11.0": {
"dependencies": {
"Newtonsoft.Json": "13.0.1"
},
"runtime": {
"lib/net6.0/WebDriver.dll": {
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.0.0.0"
}
}
},
"SharpZipLib/1.4.2": {
"runtime": {
"lib/net6.0/ICSharpCode.SharpZipLib.dll": {
"assemblyVersion": "1.4.2.13",
"fileVersion": "1.4.2.13"
}
}
},
"System.Reflection.Metadata/1.6.0": {},
"System.Runtime.CompilerServices.Unsafe/6.0.0": {},
"System.Security.AccessControl/5.0.0": {
"dependencies": {
"Microsoft.NETCore.Platforms": "5.0.0",
"System.Security.Principal.Windows": "5.0.0"
}
},
"System.Security.Principal.Windows/5.0.0": {},
"System.Text.Encoding.CodePages/6.0.0": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"System.Text.Encodings.Web/7.0.0": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
},
"runtime": {
"lib/net6.0/System.Text.Encodings.Web.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
},
"runtimeTargets": {
"runtimes/browser/lib/net6.0/System.Text.Encodings.Web.dll": {
"rid": "browser",
"assetType": "runtime",
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
},
"System.Text.Json/7.0.3": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0",
"System.Text.Encodings.Web": "7.0.0"
},
"runtime": {
"lib/net6.0/System.Text.Json.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.723.27404"
}
}
},
"WebDriverManager/2.17.1": {
"dependencies": {
"AngleSharp": "1.0.4",
"Microsoft.Win32.Registry": "5.0.0",
"SharpZipLib": "1.4.2",
"System.Text.Json": "7.0.3"
},
"runtime": {
"lib/netstandard2.1/WebDriverManager.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
}
}
},
"libraries": {
"PlaywrightTests/1.0.0": {
"LukanPOM.Tests/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"AngleSharp/1.0.4": {
"type": "package",
"serviceable": true,
"sha512": "sha512-G8R4C2MEDFQvjUbYz1QIcGfibjsTJnzP0aWy8iQgWWk7eKacYydCNGD3JMhVL0Q5pZQ9RYlqpKNESEU5NpqsRw==",
"path": "anglesharp/1.0.4",
"hashPath": "anglesharp.1.0.4.nupkg.sha512"
},
"coverlet.collector/3.2.0": {
"type": "package",
"serviceable": true,
@ -387,12 +460,12 @@
"path": "coverlet.collector/3.2.0",
"hashPath": "coverlet.collector.3.2.0.nupkg.sha512"
},
"Microsoft.Bcl.AsyncInterfaces/7.0.0": {
"DotNetSeleniumExtras.PageObjects.Core/4.3.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-3aeMZ1N0lJoSyzqiP03hqemtb1BijhsJADdobn/4nsMJ8V1H+CrpuduUe4hlRdx+ikBQju1VGjMD1GJ3Sk05Eg==",
"path": "microsoft.bcl.asyncinterfaces/7.0.0",
"hashPath": "microsoft.bcl.asyncinterfaces.7.0.0.nupkg.sha512"
"sha512": "sha512-ZqD0Rx5On7NvcwAQbnNnnUy1czifVYin17TN4jnWCIKkKofBJLMK0a0aR/uQ7sF9atUlOKHJRLjs6mZQ9shbTw==",
"path": "dotnetseleniumextras.pageobjects.core/4.3.0",
"hashPath": "dotnetseleniumextras.pageobjects.core.4.3.0.nupkg.sha512"
},
"Microsoft.CodeCoverage/17.6.0": {
"type": "package",
@ -408,33 +481,12 @@
"path": "microsoft.net.test.sdk/17.6.0",
"hashPath": "microsoft.net.test.sdk.17.6.0.nupkg.sha512"
},
"Microsoft.NETCore.Platforms/1.1.0": {
"Microsoft.NETCore.Platforms/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
"path": "microsoft.netcore.platforms/1.1.0",
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
},
"Microsoft.Playwright/1.37.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-pmZrHEDNTyJKEW3nxIJ4jdCYwSPBUGV4mc3KscVpu0NvJ2ATMtYuh6NQOLNAxIAJXoxOS6trw6cVU++mnYMf+g==",
"path": "microsoft.playwright/1.37.1",
"hashPath": "microsoft.playwright.1.37.1.nupkg.sha512"
},
"Microsoft.Playwright.NUnit/1.37.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-xbtRQXVHNJt0erl/mlo9YrGhkec3pa9rFv5x6WMCAkU1XJYATLiB4GhDdVkULRW7az4qU4d2wzRD6X4aZ8TDuw==",
"path": "microsoft.playwright.nunit/1.37.1",
"hashPath": "microsoft.playwright.nunit.1.37.1.nupkg.sha512"
},
"Microsoft.Playwright.TestAdapter/1.37.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-sgruUgpa8f8mZKEXUrkVtHPuebfBX7t/l1WHPEvroIYVDWw3jH2ivfGnYnZlTwVIt7+6rK4PJnJCSd1McdRRLg==",
"path": "microsoft.playwright.testadapter/1.37.1",
"hashPath": "microsoft.playwright.testadapter.1.37.1.nupkg.sha512"
"sha512": "sha512-VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ==",
"path": "microsoft.netcore.platforms/5.0.0",
"hashPath": "microsoft.netcore.platforms.5.0.0.nupkg.sha512"
},
"Microsoft.TestPlatform.ObjectModel/17.6.0": {
"type": "package",
@ -450,6 +502,13 @@
"path": "microsoft.testplatform.testhost/17.6.0",
"hashPath": "microsoft.testplatform.testhost.17.6.0.nupkg.sha512"
},
"Microsoft.Win32.Registry/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-dDoKi0PnDz31yAyETfRntsLArTlVAVzUzCIvvEDsDsucrl33Dl8pIJG06ePTJTI3tGpeyHS9Cq7Foc/s4EeKcg==",
"path": "microsoft.win32.registry/5.0.0",
"hashPath": "microsoft.win32.registry.5.0.0.nupkg.sha512"
},
"NETStandard.Library/2.0.0": {
"type": "package",
"serviceable": true,
@ -485,19 +544,40 @@
"path": "nunit.analyzers/3.6.1",
"hashPath": "nunit.analyzers.3.6.1.nupkg.sha512"
},
"NUnit3TestAdapter/4.4.2": {
"NUnit.ConsoleRunner/3.16.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-vA/iHYcR+LYw+pRWQugckC/zW2fXHaqMr2uA82NOBt8v4YK4wMJrQ7QC8XLc7PjetEZ96cPbBTWsDDtmQiRZTA==",
"path": "nunit3testadapter/4.4.2",
"hashPath": "nunit3testadapter.4.4.2.nupkg.sha512"
"sha512": "sha512-bhc4f0oVdS70xLaulPu2dMuUWK6hLj5fWLWmUnvbxyEA9w41sZNe6Xb3vPkcp+5OrIqggmtcRbhX+o5hoz62Jg==",
"path": "nunit.consolerunner/3.16.3",
"hashPath": "nunit.consolerunner.3.16.3.nupkg.sha512"
},
"System.ComponentModel.Annotations/5.0.0": {
"NUnit3TestAdapter/4.5.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==",
"path": "system.componentmodel.annotations/5.0.0",
"hashPath": "system.componentmodel.annotations.5.0.0.nupkg.sha512"
"sha512": "sha512-s8JpqTe9bI2f49Pfr3dFRfoVSuFQyraTj68c3XXjIS/MRGvvkLnrg6RLqnTjdShX+AdFUCCU/4Xex58AdUfs6A==",
"path": "nunit3testadapter/4.5.0",
"hashPath": "nunit3testadapter.4.5.0.nupkg.sha512"
},
"Selenium.Support/4.11.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-PR7ssrG9peQ5AqPSNvOJ846FFOX1wSv5eV3/8zvYwf0jhNx2bEprBZbtYMSWtht+HXtC5xb6atRQLlpKD+FETQ==",
"path": "selenium.support/4.11.0",
"hashPath": "selenium.support.4.11.0.nupkg.sha512"
},
"Selenium.WebDriver/4.11.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-V8o+Nvi9/3Ix12ZzMGg+fI7sfu+HrflZkMGq8Orr+j0INbfpEEyM6KR9oaaHlm0WUXcn7dTYwyWrJxYsi6eniw==",
"path": "selenium.webdriver/4.11.0",
"hashPath": "selenium.webdriver.4.11.0.nupkg.sha512"
},
"SharpZipLib/1.4.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-yjj+3zgz8zgXpiiC3ZdF/iyTBbz2fFvMxZFEBPUcwZjIvXOf37Ylm+K58hqMfIBt5JgU/Z2uoUS67JmTLe973A==",
"path": "sharpziplib/1.4.2",
"hashPath": "sharpziplib.1.4.2.nupkg.sha512"
},
"System.Reflection.Metadata/1.6.0": {
"type": "package",
@ -506,6 +586,34 @@
"path": "system.reflection.metadata/1.6.0",
"hashPath": "system.reflection.metadata.1.6.0.nupkg.sha512"
},
"System.Runtime.CompilerServices.Unsafe/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==",
"path": "system.runtime.compilerservices.unsafe/6.0.0",
"hashPath": "system.runtime.compilerservices.unsafe.6.0.0.nupkg.sha512"
},
"System.Security.AccessControl/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-dagJ1mHZO3Ani8GH0PHpPEe/oYO+rVdbQjvjJkBRNQkX4t0r1iaeGn8+/ybkSLEan3/slM0t59SVdHzuHf2jmw==",
"path": "system.security.accesscontrol/5.0.0",
"hashPath": "system.security.accesscontrol.5.0.0.nupkg.sha512"
},
"System.Security.Principal.Windows/5.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA==",
"path": "system.security.principal.windows/5.0.0",
"hashPath": "system.security.principal.windows.5.0.0.nupkg.sha512"
},
"System.Text.Encoding.CodePages/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-ZFCILZuOvtKPauZ/j/swhvw68ZRi9ATCfvGbk1QfydmcXBkIWecWKn/250UH7rahZ5OoDBaiAudJtPvLwzw85A==",
"path": "system.text.encoding.codepages/6.0.0",
"hashPath": "system.text.encoding.codepages.6.0.0.nupkg.sha512"
},
"System.Text.Encodings.Web/7.0.0": {
"type": "package",
"serviceable": true,
@ -513,12 +621,19 @@
"path": "system.text.encodings.web/7.0.0",
"hashPath": "system.text.encodings.web.7.0.0.nupkg.sha512"
},
"System.Text.Json/7.0.0": {
"System.Text.Json/7.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-DaGSsVqKsn/ia6RG8frjwmJonfos0srquhw09TlT8KRw5I43E+4gs+/bZj4K0vShJ5H9imCuXupb4RmS+dBy3w==",
"path": "system.text.json/7.0.0",
"hashPath": "system.text.json.7.0.0.nupkg.sha512"
"sha512": "sha512-AyjhwXN1zTFeIibHimfJn6eAsZ7rTBib79JQpzg8WAuR/HKDu9JGNHTuu3nbbXQ/bgI+U4z6HtZmCHNXB1QXrQ==",
"path": "system.text.json/7.0.3",
"hashPath": "system.text.json.7.0.3.nupkg.sha512"
},
"WebDriverManager/2.17.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-loeWTSHpyfWJgLO8+/W7KAh24ClhBTWkpHrnQyd2/KIflvrVzq7tF4OqPR0RIk5qhw8AoIq2xmHGPFjQLvfiBA==",
"path": "webdrivermanager/2.17.1",
"hashPath": "webdrivermanager.2.17.1.nupkg.sha512"
}
}
}

View File

@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
}
}
}

View File

@ -1 +1 @@
1004409487
1937693263

View File

@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("LukanPOM.Tests")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("LukanPOM.Tests")]
[assembly: System.Reflection.AssemblyTitleAttribute("LukanPOM.Tests")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Vygenerované třídou WriteCodeFragment nástroje MSBuild

View File

@ -0,0 +1 @@
0e7e11a237c6d551555e3a9b6e7f56d747c02bf0

View File

@ -0,0 +1,11 @@
is_global = true
build_property.TargetFramework = net6.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = LukanPOM.Tests
build_property.ProjectDir = c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\

View File

@ -0,0 +1 @@
a5f8f4183a1f4675f763c0c67fa33b48cbd6711d

View File

@ -0,0 +1,111 @@
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\testhost.exe
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\testhost.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\NUnit3.TestAdapter.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\NUnit3.TestAdapter.pdb
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\nunit.engine.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\nunit.engine.api.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\nunit.engine.core.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\testcentric.engine.metadata.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\selenium-manager\linux\selenium-manager
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\selenium-manager\macos\selenium-manager
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\selenium-manager\windows\selenium-manager.exe
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\LukanPOM.Tests.deps.json
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\LukanPOM.Tests.runtimeconfig.json
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\LukanPOM.Tests.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\LukanPOM.Tests.pdb
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\AngleSharp.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\SeleniumExtras.PageObjects.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\Microsoft.VisualStudio.CodeCoverage.Shim.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\Microsoft.TestPlatform.CoreUtilities.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\Microsoft.TestPlatform.PlatformAbstractions.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\Microsoft.TestPlatform.CommunicationUtilities.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\Microsoft.TestPlatform.CrossPlatEngine.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\Microsoft.TestPlatform.Utilities.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\Microsoft.VisualStudio.TestPlatform.Common.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\Newtonsoft.Json.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\NuGet.Frameworks.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\nunit.framework.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\WebDriver.Support.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\WebDriver.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ICSharpCode.SharpZipLib.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\System.Text.Encodings.Web.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\System.Text.Json.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\WebDriverManager.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\cs\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\cs\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\de\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\de\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\es\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\es\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\fr\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\fr\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\it\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\it\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ja\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ja\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ko\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ko\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\pl\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\pl\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\pt-BR\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\pt-BR\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ru\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ru\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\tr\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\tr\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\zh-Hans\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\zh-Hans\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\zh-Hant\Microsoft.TestPlatform.CoreUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\zh-Hant\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\cs\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\cs\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\cs\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\de\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\de\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\de\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\es\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\es\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\es\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\fr\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\fr\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\fr\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\it\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\it\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\it\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ja\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ja\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ja\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ko\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ko\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ko\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\pl\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\pl\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\pl\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\pt-BR\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\pt-BR\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\pt-BR\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ru\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ru\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\ru\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\tr\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\tr\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\tr\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\zh-Hans\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\zh-Hans\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\zh-Hans\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\zh-Hant\Microsoft.TestPlatform.CommunicationUtilities.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\zh-Hant\Microsoft.TestPlatform.CrossPlatEngine.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\zh-Hant\Microsoft.VisualStudio.TestPlatform.Common.resources.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\bin\Debug\net6.0\runtimes\browser\lib\net6.0\System.Text.Encodings.Web.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\LukanPOM.Tests.csproj.AssemblyReference.cache
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\LukanPOM.Tests.GeneratedMSBuildEditorConfig.editorconfig
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\LukanPOM.Tests.AssemblyInfoInputs.cache
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\LukanPOM.Tests.AssemblyInfo.cs
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\LukanPOM.Tests.csproj.CoreCompileInputs.cache
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\LukanPOM.Tests.csproj.CopyComplete
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\LukanPOM.Tests.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\refint\LukanPOM.Tests.dll
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\LukanPOM.Tests.pdb
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\LukanPOM.Tests.genruntimeconfig.cache
c:\Users\lukas\Nextcloud\GitHub\.Net_C.Sharp_Test\LukanNUnitProject\LukanPOM\obj\Debug\net6.0\ref\LukanPOM.Tests.dll

View File

@ -0,0 +1 @@
4b21565216d156cccad6d96bae6e4254938ca175

View File

@ -0,0 +1,105 @@
{
"format": 1,
"restore": {
"c:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\LukanPOM.Tests.csproj": {}
},
"projects": {
"c:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\LukanPOM.Tests.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "c:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\LukanPOM.Tests.csproj",
"projectName": "LukanPOM.Tests",
"projectPath": "c:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\LukanPOM.Tests.csproj",
"packagesPath": "C:\\Users\\lukas\\.nuget\\packages\\",
"outputPath": "c:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\lukas\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net6.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"dependencies": {
"DotNetSeleniumExtras.PageObjects.Core": {
"target": "Package",
"version": "[4.3.0, )"
},
"Microsoft.NET.Test.Sdk": {
"target": "Package",
"version": "[17.6.0, )"
},
"NUnit": {
"target": "Package",
"version": "[3.13.3, )"
},
"NUnit.Analyzers": {
"target": "Package",
"version": "[3.6.1, )"
},
"NUnit.ConsoleRunner": {
"target": "Package",
"version": "[3.16.3, )"
},
"NUnit3TestAdapter": {
"target": "Package",
"version": "[4.5.0, )"
},
"Selenium.Support": {
"target": "Package",
"version": "[4.11.0, )"
},
"Selenium.WebDriver": {
"target": "Package",
"version": "[4.11.0, )"
},
"WebDriverManager": {
"target": "Package",
"version": "[2.17.1, )"
},
"coverlet.collector": {
"target": "Package",
"version": "[3.2.0, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.400\\RuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@ -13,13 +13,14 @@
<SourceRoot Include="C:\Users\lukas\.nuget\packages\" />
</ItemGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)nunit3testadapter\4.4.2\build\netcoreapp3.1\NUnit3TestAdapter.props" Condition="Exists('$(NuGetPackageRoot)nunit3testadapter\4.4.2\build\netcoreapp3.1\NUnit3TestAdapter.props')" />
<Import Project="$(NuGetPackageRoot)nunit3testadapter\4.5.0\build\netcoreapp3.1\NUnit3TestAdapter.props" Condition="Exists('$(NuGetPackageRoot)nunit3testadapter\4.5.0\build\netcoreapp3.1\NUnit3TestAdapter.props')" />
<Import Project="$(NuGetPackageRoot)nunit\3.13.3\build\NUnit.props" Condition="Exists('$(NuGetPackageRoot)nunit\3.13.3\build\NUnit.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.testplatform.testhost\17.6.0\build\netcoreapp3.1\Microsoft.TestPlatform.TestHost.props" Condition="Exists('$(NuGetPackageRoot)microsoft.testplatform.testhost\17.6.0\build\netcoreapp3.1\Microsoft.TestPlatform.TestHost.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.codecoverage\17.6.0\build\netstandard2.0\Microsoft.CodeCoverage.props" Condition="Exists('$(NuGetPackageRoot)microsoft.codecoverage\17.6.0\build\netstandard2.0\Microsoft.CodeCoverage.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.net.test.sdk\17.6.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.props" Condition="Exists('$(NuGetPackageRoot)microsoft.net.test.sdk\17.6.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.props')" />
</ImportGroup>
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<PkgNUnit_ConsoleRunner Condition=" '$(PkgNUnit_ConsoleRunner)' == '' ">C:\Users\lukas\.nuget\packages\nunit.consolerunner\3.16.3</PkgNUnit_ConsoleRunner>
<PkgNUnit_Analyzers Condition=" '$(PkgNUnit_Analyzers)' == '' ">C:\Users\lukas\.nuget\packages\nunit.analyzers\3.6.1</PkgNUnit_Analyzers>
</PropertyGroup>
</Project>

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)system.text.json\7.0.0\buildTransitive\net6.0\System.Text.Json.targets" Condition="Exists('$(NuGetPackageRoot)system.text.json\7.0.0\buildTransitive\net6.0\System.Text.Json.targets')" />
<Import Project="$(NuGetPackageRoot)system.text.json\7.0.3\buildTransitive\net6.0\System.Text.Json.targets" Condition="Exists('$(NuGetPackageRoot)system.text.json\7.0.3\buildTransitive\net6.0\System.Text.Json.targets')" />
<Import Project="$(NuGetPackageRoot)selenium.webdriver\4.11.0\buildTransitive\Selenium.WebDriver.targets" Condition="Exists('$(NuGetPackageRoot)selenium.webdriver\4.11.0\buildTransitive\Selenium.WebDriver.targets')" />
<Import Project="$(NuGetPackageRoot)netstandard.library\2.0.0\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('$(NuGetPackageRoot)netstandard.library\2.0.0\build\netstandard2.0\NETStandard.Library.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.playwright\1.37.1\buildTransitive\Microsoft.Playwright.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.playwright\1.37.1\buildTransitive\Microsoft.Playwright.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.codecoverage\17.6.0\build\netstandard2.0\Microsoft.CodeCoverage.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.codecoverage\17.6.0\build\netstandard2.0\Microsoft.CodeCoverage.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.net.test.sdk\17.6.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.net.test.sdk\17.6.0\build\netcoreapp3.1\Microsoft.NET.Test.Sdk.targets')" />
<Import Project="$(NuGetPackageRoot)coverlet.collector\3.2.0\build\netstandard1.0\coverlet.collector.targets" Condition="Exists('$(NuGetPackageRoot)coverlet.collector\3.2.0\build\netstandard1.0\coverlet.collector.targets')" />

View File

@ -1754,11 +1754,11 @@
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\LukanPOM.csproj",
"projectUniqueName": "c:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\LukanPOM.csproj",
"projectName": "LukanPOM",
"projectPath": "C:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\LukanPOM.csproj",
"projectPath": "c:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\LukanPOM.csproj",
"packagesPath": "C:\\Users\\lukas\\.nuget\\packages\\",
"outputPath": "C:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\obj\\",
"outputPath": "c:\\Users\\lukas\\Nextcloud\\GitHub\\.Net_C.Sharp_Test\\LukanNUnitProject\\LukanPOM\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\lukas\\AppData\\Roaming\\NuGet\\NuGet.Config",

View File

@ -1 +0,0 @@
global using NUnit.Framework;

View File

@ -1,21 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="Microsoft.Playwright.NUnit" Version="1.37.1" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>
</Project>

View File

@ -1,15 +0,0 @@
namespace PlaywrightTests;
public class Tests
{
[SetUp]
public void Setup()
{
}
[Test]
public void Test1()
{
Assert.Pass();
}
}

View File

@ -1,4 +0,0 @@
@echo off
setlocal
if not defined PLAYWRIGHT_NODEJS_PATH set PLAYWRIGHT_NODEJS_PATH=%~dp0node.exe
"%PLAYWRIGHT_NODEJS_PATH%" "%~dp0..\..\package\lib\cli\cli.js" %*

View File

@ -1,3 +0,0 @@
# playwright-core
This package contains the no-browser flavor of [Playwright](http://github.com/microsoft/playwright).

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
See building instructions at [`/browser_patches/winldd/README.md`](../../../browser_patches/winldd/README.md)

View File

@ -1,5 +0,0 @@
$osInfo = Get-WmiObject -Class Win32_OperatingSystem
# check if running on Windows Server
if ($osInfo.ProductType -eq 3) {
Install-WindowsFeature Server-Media-Foundation
}

View File

@ -1,40 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
if [[ $(arch) == "aarch64" ]]; then
echo "ERROR: not supported on Linux Arm64"
exit 1
fi
if [[ ! -f "/etc/os-release" ]]; then
echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)"
exit 1
fi
ID=$(bash -c 'source /etc/os-release && echo $ID')
if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then
echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported"
exit 1
fi
# 1. make sure to remove old beta if any.
if dpkg --get-selections | grep -q "^google-chrome-beta[[:space:]]*install$" >/dev/null; then
apt-get remove -y google-chrome-beta
fi
# 2. Update apt lists (needed to install curl and chrome dependencies)
apt-get update
# 3. Install curl to download chrome
if ! command -v curl >/dev/null; then
apt-get install -y curl
fi
# 4. download chrome beta from dl.google.com and install it.
cd /tmp
curl -O https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb
apt-get install -y ./google-chrome-beta_current_amd64.deb
rm -rf ./google-chrome-beta_current_amd64.deb
cd -
google-chrome-beta --version

View File

@ -1,13 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
rm -rf "/Applications/Google Chrome Beta.app"
cd /tmp
curl -o ./googlechromebeta.dmg -k https://dl.google.com/chrome/mac/universal/beta/googlechromebeta.dmg
hdiutil attach -nobrowse -quiet -noautofsck -noautoopen -mountpoint /Volumes/googlechromebeta.dmg ./googlechromebeta.dmg
cp -rf "/Volumes/googlechromebeta.dmg/Google Chrome Beta.app" /Applications
hdiutil detach /Volumes/googlechromebeta.dmg
rm -rf /tmp/googlechromebeta.dmg
/Applications/Google\ Chrome\ Beta.app/Contents/MacOS/Google\ Chrome\ Beta --version

View File

@ -1,25 +0,0 @@
$url = 'https://dl.google.com/tag/s/dl/chrome/install/beta/googlechromebetastandaloneenterprise.msi';
if ([Environment]::Is64BitProcess) {
$url = 'https://dl.google.com/tag/s/dl/chrome/install/beta/googlechromebetastandaloneenterprise64.msi'
}
Write-Host "Downloading Google Chrome Beta"
$wc = New-Object net.webclient
$msiInstaller = "$env:temp\google-chrome-beta.msi"
$wc.Downloadfile($url, $msiInstaller)
Write-Host "Installing Google Chrome Beta"
$arguments = "/i `"$msiInstaller`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
Remove-Item $msiInstaller
$suffix = "\\Google\\Chrome Beta\\Application\\chrome.exe"
if (Test-Path "${env:ProgramFiles(x86)}$suffix") {
(Get-Item "${env:ProgramFiles(x86)}$suffix").VersionInfo
} elseif (Test-Path "${env:ProgramFiles}$suffix") {
(Get-Item "${env:ProgramFiles}$suffix").VersionInfo
} else {
write-host "ERROR: failed to install Google Chrome Beta"
exit 1
}

View File

@ -1,40 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
if [[ $(arch) == "aarch64" ]]; then
echo "ERROR: not supported on Linux Arm64"
exit 1
fi
if [[ ! -f "/etc/os-release" ]]; then
echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)"
exit 1
fi
ID=$(bash -c 'source /etc/os-release && echo $ID')
if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then
echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported"
exit 1
fi
# 1. make sure to remove old stable if any.
if dpkg --get-selections | grep -q "^google-chrome[[:space:]]*install$" >/dev/null; then
apt-get remove -y google-chrome
fi
# 2. Update apt lists (needed to install curl and chrome dependencies)
apt-get update
# 3. Install curl to download chrome
if ! command -v curl >/dev/null; then
apt-get install -y curl
fi
# 4. download chrome stable from dl.google.com and install it.
cd /tmp
curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
apt-get install -y ./google-chrome-stable_current_amd64.deb
rm -rf ./google-chrome-stable_current_amd64.deb
cd -
google-chrome --version

View File

@ -1,12 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
rm -rf "/Applications/Google Chrome.app"
cd /tmp
curl -o ./googlechrome.dmg -k https://dl.google.com/chrome/mac/universal/stable/GGRO/googlechrome.dmg
hdiutil attach -nobrowse -quiet -noautofsck -noautoopen -mountpoint /Volumes/googlechrome.dmg ./googlechrome.dmg
cp -rf "/Volumes/googlechrome.dmg/Google Chrome.app" /Applications
hdiutil detach /Volumes/googlechrome.dmg
rm -rf /tmp/googlechrome.dmg
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version

View File

@ -1,26 +0,0 @@
$url = 'https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise.msi';
if ([Environment]::Is64BitProcess) {
$url = 'https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise64.msi'
}
$wc = New-Object net.webclient
$msiInstaller = "$env:temp\google-chrome.msi"
Write-Host "Downloading Google Chrome"
$wc.Downloadfile($url, $msiInstaller)
Write-Host "Installing Google Chrome"
$arguments = "/i `"$msiInstaller`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
Remove-Item $msiInstaller
$suffix = "\\Google\\Chrome\\Application\\chrome.exe"
if (Test-Path "${env:ProgramFiles(x86)}$suffix") {
(Get-Item "${env:ProgramFiles(x86)}$suffix").VersionInfo
} elseif (Test-Path "${env:ProgramFiles}$suffix") {
(Get-Item "${env:ProgramFiles}$suffix").VersionInfo
} else {
write-host "ERROR: failed to install Google Chrome"
exit 1
}

View File

@ -1,40 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
if [[ $(arch) == "aarch64" ]]; then
echo "ERROR: not supported on Linux Arm64"
exit 1
fi
if [[ ! -f "/etc/os-release" ]]; then
echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)"
exit 1
fi
ID=$(bash -c 'source /etc/os-release && echo $ID')
if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then
echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported"
exit 1
fi
# 1. make sure to remove old beta if any.
if dpkg --get-selections | grep -q "^microsoft-edge-beta[[:space:]]*install$" >/dev/null; then
apt-get remove -y microsoft-edge-beta
fi
# 2. Install curl to download Microsoft gpg key
if ! command -v curl >/dev/null; then
apt-get update
apt-get install -y curl
fi
# 3. Add the GPG key, the apt repo, update the apt cache, and install the package
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/microsoft.gpg
install -o root -g root -m 644 /tmp/microsoft.gpg /etc/apt/trusted.gpg.d/
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
rm /tmp/microsoft.gpg
apt-get update && apt-get install -y microsoft-edge-beta
microsoft-edge-beta --version

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
cd /tmp
curl -o ./msedge_beta.pkg -k "$1"
# Note: there's no way to uninstall previously installed MSEdge.
# However, running PKG again seems to update installation.
sudo installer -pkg /tmp/msedge_beta.pkg -target /
rm -rf /tmp/msedge_beta.pkg
/Applications/Microsoft\ Edge\ Beta.app/Contents/MacOS/Microsoft\ Edge\ Beta --version

View File

@ -1,21 +0,0 @@
$url = $args[0]
Write-Host "Downloading Microsoft Edge Beta"
$wc = New-Object net.webclient
$msiInstaller = "$env:temp\microsoft-edge-beta.msi"
$wc.Downloadfile($url, $msiInstaller)
Write-Host "Installing Microsoft Edge Beta"
$arguments = "/i `"$msiInstaller`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
Remove-Item $msiInstaller
$suffix = "\\Microsoft\\Edge Beta\\Application\\msedge.exe"
if (Test-Path "${env:ProgramFiles(x86)}$suffix") {
(Get-Item "${env:ProgramFiles(x86)}$suffix").VersionInfo
} elseif (Test-Path "${env:ProgramFiles}$suffix") {
(Get-Item "${env:ProgramFiles}$suffix").VersionInfo
} else {
write-host "ERROR: failed to install Microsoft Edge"
exit 1
}

View File

@ -1,40 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
if [[ $(arch) == "aarch64" ]]; then
echo "ERROR: not supported on Linux Arm64"
exit 1
fi
if [[ ! -f "/etc/os-release" ]]; then
echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)"
exit 1
fi
ID=$(bash -c 'source /etc/os-release && echo $ID')
if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then
echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported"
exit 1
fi
# 1. make sure to remove old dev if any.
if dpkg --get-selections | grep -q "^microsoft-edge-dev[[:space:]]*install$" >/dev/null; then
apt-get remove -y microsoft-edge-dev
fi
# 2. Install curl to download Microsoft gpg key
if ! command -v curl >/dev/null; then
apt-get update
apt-get install -y curl
fi
# 3. Add the GPG key, the apt repo, update the apt cache, and install the package
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/microsoft.gpg
install -o root -g root -m 644 /tmp/microsoft.gpg /etc/apt/trusted.gpg.d/
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
rm /tmp/microsoft.gpg
apt-get update && apt-get install -y microsoft-edge-dev
microsoft-edge-dev --version

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
cd /tmp
curl -o ./msedge_dev.pkg -k "$1"
# Note: there's no way to uninstall previously installed MSEdge.
# However, running PKG again seems to update installation.
sudo installer -pkg /tmp/msedge_dev.pkg -target /
rm -rf /tmp/msedge_dev.pkg
/Applications/Microsoft\ Edge\ Dev.app/Contents/MacOS/Microsoft\ Edge\ Dev --version

View File

@ -1,21 +0,0 @@
$url = $args[0]
Write-Host "Downloading Microsoft Edge Dev"
$wc = New-Object net.webclient
$msiInstaller = "$env:temp\microsoft-edge-dev.msi"
$wc.Downloadfile($url, $msiInstaller)
Write-Host "Installing Microsoft Edge Dev"
$arguments = "/i `"$msiInstaller`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
Remove-Item $msiInstaller
$suffix = "\\Microsoft\\Edge Dev\\Application\\msedge.exe"
if (Test-Path "${env:ProgramFiles(x86)}$suffix") {
(Get-Item "${env:ProgramFiles(x86)}$suffix").VersionInfo
} elseif (Test-Path "${env:ProgramFiles}$suffix") {
(Get-Item "${env:ProgramFiles}$suffix").VersionInfo
} else {
write-host "ERROR: failed to install Microsoft Edge"
exit 1
}

View File

@ -1,40 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
if [[ $(arch) == "aarch64" ]]; then
echo "ERROR: not supported on Linux Arm64"
exit 1
fi
if [[ ! -f "/etc/os-release" ]]; then
echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)"
exit 1
fi
ID=$(bash -c 'source /etc/os-release && echo $ID')
if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then
echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported"
exit 1
fi
# 1. make sure to remove old stable if any.
if dpkg --get-selections | grep -q "^microsoft-edge-stable[[:space:]]*install$" >/dev/null; then
apt-get remove -y microsoft-edge-stable
fi
# 2. Install curl to download Microsoft gpg key
if ! command -v curl >/dev/null; then
apt-get update
apt-get install -y curl
fi
# 3. Add the GPG key, the apt repo, update the apt cache, and install the package
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/microsoft.gpg
install -o root -g root -m 644 /tmp/microsoft.gpg /etc/apt/trusted.gpg.d/
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-stable.list'
rm /tmp/microsoft.gpg
apt-get update && apt-get install -y microsoft-edge-stable
microsoft-edge-stable --version

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
cd /tmp
curl -o ./msedge_stable.pkg -k "$1"
# Note: there's no way to uninstall previously installed MSEdge.
# However, running PKG again seems to update installation.
sudo installer -pkg /tmp/msedge_stable.pkg -target /
rm -rf /tmp/msedge_stable.pkg
/Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge --version

View File

@ -1,21 +0,0 @@
$url = $args[0]
Write-Host "Downloading Microsoft Edge"
$wc = New-Object net.webclient
$msiInstaller = "$env:temp\microsoft-edge-stable.msi"
$wc.Downloadfile($url, $msiInstaller)
Write-Host "Installing Microsoft Edge"
$arguments = "/i `"$msiInstaller`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
Remove-Item $msiInstaller
$suffix = "\\Microsoft\\Edge\\Application\\msedge.exe"
if (Test-Path "${env:ProgramFiles(x86)}$suffix") {
(Get-Item "${env:ProgramFiles(x86)}$suffix").VersionInfo
} elseif (Test-Path "${env:ProgramFiles}$suffix") {
(Get-Item "${env:ProgramFiles}$suffix").VersionInfo
} else {
write-host "ERROR: failed to install Microsoft Edge"
exit 1
}

View File

@ -1,64 +0,0 @@
{
"comment": "Do not edit this file, use utils/roll_browser.js",
"browsers": [
{
"name": "chromium",
"revision": "1076",
"installByDefault": true,
"browserVersion": "116.0.5845.82"
},
{
"name": "chromium-with-symbols",
"revision": "1076",
"installByDefault": false,
"browserVersion": "116.0.5845.82"
},
{
"name": "chromium-tip-of-tree",
"revision": "1136",
"installByDefault": false,
"browserVersion": "117.0.5913.0"
},
{
"name": "firefox",
"revision": "1422",
"installByDefault": true,
"browserVersion": "115.0"
},
{
"name": "firefox-asan",
"revision": "1422",
"installByDefault": false,
"browserVersion": "115.0"
},
{
"name": "firefox-beta",
"revision": "1422",
"installByDefault": false,
"browserVersion": "116.0b2"
},
{
"name": "webkit",
"revision": "1883",
"installByDefault": true,
"revisionOverrides": {
"mac10.14": "1446",
"mac10.15": "1616",
"mac11": "1816",
"mac11-arm64": "1816",
"ubuntu18.04": "1728"
},
"browserVersion": "17.0"
},
{
"name": "ffmpeg",
"revision": "1009",
"installByDefault": true
},
{
"name": "android",
"revision": "1000",
"installByDefault": false
}
]
}

View File

@ -1,17 +0,0 @@
#!/usr/bin/env node
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('playwright-core/lib/cli/cli');

View File

@ -1,17 +0,0 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './types/types';

View File

@ -1,33 +0,0 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const minimumMajorNodeVersion = 14;
const currentNodeVersion = process.versions.node;
const semver = currentNodeVersion.split('.');
const [major] = [+semver[0]];
if (major < minimumMajorNodeVersion) {
// eslint-disable-next-line no-console
console.error(
'You are running Node.js ' +
currentNodeVersion +
'.\n' +
`Playwright requires Node.js ${minimumMajorNodeVersion} or higher. \n` +
'Please update your version of Node.js.'
);
process.exit(1);
}
module.exports = require('./lib/inprocess');

View File

@ -1,28 +0,0 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import playwright from './index.js';
export const chromium = playwright.chromium;
export const firefox = playwright.firefox;
export const webkit = playwright.webkit;
export const selectors = playwright.selectors;
export const devices = playwright.devices;
export const errors = playwright.errors;
export const request = playwright.request;
export const _electron = playwright._electron;
export const _android = playwright._android;
export default playwright;

View File

@ -1,69 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AndroidServerLauncherImpl = void 0;
var _utilsBundle = require("./utilsBundle");
var _utils = require("./utils");
var _playwright = require("./server/playwright");
var _playwrightServer = require("./remote/playwrightServer");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the 'License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class AndroidServerLauncherImpl {
async launchServer(options = {}) {
const playwright = (0, _playwright.createPlaywright)({
sdkLanguage: 'javascript',
isServer: true
});
// 1. Pre-connect to the device
let devices = await playwright.android.devices({
host: options.adbHost,
port: options.adbPort,
omitDriverInstall: options.omitDriverInstall
});
if (devices.length === 0) throw new Error('No devices found');
if (options.deviceSerialNumber) {
devices = devices.filter(d => d.serial === options.deviceSerialNumber);
if (devices.length === 0) throw new Error(`No device with serial number '${options.deviceSerialNumber}' not found`);
}
if (devices.length > 1) throw new Error(`More than one device found. Please specify deviceSerialNumber`);
const device = devices[0];
const path = options.wsPath ? options.wsPath.startsWith('/') ? options.wsPath : `/${options.wsPath}` : `/${(0, _utils.createGuid)()}`;
// 2. Start the server
const server = new _playwrightServer.PlaywrightServer({
mode: 'launchServer',
path,
maxConnections: 1,
preLaunchedAndroidDevice: device
});
const wsEndpoint = await server.listen(options.port);
// 3. Return the BrowserServer interface
const browserServer = new _utilsBundle.ws.EventEmitter();
browserServer.wsEndpoint = () => wsEndpoint;
browserServer.close = () => device.close();
browserServer.kill = () => device.close();
device.on('close', () => {
server.close();
browserServer.emit('close');
});
return browserServer;
}
}
exports.AndroidServerLauncherImpl = AndroidServerLauncherImpl;

View File

@ -1,91 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BrowserServerLauncherImpl = void 0;
var _utilsBundle = require("./utilsBundle");
var _clientHelper = require("./client/clientHelper");
var _utils = require("./utils");
var _instrumentation = require("./server/instrumentation");
var _playwright = require("./server/playwright");
var _playwrightServer = require("./remote/playwrightServer");
var _helper = require("./server/helper");
var _stackTrace = require("./utils/stackTrace");
var _socksProxy = require("./common/socksProxy");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the 'License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrowserServerLauncherImpl {
constructor(browserName) {
this._browserName = void 0;
this._browserName = browserName;
}
async launchServer(options = {}) {
const playwright = (0, _playwright.createPlaywright)({
sdkLanguage: 'javascript',
isServer: true
});
// TODO: enable socks proxy once ipv6 is supported.
const socksProxy = false ? new _socksProxy.SocksProxy() : undefined;
playwright.options.socksProxyPort = await (socksProxy === null || socksProxy === void 0 ? void 0 : socksProxy.listen(0));
// 1. Pre-launch the browser
const metadata = (0, _instrumentation.serverSideCallMetadata)();
const browser = await playwright[this._browserName].launch(metadata, {
...options,
ignoreDefaultArgs: Array.isArray(options.ignoreDefaultArgs) ? options.ignoreDefaultArgs : undefined,
ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs),
env: options.env ? (0, _clientHelper.envObjectToArray)(options.env) : undefined
}, toProtocolLogger(options.logger)).catch(e => {
const log = _helper.helper.formatBrowserLogs(metadata.log);
(0, _stackTrace.rewriteErrorMessage)(e, `${e.message} Failed to launch browser.${log}`);
throw e;
});
const path = options.wsPath ? options.wsPath.startsWith('/') ? options.wsPath : `/${options.wsPath}` : `/${(0, _utils.createGuid)()}`;
// 2. Start the server
const server = new _playwrightServer.PlaywrightServer({
mode: 'launchServer',
path,
maxConnections: Infinity,
preLaunchedBrowser: browser,
preLaunchedSocksProxy: socksProxy
});
const wsEndpoint = await server.listen(options.port);
// 3. Return the BrowserServer interface
const browserServer = new _utilsBundle.ws.EventEmitter();
browserServer.process = () => browser.options.browserProcess.process;
browserServer.wsEndpoint = () => wsEndpoint;
browserServer.close = () => browser.options.browserProcess.close();
browserServer.kill = () => browser.options.browserProcess.kill();
browserServer._disconnectForTest = () => server.close();
browserServer._userDataDirForTest = browser._userDataDirForTest;
browser.options.browserProcess.onclose = (exitCode, signal) => {
socksProxy === null || socksProxy === void 0 ? void 0 : socksProxy.close().catch(() => {});
server.close();
browserServer.emit('close', exitCode, signal);
};
return browserServer;
}
}
exports.BrowserServerLauncherImpl = BrowserServerLauncherImpl;
function toProtocolLogger(logger) {
return logger ? (direction, message) => {
if (logger.isEnabled('protocol', 'verbose')) logger.log('protocol', 'verbose', (direction === 'send' ? 'SEND ► ' : '◀ RECV ') + JSON.stringify(message), [], {});
} : undefined;
}

View File

@ -1,65 +0,0 @@
#!/usr/bin/env node
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-console */
"use strict";
var _utils = require("../utils");
var _program = _interopRequireDefault(require("./program"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function printPlaywrightTestError(command) {
const packages = [];
for (const pkg of ['playwright', 'playwright-chromium', 'playwright-firefox', 'playwright-webkit']) {
try {
require.resolve(pkg);
packages.push(pkg);
} catch (e) {}
}
if (!packages.length) packages.push('playwright');
const packageManager = (0, _utils.getPackageManager)();
if (packageManager === 'yarn') {
console.error(`Please install @playwright/test package before running "yarn playwright ${command}"`);
console.error(` yarn remove ${packages.join(' ')}`);
console.error(' yarn add -D @playwright/test');
} else if (packageManager === 'pnpm') {
console.error(`Please install @playwright/test package before running "pnpm exec playwright ${command}"`);
console.error(` pnpm remove ${packages.join(' ')}`);
console.error(' pnpm add -D @playwright/test');
} else {
console.error(`Please install @playwright/test package before running "npx playwright ${command}"`);
console.error(` npm uninstall ${packages.join(' ')}`);
console.error(' npm install -D @playwright/test');
}
}
{
const command = _program.default.command('test').allowUnknownOption(true);
command.description('Run tests with Playwright Test. Available in @playwright/test package.');
command.action(async () => {
printPlaywrightTestError('test');
(0, _utils.gracefullyProcessExitDoNotHang)(1);
});
}
{
const command = _program.default.command('show-report').allowUnknownOption(true);
command.description('Show Playwright Test HTML report. Available in @playwright/test package.');
command.action(async () => {
printPlaywrightTestError('show-report');
(0, _utils.gracefullyProcessExitDoNotHang)(1);
});
}
_program.default.parse(process.argv);

View File

@ -1,88 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.launchBrowserServer = launchBrowserServer;
exports.printApiJson = printApiJson;
exports.runDriver = runDriver;
exports.runServer = runServer;
var _fs = _interopRequireDefault(require("fs"));
var playwright = _interopRequireWildcard(require("../.."));
var _server = require("../server");
var _transport = require("../protocol/transport");
var _playwrightServer = require("../remote/playwrightServer");
var _processLauncher = require("../utils/processLauncher");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the 'License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-console */
function printApiJson() {
// Note: this file is generated by build-playwright-driver.sh
console.log(JSON.stringify(require('../../api.json')));
}
function runDriver() {
const dispatcherConnection = new _server.DispatcherConnection();
new _server.RootDispatcher(dispatcherConnection, async (rootScope, {
sdkLanguage
}) => {
const playwright = (0, _server.createPlaywright)({
sdkLanguage
});
return new _server.PlaywrightDispatcher(rootScope, playwright);
});
const transport = new _transport.PipeTransport(process.stdout, process.stdin);
transport.onmessage = message => dispatcherConnection.dispatch(JSON.parse(message));
dispatcherConnection.onmessage = message => transport.send(JSON.stringify(message));
transport.onclose = () => {
// Drop any messages during shutdown on the floor.
dispatcherConnection.onmessage = () => {};
(0, _processLauncher.gracefullyProcessExitDoNotHang)(0);
};
// Ignore the SIGINT signal in the driver process so the parent can gracefully close the connection.
// We still will destruct everything (close browsers and exit) when the transport pipe closes.
process.on('SIGINT', () => {
// Keep the process running.
});
}
async function runServer(options) {
const {
port,
path = '/',
maxConnections = Infinity,
extension
} = options;
const server = new _playwrightServer.PlaywrightServer({
mode: extension ? 'extension' : 'default',
path,
maxConnections
});
const wsEndpoint = await server.listen(port);
process.on('exit', () => server.close().catch(console.error));
console.log('Listening on ' + wsEndpoint); // eslint-disable-line no-console
process.stdin.on('close', () => (0, _processLauncher.gracefullyProcessExitDoNotHang)(0));
}
async function launchBrowserServer(browserName, configFile) {
let options = {};
if (configFile) options = JSON.parse(_fs.default.readFileSync(configFile).toString());
const browserType = playwright[browserName];
const server = await browserType.launchServer(options);
console.log(server.wsEndpoint());
}

View File

@ -1,569 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _fs = _interopRequireDefault(require("fs"));
var _os = _interopRequireDefault(require("os"));
var _path = _interopRequireDefault(require("path"));
var _utilsBundle = require("../utilsBundle");
var _driver = require("./driver");
var _traceViewer = require("../server/trace/viewer/traceViewer");
var playwright = _interopRequireWildcard(require("../.."));
var _child_process = require("child_process");
var _utils = require("../utils");
var _server = require("../server");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-console */
const packageJSON = require('../../package.json');
_utilsBundle.program.version('Version ' + (process.env.PW_CLI_DISPLAY_VERSION || packageJSON.version)).name(buildBasePlaywrightCLICommand(process.env.PW_LANG_NAME));
_utilsBundle.program.command('mark-docker-image [dockerImageNameTemplate]', {
hidden: true
}).description('mark docker image').allowUnknownOption(true).action(function (dockerImageNameTemplate) {
(0, _utils.assert)(dockerImageNameTemplate, 'dockerImageNameTemplate is required');
(0, _server.writeDockerVersion)(dockerImageNameTemplate).catch(logErrorAndExit);
});
commandWithOpenOptions('open [url]', 'open page in browser specified via -b, --browser', []).action(function (url, options) {
open(options, url, codegenId()).catch(logErrorAndExit);
}).addHelpText('afterAll', `
Examples:
$ open
$ open -b webkit https://example.com`);
commandWithOpenOptions('codegen [url]', 'open page and generate code for user actions', [['-o, --output <file name>', 'saves the generated script to a file'], ['--target <language>', `language to generate, one of javascript, playwright-test, python, python-async, python-pytest, csharp, csharp-mstest, csharp-nunit, java`, codegenId()], ['--save-trace <filename>', 'record a trace for the session and save it to a file'], ['--test-id-attribute <attributeName>', 'use the specified attribute to generate data test ID selectors']]).action(function (url, options) {
codegen(options, url).catch(logErrorAndExit);
}).addHelpText('afterAll', `
Examples:
$ codegen
$ codegen --target=python
$ codegen -b webkit https://example.com`);
_utilsBundle.program.command('debug <app> [args...]', {
hidden: true
}).description('run command in debug mode: disable timeout, open inspector').allowUnknownOption(true).action(function (app, options) {
(0, _child_process.spawn)(app, options, {
env: {
...process.env,
PWDEBUG: '1'
},
stdio: 'inherit'
});
}).addHelpText('afterAll', `
Examples:
$ debug node test.js
$ debug npm run test`);
function suggestedBrowsersToInstall() {
return _server.registry.executables().filter(e => e.installType !== 'none' && e.type !== 'tool').map(e => e.name).join(', ');
}
function checkBrowsersToInstall(args) {
const faultyArguments = [];
const executables = [];
for (const arg of args) {
const executable = _server.registry.findExecutable(arg);
if (!executable || executable.installType === 'none') faultyArguments.push(arg);else executables.push(executable);
}
if (faultyArguments.length) throw new Error(`Invalid installation targets: ${faultyArguments.map(name => `'${name}'`).join(', ')}. Expecting one of: ${suggestedBrowsersToInstall()}`);
return executables;
}
_utilsBundle.program.command('install [browser...]').description('ensure browsers necessary for this version of Playwright are installed').option('--with-deps', 'install system dependencies for browsers').option('--dry-run', 'do not execute installation, only print information').option('--force', 'force reinstall of stable browser channels').action(async function (args, options) {
if ((0, _utils.isLikelyNpxGlobal)()) {
console.error((0, _utils.wrapInASCIIBox)([`WARNING: It looks like you are running 'npx playwright install' without first`, `installing your project's dependencies.`, ``, `To avoid unexpected behavior, please install your dependencies first, and`, `then run Playwright's install command:`, ``, ` npm install`, ` npx playwright install`, ``, `If your project does not yet depend on Playwright, first install the`, `applicable npm package (most commonly @playwright/test), and`, `then run Playwright's install command to download the browsers:`, ``, ` npm install @playwright/test`, ` npx playwright install`, ``].join('\n'), 1));
}
try {
const hasNoArguments = !args.length;
const executables = hasNoArguments ? _server.registry.defaultExecutables() : checkBrowsersToInstall(args);
if (options.withDeps) await _server.registry.installDeps(executables, !!options.dryRun);
if (options.dryRun) {
for (const executable of executables) {
var _executable$directory, _executable$downloadU;
const version = executable.browserVersion ? `version ` + executable.browserVersion : '';
console.log(`browser: ${executable.name}${version ? ' ' + version : ''}`);
console.log(` Install location: ${(_executable$directory = executable.directory) !== null && _executable$directory !== void 0 ? _executable$directory : '<system>'}`);
if ((_executable$downloadU = executable.downloadURLs) !== null && _executable$downloadU !== void 0 && _executable$downloadU.length) {
const [url, ...fallbacks] = executable.downloadURLs;
console.log(` Download url: ${url}`);
for (let i = 0; i < fallbacks.length; ++i) console.log(` Download fallback ${i + 1}: ${fallbacks[i]}`);
}
console.log(``);
}
} else {
const forceReinstall = hasNoArguments ? false : !!options.force;
await _server.registry.install(executables, forceReinstall);
}
} catch (e) {
console.log(`Failed to install browsers\n${e}`);
(0, _utils.gracefullyProcessExitDoNotHang)(1);
}
}).addHelpText('afterAll', `
Examples:
- $ install
Install default browsers.
- $ install chrome firefox
Install custom browsers, supports ${suggestedBrowsersToInstall()}.`);
_utilsBundle.program.command('uninstall').description('Removes browsers used by this installation of Playwright from the system (chromium, firefox, webkit, ffmpeg). This does not include branded channels.').option('--all', 'Removes all browsers used by any Playwright installation from the system.').action(async options => {
await _server.registry.uninstall(!!options.all).then(({
numberOfBrowsersLeft
}) => {
if (!options.all && numberOfBrowsersLeft > 0) {
console.log('Successfully uninstalled Playwright browsers for the current Playwright installation.');
console.log(`There are still ${numberOfBrowsersLeft} browsers left, used by other Playwright installations.\nTo uninstall Playwright browsers for all installations, re-run with --all flag.`);
}
}).catch(logErrorAndExit);
});
_utilsBundle.program.command('install-deps [browser...]').description('install dependencies necessary to run browsers (will ask for sudo permissions)').option('--dry-run', 'Do not execute installation commands, only print them').action(async function (args, options) {
try {
if (!args.length) await _server.registry.installDeps(_server.registry.defaultExecutables(), !!options.dryRun);else await _server.registry.installDeps(checkBrowsersToInstall(args), !!options.dryRun);
} catch (e) {
console.log(`Failed to install browser dependencies\n${e}`);
(0, _utils.gracefullyProcessExitDoNotHang)(1);
}
}).addHelpText('afterAll', `
Examples:
- $ install-deps
Install dependencies for default browsers.
- $ install-deps chrome firefox
Install dependencies for specific browsers, supports ${suggestedBrowsersToInstall()}.`);
const browsers = [{
alias: 'cr',
name: 'Chromium',
type: 'chromium'
}, {
alias: 'ff',
name: 'Firefox',
type: 'firefox'
}, {
alias: 'wk',
name: 'WebKit',
type: 'webkit'
}];
for (const {
alias,
name,
type
} of browsers) {
commandWithOpenOptions(`${alias} [url]`, `open page in ${name}`, []).action(function (url, options) {
open({
...options,
browser: type
}, url, options.target).catch(logErrorAndExit);
}).addHelpText('afterAll', `
Examples:
$ ${alias} https://example.com`);
}
commandWithOpenOptions('screenshot <url> <filename>', 'capture a page screenshot', [['--wait-for-selector <selector>', 'wait for selector before taking a screenshot'], ['--wait-for-timeout <timeout>', 'wait for timeout in milliseconds before taking a screenshot'], ['--full-page', 'whether to take a full page screenshot (entire scrollable area)']]).action(function (url, filename, command) {
screenshot(command, command, url, filename).catch(logErrorAndExit);
}).addHelpText('afterAll', `
Examples:
$ screenshot -b webkit https://example.com example.png`);
commandWithOpenOptions('pdf <url> <filename>', 'save page as pdf', [['--wait-for-selector <selector>', 'wait for given selector before saving as pdf'], ['--wait-for-timeout <timeout>', 'wait for given timeout in milliseconds before saving as pdf']]).action(function (url, filename, options) {
pdf(options, options, url, filename).catch(logErrorAndExit);
}).addHelpText('afterAll', `
Examples:
$ pdf https://example.com example.pdf`);
_utilsBundle.program.command('run-driver', {
hidden: true
}).action(function (options) {
(0, _driver.runDriver)();
});
_utilsBundle.program.command('run-server', {
hidden: true
}).option('--port <port>', 'Server port').option('--path <path>', 'Endpoint Path', '/').option('--max-clients <maxClients>', 'Maximum clients').option('--mode <mode>', 'Server mode, either "default" or "extension"').action(function (options) {
(0, _driver.runServer)({
port: options.port ? +options.port : undefined,
path: options.path,
maxConnections: options.maxClients ? +options.maxClients : Infinity,
extension: options.mode === 'extension' || !!process.env.PW_EXTENSION_MODE
}).catch(logErrorAndExit);
});
_utilsBundle.program.command('print-api-json', {
hidden: true
}).action(function (options) {
(0, _driver.printApiJson)();
});
_utilsBundle.program.command('launch-server', {
hidden: true
}).requiredOption('--browser <browserName>', 'Browser name, one of "chromium", "firefox" or "webkit"').option('--config <path-to-config-file>', 'JSON file with launchServer options').action(function (options) {
(0, _driver.launchBrowserServer)(options.browser, options.config);
});
_utilsBundle.program.command('show-trace [trace...]').option('-b, --browser <browserType>', 'browser to use, one of cr, chromium, ff, firefox, wk, webkit', 'chromium').option('-h, --host <host>', 'Host to serve trace on; specifying this option opens trace in a browser tab').option('-p, --port <port>', 'Port to serve trace on, 0 for any free port; specifying this option opens trace in a browser tab').option('--stdin', 'Accept trace URLs over stdin to update the viewer').description('show trace viewer').action(function (traces, options) {
if (options.browser === 'cr') options.browser = 'chromium';
if (options.browser === 'ff') options.browser = 'firefox';
if (options.browser === 'wk') options.browser = 'webkit';
const openOptions = {
headless: false,
host: options.host,
port: +options.port,
isServer: !!options.stdin
};
if (options.port !== undefined || options.host !== undefined) {
(0, _traceViewer.openTraceInBrowser)(traces, openOptions).catch(logErrorAndExit);
} else {
(0, _traceViewer.openTraceViewerApp)(traces, options.browser, openOptions).then(page => {
page.on('close', () => (0, _utils.gracefullyProcessExitDoNotHang)(0));
}).catch(logErrorAndExit);
}
}).addHelpText('afterAll', `
Examples:
$ show-trace https://example.com/trace.zip`);
async function launchContext(options, headless, executablePath) {
validateOptions(options);
const browserType = lookupBrowserType(options);
const launchOptions = {
headless,
executablePath
};
if (options.channel) launchOptions.channel = options.channel;
launchOptions.handleSIGINT = false;
const contextOptions =
// Copy the device descriptor since we have to compare and modify the options.
options.device ? {
...playwright.devices[options.device]
} : {};
// In headful mode, use host device scale factor for things to look nice.
// In headless, keep things the way it works in Playwright by default.
// Assume high-dpi on MacOS. TODO: this is not perfect.
if (!headless) contextOptions.deviceScaleFactor = _os.default.platform() === 'darwin' ? 2 : 1;
// Work around the WebKit GTK scrolling issue.
if (browserType.name() === 'webkit' && process.platform === 'linux') {
delete contextOptions.hasTouch;
delete contextOptions.isMobile;
}
if (contextOptions.isMobile && browserType.name() === 'firefox') contextOptions.isMobile = undefined;
if (options.blockServiceWorkers) contextOptions.serviceWorkers = 'block';
// Proxy
if (options.proxyServer) {
launchOptions.proxy = {
server: options.proxyServer
};
if (options.proxyBypass) launchOptions.proxy.bypass = options.proxyBypass;
}
const browser = await browserType.launch(launchOptions);
if (process.env.PWTEST_CLI_IS_UNDER_TEST) {
process._didSetSourcesForTest = text => {
process.stdout.write('\n-------------8<-------------\n');
process.stdout.write(text);
process.stdout.write('\n-------------8<-------------\n');
const autoExitCondition = process.env.PWTEST_CLI_AUTO_EXIT_WHEN;
if (autoExitCondition && text.includes(autoExitCondition)) Promise.all(context.pages().map(async p => p.close()));
};
// Make sure we exit abnormally when browser crashes.
const logs = [];
require('playwright-core/lib/utilsBundle').debug.log = (...args) => {
const line = require('util').format(...args) + '\n';
logs.push(line);
process.stderr.write(line);
};
browser.on('disconnected', () => {
const hasCrashLine = logs.some(line => line.includes('process did exit:') && !line.includes('process did exit: exitCode=0, signal=null'));
if (hasCrashLine) {
process.stderr.write('Detected browser crash.\n');
(0, _utils.gracefullyProcessExitDoNotHang)(1);
}
});
}
// Viewport size
if (options.viewportSize) {
try {
const [width, height] = options.viewportSize.split(',').map(n => parseInt(n, 10));
contextOptions.viewport = {
width,
height
};
} catch (e) {
throw new Error('Invalid viewport size format: use "width, height", for example --viewport-size=800,600');
}
}
// Geolocation
if (options.geolocation) {
try {
const [latitude, longitude] = options.geolocation.split(',').map(n => parseFloat(n.trim()));
contextOptions.geolocation = {
latitude,
longitude
};
} catch (e) {
throw new Error('Invalid geolocation format, should be "lat,long". For example --geolocation="37.819722,-122.478611"');
}
contextOptions.permissions = ['geolocation'];
}
// User agent
if (options.userAgent) contextOptions.userAgent = options.userAgent;
// Lang
if (options.lang) contextOptions.locale = options.lang;
// Color scheme
if (options.colorScheme) contextOptions.colorScheme = options.colorScheme;
// Timezone
if (options.timezone) contextOptions.timezoneId = options.timezone;
// Storage
if (options.loadStorage) contextOptions.storageState = options.loadStorage;
if (options.ignoreHttpsErrors) contextOptions.ignoreHTTPSErrors = true;
// HAR
if (options.saveHar) {
contextOptions.recordHar = {
path: _path.default.resolve(process.cwd(), options.saveHar),
mode: 'minimal'
};
if (options.saveHarGlob) contextOptions.recordHar.urlFilter = options.saveHarGlob;
contextOptions.serviceWorkers = 'block';
}
// Close app when the last window closes.
const context = await browser.newContext(contextOptions);
let closingBrowser = false;
async function closeBrowser() {
// We can come here multiple times. For example, saving storage creates
// a temporary page and we call closeBrowser again when that page closes.
if (closingBrowser) return;
closingBrowser = true;
if (options.saveTrace) await context.tracing.stop({
path: options.saveTrace
});
if (options.saveStorage) await context.storageState({
path: options.saveStorage
}).catch(e => null);
if (options.saveHar) await context.close();
await browser.close();
}
context.on('page', page => {
page.on('dialog', () => {}); // Prevent dialogs from being automatically dismissed.
page.on('close', () => {
const hasPage = browser.contexts().some(context => context.pages().length > 0);
if (hasPage) return;
// Avoid the error when the last page is closed because the browser has been closed.
closeBrowser().catch(e => null);
});
});
process.on('SIGINT', async () => {
await closeBrowser();
(0, _utils.gracefullyProcessExitDoNotHang)(130);
});
const timeout = options.timeout ? parseInt(options.timeout, 10) : 0;
context.setDefaultTimeout(timeout);
context.setDefaultNavigationTimeout(timeout);
if (options.saveTrace) await context.tracing.start({
screenshots: true,
snapshots: true
});
// Omit options that we add automatically for presentation purpose.
delete launchOptions.headless;
delete launchOptions.executablePath;
delete launchOptions.handleSIGINT;
delete contextOptions.deviceScaleFactor;
return {
browser,
browserName: browserType.name(),
context,
contextOptions,
launchOptions
};
}
async function openPage(context, url) {
const page = await context.newPage();
if (url) {
if (_fs.default.existsSync(url)) url = 'file://' + _path.default.resolve(url);else if (!url.startsWith('http') && !url.startsWith('file://') && !url.startsWith('about:') && !url.startsWith('data:')) url = 'http://' + url;
await page.goto(url).catch(error => {
if (process.env.PWTEST_CLI_AUTO_EXIT_WHEN && error.message.includes('Navigation failed because page was closed')) {
// Tests with PWTEST_CLI_AUTO_EXIT_WHEN might close page too fast, resulting
// in a stray navigation aborted error. We should ignore it.
} else {
throw error;
}
});
}
return page;
}
async function open(options, url, language) {
const {
context,
launchOptions,
contextOptions
} = await launchContext(options, !!process.env.PWTEST_CLI_HEADLESS, process.env.PWTEST_CLI_EXECUTABLE_PATH);
await context._enableRecorder({
language,
launchOptions,
contextOptions,
device: options.device,
saveStorage: options.saveStorage
});
await openPage(context, url);
}
async function codegen(options, url) {
const {
target: language,
output: outputFile,
testIdAttribute: testIdAttributeName
} = options;
const {
context,
launchOptions,
contextOptions
} = await launchContext(options, !!process.env.PWTEST_CLI_HEADLESS, process.env.PWTEST_CLI_EXECUTABLE_PATH);
await context._enableRecorder({
language,
launchOptions,
contextOptions,
device: options.device,
saveStorage: options.saveStorage,
mode: 'recording',
testIdAttributeName,
outputFile: outputFile ? _path.default.resolve(outputFile) : undefined,
handleSIGINT: false
});
await openPage(context, url);
}
async function waitForPage(page, captureOptions) {
if (captureOptions.waitForSelector) {
console.log(`Waiting for selector ${captureOptions.waitForSelector}...`);
await page.waitForSelector(captureOptions.waitForSelector);
}
if (captureOptions.waitForTimeout) {
console.log(`Waiting for timeout ${captureOptions.waitForTimeout}...`);
await page.waitForTimeout(parseInt(captureOptions.waitForTimeout, 10));
}
}
async function screenshot(options, captureOptions, url, path) {
const {
context
} = await launchContext(options, true);
console.log('Navigating to ' + url);
const page = await openPage(context, url);
await waitForPage(page, captureOptions);
console.log('Capturing screenshot into ' + path);
await page.screenshot({
path,
fullPage: !!captureOptions.fullPage
});
// launchContext takes care of closing the browser.
await page.close();
}
async function pdf(options, captureOptions, url, path) {
if (options.browser !== 'chromium') throw new Error('PDF creation is only working with Chromium');
const {
context
} = await launchContext({
...options,
browser: 'chromium'
}, true);
console.log('Navigating to ' + url);
const page = await openPage(context, url);
await waitForPage(page, captureOptions);
console.log('Saving as pdf into ' + path);
await page.pdf({
path
});
// launchContext takes care of closing the browser.
await page.close();
}
function lookupBrowserType(options) {
let name = options.browser;
if (options.device) {
const device = playwright.devices[options.device];
name = device.defaultBrowserType;
}
let browserType;
switch (name) {
case 'chromium':
browserType = playwright.chromium;
break;
case 'webkit':
browserType = playwright.webkit;
break;
case 'firefox':
browserType = playwright.firefox;
break;
case 'cr':
browserType = playwright.chromium;
break;
case 'wk':
browserType = playwright.webkit;
break;
case 'ff':
browserType = playwright.firefox;
break;
}
if (browserType) return browserType;
_utilsBundle.program.help();
}
function validateOptions(options) {
if (options.device && !(options.device in playwright.devices)) {
const lines = [`Device descriptor not found: '${options.device}', available devices are:`];
for (const name in playwright.devices) lines.push(` "${name}"`);
throw new Error(lines.join('\n'));
}
if (options.colorScheme && !['light', 'dark'].includes(options.colorScheme)) throw new Error('Invalid color scheme, should be one of "light", "dark"');
}
function logErrorAndExit(e) {
if (process.env.PWDEBUGIMPL) console.error(e);else console.error(e.name + ': ' + e.message);
(0, _utils.gracefullyProcessExitDoNotHang)(1);
}
function codegenId() {
return process.env.PW_LANG_NAME || 'playwright-test';
}
function commandWithOpenOptions(command, description, options) {
let result = _utilsBundle.program.command(command).description(description);
for (const option of options) result = result.option(option[0], ...option.slice(1));
return result.option('-b, --browser <browserType>', 'browser to use, one of cr, chromium, ff, firefox, wk, webkit', 'chromium').option('--block-service-workers', 'block service workers').option('--channel <channel>', 'Chromium distribution channel, "chrome", "chrome-beta", "msedge-dev", etc').option('--color-scheme <scheme>', 'emulate preferred color scheme, "light" or "dark"').option('--device <deviceName>', 'emulate device, for example "iPhone 11"').option('--geolocation <coordinates>', 'specify geolocation coordinates, for example "37.819722,-122.478611"').option('--ignore-https-errors', 'ignore https errors').option('--load-storage <filename>', 'load context storage state from the file, previously saved with --save-storage').option('--lang <language>', 'specify language / locale, for example "en-GB"').option('--proxy-server <proxy>', 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"').option('--proxy-bypass <bypass>', 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option('--save-har <filename>', 'save HAR file with all network activity at the end').option('--save-har-glob <glob pattern>', 'filter entries in the HAR by matching url against this glob pattern').option('--save-storage <filename>', 'save context storage state at the end, for later use with --load-storage').option('--timezone <time zone>', 'time zone to emulate, for example "Europe/Rome"').option('--timeout <timeout>', 'timeout for Playwright actions in milliseconds, no timeout by default').option('--user-agent <ua string>', 'specify user agent string').option('--viewport-size <size>', 'specify browser viewport size in pixels, for example "1280, 720"');
}
function buildBasePlaywrightCLICommand(cliTargetLang) {
switch (cliTargetLang) {
case 'python':
return `playwright`;
case 'java':
return `mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="...options.."`;
case 'csharp':
return `pwsh bin/Debug/netX/playwright.ps1`;
default:
return `npx playwright`;
}
}
var _default = _utilsBundle.program;
exports.default = _default;

View File

@ -1,50 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Accessibility = void 0;
/**
* Copyright 2017 Google Inc. All rights reserved.
* Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function axNodeFromProtocol(axNode) {
const result = {
...axNode,
value: axNode.valueNumber !== undefined ? axNode.valueNumber : axNode.valueString,
checked: axNode.checked === 'checked' ? true : axNode.checked === 'unchecked' ? false : axNode.checked,
pressed: axNode.pressed === 'pressed' ? true : axNode.pressed === 'released' ? false : axNode.pressed,
children: axNode.children ? axNode.children.map(axNodeFromProtocol) : undefined
};
delete result.valueNumber;
delete result.valueString;
return result;
}
class Accessibility {
constructor(channel) {
this._channel = void 0;
this._channel = channel;
}
async snapshot(options = {}) {
const root = options.root ? options.root._elementChannel : undefined;
const result = await this._channel.accessibilitySnapshot({
interestingOnly: options.interestingOnly,
root
});
return result.rootAXNode ? axNodeFromProtocol(result.rootAXNode) : null;
}
}
exports.Accessibility = Accessibility;

View File

@ -1,466 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AndroidWebView = exports.AndroidSocket = exports.AndroidInput = exports.AndroidDevice = exports.Android = void 0;
var _fs = _interopRequireDefault(require("fs"));
var _utils = require("../utils");
var _events = require("./events");
var _browserContext = require("./browserContext");
var _channelOwner = require("./channelOwner");
var _timeoutSettings = require("../common/timeoutSettings");
var _waiter = require("./waiter");
var _events2 = require("events");
var _connection = require("./connection");
var _errors = require("../common/errors");
var _timeoutRunner = require("../utils/timeoutRunner");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Android extends _channelOwner.ChannelOwner {
static from(android) {
return android._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._timeoutSettings = void 0;
this._serverLauncher = void 0;
this._timeoutSettings = new _timeoutSettings.TimeoutSettings();
}
setDefaultTimeout(timeout) {
this._timeoutSettings.setDefaultTimeout(timeout);
this._channel.setDefaultTimeoutNoReply({
timeout
});
}
async devices(options = {}) {
const {
devices
} = await this._channel.devices(options);
return devices.map(d => AndroidDevice.from(d));
}
async launchServer(options = {}) {
if (!this._serverLauncher) throw new Error('Launching server is not supported');
return this._serverLauncher.launchServer(options);
}
async connect(wsEndpoint, options = {}) {
return await this._wrapApiCall(async () => {
const deadline = options.timeout ? (0, _utils.monotonicTime)() + options.timeout : 0;
const headers = {
'x-playwright-browser': 'android',
...options.headers
};
const localUtils = this._connection.localUtils();
const connectParams = {
wsEndpoint,
headers,
slowMo: options.slowMo,
timeout: options.timeout
};
const {
pipe
} = await localUtils._channel.connect(connectParams);
const closePipe = () => pipe.close().catch(() => {});
const connection = new _connection.Connection(localUtils, this._instrumentation);
connection.markAsRemote();
connection.on('close', closePipe);
let device;
let closeError;
const onPipeClosed = () => {
var _device;
(_device = device) === null || _device === void 0 ? void 0 : _device._didClose();
connection.close(closeError || _errors.kBrowserClosedError);
};
pipe.on('closed', onPipeClosed);
connection.onmessage = message => pipe.send({
message
}).catch(onPipeClosed);
pipe.on('message', ({
message
}) => {
try {
connection.dispatch(message);
} catch (e) {
closeError = e.toString();
closePipe();
}
});
const result = await (0, _timeoutRunner.raceAgainstDeadline)(async () => {
const playwright = await connection.initializePlaywright();
if (!playwright._initializer.preConnectedAndroidDevice) {
closePipe();
throw new Error('Malformed endpoint. Did you use Android.launchServer method?');
}
device = AndroidDevice.from(playwright._initializer.preConnectedAndroidDevice);
device._shouldCloseConnectionOnClose = true;
device.on(_events.Events.AndroidDevice.Close, closePipe);
return device;
}, deadline);
if (!result.timedOut) {
return result.result;
} else {
closePipe();
throw new Error(`Timeout ${options.timeout}ms exceeded`);
}
});
}
}
exports.Android = Android;
class AndroidDevice extends _channelOwner.ChannelOwner {
static from(androidDevice) {
return androidDevice._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._timeoutSettings = void 0;
this._webViews = new Map();
this._shouldCloseConnectionOnClose = false;
this.input = void 0;
this.input = new AndroidInput(this);
this._timeoutSettings = new _timeoutSettings.TimeoutSettings(parent._timeoutSettings);
this._channel.on('webViewAdded', ({
webView
}) => this._onWebViewAdded(webView));
this._channel.on('webViewRemoved', ({
socketName
}) => this._onWebViewRemoved(socketName));
this._channel.on('close', () => this._didClose());
}
_onWebViewAdded(webView) {
const view = new AndroidWebView(this, webView);
this._webViews.set(webView.socketName, view);
this.emit(_events.Events.AndroidDevice.WebView, view);
}
_onWebViewRemoved(socketName) {
const view = this._webViews.get(socketName);
this._webViews.delete(socketName);
if (view) view.emit(_events.Events.AndroidWebView.Close);
}
setDefaultTimeout(timeout) {
this._timeoutSettings.setDefaultTimeout(timeout);
this._channel.setDefaultTimeoutNoReply({
timeout
});
}
serial() {
return this._initializer.serial;
}
model() {
return this._initializer.model;
}
webViews() {
return [...this._webViews.values()];
}
async webView(selector, options) {
const predicate = v => {
if (selector.pkg) return v.pkg() === selector.pkg;
if (selector.socketName) return v._socketName() === selector.socketName;
return false;
};
const webView = [...this._webViews.values()].find(predicate);
if (webView) return webView;
return this.waitForEvent('webview', {
...options,
predicate
});
}
async wait(selector, options) {
await this._channel.wait({
selector: toSelectorChannel(selector),
...options
});
}
async fill(selector, text, options) {
await this._channel.fill({
selector: toSelectorChannel(selector),
text,
...options
});
}
async press(selector, key, options) {
await this.tap(selector, options);
await this.input.press(key);
}
async tap(selector, options) {
await this._channel.tap({
selector: toSelectorChannel(selector),
...options
});
}
async drag(selector, dest, options) {
await this._channel.drag({
selector: toSelectorChannel(selector),
dest,
...options
});
}
async fling(selector, direction, options) {
await this._channel.fling({
selector: toSelectorChannel(selector),
direction,
...options
});
}
async longTap(selector, options) {
await this._channel.longTap({
selector: toSelectorChannel(selector),
...options
});
}
async pinchClose(selector, percent, options) {
await this._channel.pinchClose({
selector: toSelectorChannel(selector),
percent,
...options
});
}
async pinchOpen(selector, percent, options) {
await this._channel.pinchOpen({
selector: toSelectorChannel(selector),
percent,
...options
});
}
async scroll(selector, direction, percent, options) {
await this._channel.scroll({
selector: toSelectorChannel(selector),
direction,
percent,
...options
});
}
async swipe(selector, direction, percent, options) {
await this._channel.swipe({
selector: toSelectorChannel(selector),
direction,
percent,
...options
});
}
async info(selector) {
return (await this._channel.info({
selector: toSelectorChannel(selector)
})).info;
}
async screenshot(options = {}) {
const {
binary
} = await this._channel.screenshot();
if (options.path) await _fs.default.promises.writeFile(options.path, binary);
return binary;
}
async close() {
try {
if (this._shouldCloseConnectionOnClose) this._connection.close(_errors.kBrowserClosedError);else await this._channel.close();
} catch (e) {
if ((0, _errors.isSafeCloseError)(e)) return;
throw e;
}
}
_didClose() {
this.emit(_events.Events.AndroidDevice.Close, this);
}
async shell(command) {
const {
result
} = await this._channel.shell({
command
});
return result;
}
async open(command) {
return AndroidSocket.from((await this._channel.open({
command
})).socket);
}
async installApk(file, options) {
await this._channel.installApk({
file: await loadFile(file),
args: options && options.args
});
}
async push(file, path, options) {
await this._channel.push({
file: await loadFile(file),
path,
mode: options ? options.mode : undefined
});
}
async launchBrowser(options = {}) {
const contextOptions = await (0, _browserContext.prepareBrowserContextParams)(options);
const {
context
} = await this._channel.launchBrowser(contextOptions);
return _browserContext.BrowserContext.from(context);
}
async waitForEvent(event, optionsOrPredicate = {}) {
return this._wrapApiCall(async () => {
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
const waiter = _waiter.Waiter.createForEvent(this, event);
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
if (event !== _events.Events.AndroidDevice.Close) waiter.rejectOnEvent(this, _events.Events.AndroidDevice.Close, new Error('Device closed'));
const result = await waiter.waitForEvent(this, event, predicate);
waiter.dispose();
return result;
});
}
}
exports.AndroidDevice = AndroidDevice;
class AndroidSocket extends _channelOwner.ChannelOwner {
static from(androidDevice) {
return androidDevice._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._channel.on('data', ({
data
}) => this.emit(_events.Events.AndroidSocket.Data, data));
this._channel.on('close', () => this.emit(_events.Events.AndroidSocket.Close));
}
async write(data) {
await this._channel.write({
data
});
}
async close() {
await this._channel.close();
}
}
exports.AndroidSocket = AndroidSocket;
async function loadFile(file) {
if ((0, _utils.isString)(file)) return _fs.default.promises.readFile(file);
return file;
}
class AndroidInput {
constructor(device) {
this._device = void 0;
this._device = device;
}
async type(text) {
await this._device._channel.inputType({
text
});
}
async press(key) {
await this._device._channel.inputPress({
key
});
}
async tap(point) {
await this._device._channel.inputTap({
point
});
}
async swipe(from, segments, steps) {
await this._device._channel.inputSwipe({
segments,
steps
});
}
async drag(from, to, steps) {
await this._device._channel.inputDrag({
from,
to,
steps
});
}
}
exports.AndroidInput = AndroidInput;
function toSelectorChannel(selector) {
const {
checkable,
checked,
clazz,
clickable,
depth,
desc,
enabled,
focusable,
focused,
hasChild,
hasDescendant,
longClickable,
pkg,
res,
scrollable,
selected,
text
} = selector;
const toRegex = value => {
if (value === undefined) return undefined;
if ((0, _utils.isRegExp)(value)) return value.source;
return '^' + value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d') + '$';
};
return {
checkable,
checked,
clazz: toRegex(clazz),
pkg: toRegex(pkg),
desc: toRegex(desc),
res: toRegex(res),
text: toRegex(text),
clickable,
depth,
enabled,
focusable,
focused,
hasChild: hasChild ? {
selector: toSelectorChannel(hasChild.selector)
} : undefined,
hasDescendant: hasDescendant ? {
selector: toSelectorChannel(hasDescendant.selector),
maxDepth: hasDescendant.maxDepth
} : undefined,
longClickable,
scrollable,
selected
};
}
class AndroidWebView extends _events2.EventEmitter {
constructor(device, data) {
super();
this._device = void 0;
this._data = void 0;
this._pagePromise = void 0;
this._device = device;
this._data = data;
}
pid() {
return this._data.pid;
}
pkg() {
return this._data.pkg;
}
_socketName() {
return this._data.socketName;
}
async page() {
if (!this._pagePromise) this._pagePromise = this._fetchPage();
return this._pagePromise;
}
async _fetchPage() {
const {
context
} = await this._device._channel.connectToWebView({
socketName: this._data.socketName
});
return _browserContext.BrowserContext.from(context).pages()[0];
}
}
exports.AndroidWebView = AndroidWebView;

View File

@ -1,265 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "APIRequest", {
enumerable: true,
get: function () {
return _fetch.APIRequest;
}
});
Object.defineProperty(exports, "APIRequestContext", {
enumerable: true,
get: function () {
return _fetch.APIRequestContext;
}
});
Object.defineProperty(exports, "APIResponse", {
enumerable: true,
get: function () {
return _fetch.APIResponse;
}
});
Object.defineProperty(exports, "Accessibility", {
enumerable: true,
get: function () {
return _accessibility.Accessibility;
}
});
Object.defineProperty(exports, "Android", {
enumerable: true,
get: function () {
return _android.Android;
}
});
Object.defineProperty(exports, "AndroidDevice", {
enumerable: true,
get: function () {
return _android.AndroidDevice;
}
});
Object.defineProperty(exports, "AndroidInput", {
enumerable: true,
get: function () {
return _android.AndroidInput;
}
});
Object.defineProperty(exports, "AndroidSocket", {
enumerable: true,
get: function () {
return _android.AndroidSocket;
}
});
Object.defineProperty(exports, "AndroidWebView", {
enumerable: true,
get: function () {
return _android.AndroidWebView;
}
});
Object.defineProperty(exports, "Browser", {
enumerable: true,
get: function () {
return _browser.Browser;
}
});
Object.defineProperty(exports, "BrowserContext", {
enumerable: true,
get: function () {
return _browserContext.BrowserContext;
}
});
Object.defineProperty(exports, "BrowserType", {
enumerable: true,
get: function () {
return _browserType.BrowserType;
}
});
Object.defineProperty(exports, "CDPSession", {
enumerable: true,
get: function () {
return _cdpSession.CDPSession;
}
});
Object.defineProperty(exports, "ConsoleMessage", {
enumerable: true,
get: function () {
return _consoleMessage.ConsoleMessage;
}
});
Object.defineProperty(exports, "Coverage", {
enumerable: true,
get: function () {
return _coverage.Coverage;
}
});
Object.defineProperty(exports, "Dialog", {
enumerable: true,
get: function () {
return _dialog.Dialog;
}
});
Object.defineProperty(exports, "Download", {
enumerable: true,
get: function () {
return _download.Download;
}
});
Object.defineProperty(exports, "Electron", {
enumerable: true,
get: function () {
return _electron.Electron;
}
});
Object.defineProperty(exports, "ElectronApplication", {
enumerable: true,
get: function () {
return _electron.ElectronApplication;
}
});
Object.defineProperty(exports, "ElementHandle", {
enumerable: true,
get: function () {
return _elementHandle.ElementHandle;
}
});
Object.defineProperty(exports, "FileChooser", {
enumerable: true,
get: function () {
return _fileChooser.FileChooser;
}
});
Object.defineProperty(exports, "Frame", {
enumerable: true,
get: function () {
return _frame.Frame;
}
});
Object.defineProperty(exports, "FrameLocator", {
enumerable: true,
get: function () {
return _locator.FrameLocator;
}
});
Object.defineProperty(exports, "JSHandle", {
enumerable: true,
get: function () {
return _jsHandle.JSHandle;
}
});
Object.defineProperty(exports, "Keyboard", {
enumerable: true,
get: function () {
return _input.Keyboard;
}
});
Object.defineProperty(exports, "Locator", {
enumerable: true,
get: function () {
return _locator.Locator;
}
});
Object.defineProperty(exports, "Mouse", {
enumerable: true,
get: function () {
return _input.Mouse;
}
});
Object.defineProperty(exports, "Page", {
enumerable: true,
get: function () {
return _page.Page;
}
});
Object.defineProperty(exports, "Playwright", {
enumerable: true,
get: function () {
return _playwright.Playwright;
}
});
Object.defineProperty(exports, "Request", {
enumerable: true,
get: function () {
return _network.Request;
}
});
Object.defineProperty(exports, "Response", {
enumerable: true,
get: function () {
return _network.Response;
}
});
Object.defineProperty(exports, "Route", {
enumerable: true,
get: function () {
return _network.Route;
}
});
Object.defineProperty(exports, "Selectors", {
enumerable: true,
get: function () {
return _selectors.Selectors;
}
});
Object.defineProperty(exports, "TimeoutError", {
enumerable: true,
get: function () {
return _errors.TimeoutError;
}
});
Object.defineProperty(exports, "Touchscreen", {
enumerable: true,
get: function () {
return _input.Touchscreen;
}
});
Object.defineProperty(exports, "Tracing", {
enumerable: true,
get: function () {
return _tracing.Tracing;
}
});
Object.defineProperty(exports, "Video", {
enumerable: true,
get: function () {
return _video.Video;
}
});
Object.defineProperty(exports, "WebSocket", {
enumerable: true,
get: function () {
return _network.WebSocket;
}
});
Object.defineProperty(exports, "Worker", {
enumerable: true,
get: function () {
return _worker.Worker;
}
});
var _accessibility = require("./accessibility");
var _android = require("./android");
var _browser = require("./browser");
var _browserContext = require("./browserContext");
var _browserType = require("./browserType");
var _consoleMessage = require("./consoleMessage");
var _coverage = require("./coverage");
var _dialog = require("./dialog");
var _download = require("./download");
var _electron = require("./electron");
var _locator = require("./locator");
var _elementHandle = require("./elementHandle");
var _fileChooser = require("./fileChooser");
var _errors = require("../common/errors");
var _frame = require("./frame");
var _input = require("./input");
var _jsHandle = require("./jsHandle");
var _network = require("./network");
var _fetch = require("./fetch");
var _page = require("./page");
var _selectors = require("./selectors");
var _tracing = require("./tracing");
var _video = require("./video");
var _worker = require("./worker");
var _cdpSession = require("./cdpSession");
var _playwright = require("./playwright");

View File

@ -1,80 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Artifact = void 0;
var fs = _interopRequireWildcard(require("fs"));
var _stream = require("./stream");
var _fileUtils = require("../utils/fileUtils");
var _channelOwner = require("./channelOwner");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Artifact extends _channelOwner.ChannelOwner {
static from(channel) {
return channel._object;
}
async pathAfterFinished() {
if (this._connection.isRemote()) throw new Error(`Path is not available when connecting remotely. Use saveAs() to save a local copy.`);
return (await this._channel.pathAfterFinished()).value || null;
}
async saveAs(path) {
if (!this._connection.isRemote()) {
await this._channel.saveAs({
path
});
return;
}
const result = await this._channel.saveAsStream();
const stream = _stream.Stream.from(result.stream);
await (0, _fileUtils.mkdirIfNeeded)(path);
await new Promise((resolve, reject) => {
stream.stream().pipe(fs.createWriteStream(path)).on('finish', resolve).on('error', reject);
});
}
async failure() {
return (await this._channel.failure()).error || null;
}
async createReadStream() {
const result = await this._channel.stream();
if (!result.stream) return null;
const stream = _stream.Stream.from(result.stream);
return stream.stream();
}
async readIntoBuffer() {
const stream = await this.createReadStream();
return new Promise((resolve, reject) => {
const chunks = [];
stream.on('data', chunk => {
chunks.push(chunk);
});
stream.on('end', () => {
resolve(Buffer.concat(chunks));
});
stream.on('error', reject);
});
}
async cancel() {
return this._channel.cancel();
}
async delete() {
return this._channel.delete();
}
}
exports.Artifact = Artifact;

View File

@ -1,133 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Browser = void 0;
var _fs = _interopRequireDefault(require("fs"));
var _browserContext = require("./browserContext");
var _channelOwner = require("./channelOwner");
var _events = require("./events");
var _errors = require("../common/errors");
var _cdpSession = require("./cdpSession");
var _artifact = require("./artifact");
var _utils = require("../utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Browser extends _channelOwner.ChannelOwner {
// Used from @playwright/test fixtures.
static from(browser) {
return browser._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._contexts = new Set();
this._isConnected = true;
this._closedPromise = void 0;
this._shouldCloseConnectionOnClose = false;
this._browserType = void 0;
this._options = {};
this._name = void 0;
this._path = void 0;
this._connectHeaders = void 0;
this._name = initializer.name;
this._channel.on('close', () => this._didClose());
this._closedPromise = new Promise(f => this.once(_events.Events.Browser.Disconnected, f));
}
browserType() {
return this._browserType;
}
async newContext(options = {}) {
return await this._innerNewContext(options, false);
}
async _newContextForReuse(options = {}) {
return await this._wrapApiCall(async () => {
for (const context of this._contexts) {
await this._browserType._willCloseContext(context);
for (const page of context.pages()) page._onClose();
context._onClose();
}
return await this._innerNewContext(options, true);
}, true);
}
async _innerNewContext(options = {}, forReuse) {
options = {
...this._browserType._defaultContextOptions,
...options
};
const contextOptions = await (0, _browserContext.prepareBrowserContextParams)(options);
const response = forReuse ? await this._channel.newContextForReuse(contextOptions) : await this._channel.newContext(contextOptions);
const context = _browserContext.BrowserContext.from(response.context);
await this._browserType._didCreateContext(context, contextOptions, this._options, options.logger || this._logger);
return context;
}
contexts() {
return [...this._contexts];
}
version() {
return this._initializer.version;
}
async newPage(options = {}) {
return await this._wrapApiCall(async () => {
const context = await this.newContext(options);
const page = await context.newPage();
page._ownedContext = context;
context._ownerPage = page;
return page;
});
}
isConnected() {
return this._isConnected;
}
async newBrowserCDPSession() {
return _cdpSession.CDPSession.from((await this._channel.newBrowserCDPSession()).session);
}
async startTracing(page, options = {}) {
this._path = options.path;
await this._channel.startTracing({
...options,
page: page ? page._channel : undefined
});
}
async stopTracing() {
const artifact = _artifact.Artifact.from((await this._channel.stopTracing()).artifact);
const buffer = await artifact.readIntoBuffer();
await artifact.delete();
if (this._path) {
await (0, _utils.mkdirIfNeeded)(this._path);
await _fs.default.promises.writeFile(this._path, buffer);
this._path = undefined;
}
return buffer;
}
async close() {
try {
if (this._shouldCloseConnectionOnClose) this._connection.close(_errors.kBrowserClosedError);else await this._channel.close();
await this._closedPromise;
} catch (e) {
if ((0, _errors.isSafeCloseError)(e)) return;
throw e;
}
}
_didClose() {
this._isConnected = false;
this.emit(_events.Events.Browser.Disconnected, this);
}
}
exports.Browser = Browser;

View File

@ -1,452 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BrowserContext = void 0;
exports.prepareBrowserContextParams = prepareBrowserContextParams;
var _page = require("./page");
var _frame = require("./frame");
var network = _interopRequireWildcard(require("./network"));
var _fs = _interopRequireDefault(require("fs"));
var _channelOwner = require("./channelOwner");
var _clientHelper = require("./clientHelper");
var _browser = require("./browser");
var _worker = require("./worker");
var _events = require("./events");
var _timeoutSettings = require("../common/timeoutSettings");
var _waiter = require("./waiter");
var _utils = require("../utils");
var _fileUtils = require("../utils/fileUtils");
var _cdpSession = require("./cdpSession");
var _tracing = require("./tracing");
var _artifact = require("./artifact");
var _fetch = require("./fetch");
var _stackTrace = require("../utils/stackTrace");
var _harRouter = require("./harRouter");
var _consoleMessage = require("./consoleMessage");
var _dialog = require("./dialog");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
* Copyright 2017 Google Inc. All rights reserved.
* Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrowserContext extends _channelOwner.ChannelOwner {
static from(context) {
return context._object;
}
static fromNullable(context) {
return context ? BrowserContext.from(context) : null;
}
constructor(parent, type, guid, initializer) {
var _this$_browser, _this$_browser2;
super(parent, type, guid, initializer);
this._pages = new Set();
this._routes = [];
this._browser = null;
this._browserType = void 0;
this._bindings = new Map();
this._timeoutSettings = new _timeoutSettings.TimeoutSettings();
this._ownerPage = void 0;
this._closedPromise = void 0;
this._options = {};
this.request = void 0;
this.tracing = void 0;
this._backgroundPages = new Set();
this._serviceWorkers = new Set();
this._isChromium = void 0;
this._harRecorders = new Map();
this._closeWasCalled = false;
if (parent instanceof _browser.Browser) this._browser = parent;
(_this$_browser = this._browser) === null || _this$_browser === void 0 ? void 0 : _this$_browser._contexts.add(this);
this._isChromium = ((_this$_browser2 = this._browser) === null || _this$_browser2 === void 0 ? void 0 : _this$_browser2._name) === 'chromium';
this.tracing = _tracing.Tracing.from(initializer.tracing);
this.request = _fetch.APIRequestContext.from(initializer.requestContext);
this._channel.on('bindingCall', ({
binding
}) => this._onBinding(_page.BindingCall.from(binding)));
this._channel.on('close', () => this._onClose());
this._channel.on('page', ({
page
}) => this._onPage(_page.Page.from(page)));
this._channel.on('route', ({
route
}) => this._onRoute(network.Route.from(route)));
this._channel.on('backgroundPage', ({
page
}) => {
const backgroundPage = _page.Page.from(page);
this._backgroundPages.add(backgroundPage);
this.emit(_events.Events.BrowserContext.BackgroundPage, backgroundPage);
});
this._channel.on('serviceWorker', ({
worker
}) => {
const serviceWorker = _worker.Worker.from(worker);
serviceWorker._context = this;
this._serviceWorkers.add(serviceWorker);
this.emit(_events.Events.BrowserContext.ServiceWorker, serviceWorker);
});
this._channel.on('console', ({
message
}) => {
const consoleMessage = _consoleMessage.ConsoleMessage.from(message);
this.emit(_events.Events.BrowserContext.Console, consoleMessage);
const page = consoleMessage.page();
if (page) page.emit(_events.Events.Page.Console, consoleMessage);
});
this._channel.on('dialog', ({
dialog
}) => {
const dialogObject = _dialog.Dialog.from(dialog);
let hasListeners = this.emit(_events.Events.BrowserContext.Dialog, dialogObject);
const page = dialogObject.page();
if (page) hasListeners = page.emit(_events.Events.Page.Dialog, dialogObject) || hasListeners;
if (!hasListeners) {
// Although we do similar handling on the server side, we still need this logic
// on the client side due to a possible race condition between two async calls:
// a) removing "dialog" listener subscription (client->server)
// b) actual "dialog" event (server->client)
if (dialogObject.type() === 'beforeunload') dialog.accept({}).catch(() => {});else dialog.dismiss().catch(() => {});
}
});
this._channel.on('request', ({
request,
page
}) => this._onRequest(network.Request.from(request), _page.Page.fromNullable(page)));
this._channel.on('requestFailed', ({
request,
failureText,
responseEndTiming,
page
}) => this._onRequestFailed(network.Request.from(request), responseEndTiming, failureText, _page.Page.fromNullable(page)));
this._channel.on('requestFinished', params => this._onRequestFinished(params));
this._channel.on('response', ({
response,
page
}) => this._onResponse(network.Response.from(response), _page.Page.fromNullable(page)));
this._closedPromise = new Promise(f => this.once(_events.Events.BrowserContext.Close, f));
this._setEventToSubscriptionMapping(new Map([[_events.Events.BrowserContext.Console, 'console'], [_events.Events.BrowserContext.Dialog, 'dialog'], [_events.Events.BrowserContext.Request, 'request'], [_events.Events.BrowserContext.Response, 'response'], [_events.Events.BrowserContext.RequestFinished, 'requestFinished'], [_events.Events.BrowserContext.RequestFailed, 'requestFailed']]));
}
_setOptions(contextOptions, browserOptions) {
this._options = contextOptions;
if (this._options.recordHar) this._harRecorders.set('', {
path: this._options.recordHar.path,
content: this._options.recordHar.content
});
this.tracing._tracesDir = browserOptions.tracesDir;
}
_onPage(page) {
this._pages.add(page);
this.emit(_events.Events.BrowserContext.Page, page);
if (page._opener && !page._opener.isClosed()) page._opener.emit(_events.Events.Page.Popup, page);
}
_onRequest(request, page) {
this.emit(_events.Events.BrowserContext.Request, request);
if (page) page.emit(_events.Events.Page.Request, request);
}
_onResponse(response, page) {
this.emit(_events.Events.BrowserContext.Response, response);
if (page) page.emit(_events.Events.Page.Response, response);
}
_onRequestFailed(request, responseEndTiming, failureText, page) {
request._failureText = failureText || null;
request._setResponseEndTiming(responseEndTiming);
this.emit(_events.Events.BrowserContext.RequestFailed, request);
if (page) page.emit(_events.Events.Page.RequestFailed, request);
}
_onRequestFinished(params) {
const {
responseEndTiming
} = params;
const request = network.Request.from(params.request);
const response = network.Response.fromNullable(params.response);
const page = _page.Page.fromNullable(params.page);
request._setResponseEndTiming(responseEndTiming);
this.emit(_events.Events.BrowserContext.RequestFinished, request);
if (page) page.emit(_events.Events.Page.RequestFinished, request);
if (response) response._finishedPromise.resolve(null);
}
async _onRoute(route) {
const routeHandlers = this._routes.slice();
for (const routeHandler of routeHandlers) {
if (!routeHandler.matches(route.request().url())) continue;
if (routeHandler.willExpire()) this._routes.splice(this._routes.indexOf(routeHandler), 1);
const handled = await routeHandler.handle(route);
if (!this._routes.length) this._wrapApiCall(() => this._updateInterceptionPatterns(), true).catch(() => {});
if (handled) return;
}
await route._innerContinue(true);
}
async _onBinding(bindingCall) {
const func = this._bindings.get(bindingCall._initializer.name);
if (!func) return;
await bindingCall.call(func);
}
setDefaultNavigationTimeout(timeout) {
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
this._wrapApiCall(async () => {
this._channel.setDefaultNavigationTimeoutNoReply({
timeout
}).catch(() => {});
}, true);
}
setDefaultTimeout(timeout) {
this._timeoutSettings.setDefaultTimeout(timeout);
this._wrapApiCall(async () => {
this._channel.setDefaultTimeoutNoReply({
timeout
}).catch(() => {});
}, true);
}
browser() {
return this._browser;
}
pages() {
return [...this._pages];
}
async newPage() {
if (this._ownerPage) throw new Error('Please use browser.newContext()');
return _page.Page.from((await this._channel.newPage()).page);
}
async cookies(urls) {
if (!urls) urls = [];
if (urls && typeof urls === 'string') urls = [urls];
return (await this._channel.cookies({
urls: urls
})).cookies;
}
async addCookies(cookies) {
await this._channel.addCookies({
cookies
});
}
async clearCookies() {
await this._channel.clearCookies();
}
async grantPermissions(permissions, options) {
await this._channel.grantPermissions({
permissions,
...options
});
}
async clearPermissions() {
await this._channel.clearPermissions();
}
async setGeolocation(geolocation) {
await this._channel.setGeolocation({
geolocation: geolocation || undefined
});
}
async setExtraHTTPHeaders(headers) {
network.validateHeaders(headers);
await this._channel.setExtraHTTPHeaders({
headers: (0, _utils.headersObjectToArray)(headers)
});
}
async setOffline(offline) {
await this._channel.setOffline({
offline
});
}
async setHTTPCredentials(httpCredentials) {
await this._channel.setHTTPCredentials({
httpCredentials: httpCredentials || undefined
});
}
async addInitScript(script, arg) {
const source = await (0, _clientHelper.evaluationScript)(script, arg);
await this._channel.addInitScript({
source
});
}
async exposeBinding(name, callback, options = {}) {
await this._channel.exposeBinding({
name,
needsHandle: options.handle
});
this._bindings.set(name, callback);
}
async exposeFunction(name, callback) {
await this._channel.exposeBinding({
name
});
const binding = (source, ...args) => callback(...args);
this._bindings.set(name, binding);
}
async route(url, handler, options = {}) {
this._routes.unshift(new network.RouteHandler(this._options.baseURL, url, handler, options.times));
await this._updateInterceptionPatterns();
}
async _recordIntoHAR(har, page, options = {}) {
var _options$updateConten, _options$updateMode, _options$updateConten2;
const {
harId
} = await this._channel.harStart({
page: page === null || page === void 0 ? void 0 : page._channel,
options: prepareRecordHarOptions({
path: har,
content: (_options$updateConten = options.updateContent) !== null && _options$updateConten !== void 0 ? _options$updateConten : 'attach',
mode: (_options$updateMode = options.updateMode) !== null && _options$updateMode !== void 0 ? _options$updateMode : 'minimal',
urlFilter: options.url
})
});
this._harRecorders.set(harId, {
path: har,
content: (_options$updateConten2 = options.updateContent) !== null && _options$updateConten2 !== void 0 ? _options$updateConten2 : 'attach'
});
}
async routeFromHAR(har, options = {}) {
if (options.update) {
await this._recordIntoHAR(har, null, options);
return;
}
const harRouter = await _harRouter.HarRouter.create(this._connection.localUtils(), har, options.notFound || 'abort', {
urlMatch: options.url
});
harRouter.addContextRoute(this);
}
async unroute(url, handler) {
this._routes = this._routes.filter(route => !(0, _utils.urlMatchesEqual)(route.url, url) || handler && route.handler !== handler);
await this._updateInterceptionPatterns();
}
async _updateInterceptionPatterns() {
const patterns = network.RouteHandler.prepareInterceptionPatterns(this._routes);
await this._channel.setNetworkInterceptionPatterns({
patterns
});
}
async waitForEvent(event, optionsOrPredicate = {}) {
return this._wrapApiCall(async () => {
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
const waiter = _waiter.Waiter.createForEvent(this, event);
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
if (event !== _events.Events.BrowserContext.Close) waiter.rejectOnEvent(this, _events.Events.BrowserContext.Close, new Error('Context closed'));
const result = await waiter.waitForEvent(this, event, predicate);
waiter.dispose();
return result;
});
}
async storageState(options = {}) {
const state = await this._channel.storageState();
if (options.path) {
await (0, _fileUtils.mkdirIfNeeded)(options.path);
await _fs.default.promises.writeFile(options.path, JSON.stringify(state, undefined, 2), 'utf8');
}
return state;
}
backgroundPages() {
return [...this._backgroundPages];
}
serviceWorkers() {
return [...this._serviceWorkers];
}
async newCDPSession(page) {
// channelOwner.ts's validation messages don't handle the pseudo-union type, so we're explicit here
if (!(page instanceof _page.Page) && !(page instanceof _frame.Frame)) throw new Error('page: expected Page or Frame');
const result = await this._channel.newCDPSession(page instanceof _page.Page ? {
page: page._channel
} : {
frame: page._channel
});
return _cdpSession.CDPSession.from(result.session);
}
_onClose() {
var _this$_browserType, _this$_browserType$_c;
if (this._browser) this._browser._contexts.delete(this);
(_this$_browserType = this._browserType) === null || _this$_browserType === void 0 ? void 0 : (_this$_browserType$_c = _this$_browserType._contexts) === null || _this$_browserType$_c === void 0 ? void 0 : _this$_browserType$_c.delete(this);
this.emit(_events.Events.BrowserContext.Close, this);
}
async close() {
if (this._closeWasCalled) return;
this._closeWasCalled = true;
await this._wrapApiCall(async () => {
var _this$_browserType2;
await ((_this$_browserType2 = this._browserType) === null || _this$_browserType2 === void 0 ? void 0 : _this$_browserType2._willCloseContext(this));
for (const [harId, harParams] of this._harRecorders) {
const har = await this._channel.harExport({
harId
});
const artifact = _artifact.Artifact.from(har.artifact);
// Server side will compress artifact if content is attach or if file is .zip.
const isCompressed = harParams.content === 'attach' || harParams.path.endsWith('.zip');
const needCompressed = harParams.path.endsWith('.zip');
if (isCompressed && !needCompressed) {
await artifact.saveAs(harParams.path + '.tmp');
await this._connection.localUtils()._channel.harUnzip({
zipFile: harParams.path + '.tmp',
harFile: harParams.path
});
} else {
await artifact.saveAs(harParams.path);
}
await artifact.delete();
}
}, true);
await this._channel.close();
await this._closedPromise;
}
async _enableRecorder(params) {
await this._channel.recorderSupplementEnable(params);
}
}
exports.BrowserContext = BrowserContext;
async function prepareStorageState(options) {
if (typeof options.storageState !== 'string') return options.storageState;
try {
return JSON.parse(await _fs.default.promises.readFile(options.storageState, 'utf8'));
} catch (e) {
(0, _stackTrace.rewriteErrorMessage)(e, `Error reading storage state from ${options.storageState}:\n` + e.message);
throw e;
}
}
function prepareRecordHarOptions(options) {
if (!options) return;
return {
path: options.path,
content: options.content || (options.omitContent ? 'omit' : undefined),
urlGlob: (0, _utils.isString)(options.urlFilter) ? options.urlFilter : undefined,
urlRegexSource: (0, _utils.isRegExp)(options.urlFilter) ? options.urlFilter.source : undefined,
urlRegexFlags: (0, _utils.isRegExp)(options.urlFilter) ? options.urlFilter.flags : undefined,
mode: options.mode
};
}
async function prepareBrowserContextParams(options) {
if (options.videoSize && !options.videosPath) throw new Error(`"videoSize" option requires "videosPath" to be specified`);
if (options.extraHTTPHeaders) network.validateHeaders(options.extraHTTPHeaders);
const contextParams = {
...options,
viewport: options.viewport === null ? undefined : options.viewport,
noDefaultViewport: options.viewport === null,
extraHTTPHeaders: options.extraHTTPHeaders ? (0, _utils.headersObjectToArray)(options.extraHTTPHeaders) : undefined,
storageState: await prepareStorageState(options),
serviceWorkers: options.serviceWorkers,
recordHar: prepareRecordHarOptions(options.recordHar),
colorScheme: options.colorScheme === null ? 'no-override' : options.colorScheme,
reducedMotion: options.reducedMotion === null ? 'no-override' : options.reducedMotion,
forcedColors: options.forcedColors === null ? 'no-override' : options.forcedColors
};
if (!contextParams.recordVideo && options.videosPath) {
contextParams.recordVideo = {
dir: options.videosPath,
size: options.videoSize
};
}
return contextParams;
}

View File

@ -1,254 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BrowserType = void 0;
var _browser3 = require("./browser");
var _browserContext = require("./browserContext");
var _channelOwner = require("./channelOwner");
var _connection = require("./connection");
var _events = require("./events");
var _clientHelper = require("./clientHelper");
var _utils = require("../utils");
var _errors = require("../common/errors");
var _timeoutRunner = require("../utils/timeoutRunner");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This is here just for api generation and checking.
class BrowserType extends _channelOwner.ChannelOwner {
constructor(...args) {
super(...args);
this._serverLauncher = void 0;
this._contexts = new Set();
this._playwright = void 0;
// Instrumentation.
this._defaultContextOptions = void 0;
this._defaultContextTimeout = void 0;
this._defaultContextNavigationTimeout = void 0;
this._defaultLaunchOptions = void 0;
this._defaultConnectOptions = void 0;
}
static from(browserType) {
return browserType._object;
}
executablePath() {
if (!this._initializer.executablePath) throw new Error('Browser is not supported on current platform');
return this._initializer.executablePath;
}
name() {
return this._initializer.name;
}
async launch(options = {}) {
var _this$_defaultLaunchO;
(0, _utils.assert)(!options.userDataDir, 'userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistentContext` instead');
(0, _utils.assert)(!options.port, 'Cannot specify a port without launching as a server.');
if (this._defaultConnectOptions) return await this._connectInsteadOfLaunching(this._defaultConnectOptions, options);
const logger = options.logger || ((_this$_defaultLaunchO = this._defaultLaunchOptions) === null || _this$_defaultLaunchO === void 0 ? void 0 : _this$_defaultLaunchO.logger);
options = {
...this._defaultLaunchOptions,
...options
};
const launchOptions = {
...options,
ignoreDefaultArgs: Array.isArray(options.ignoreDefaultArgs) ? options.ignoreDefaultArgs : undefined,
ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs),
env: options.env ? (0, _clientHelper.envObjectToArray)(options.env) : undefined
};
return await this._wrapApiCall(async () => {
const browser = _browser3.Browser.from((await this._channel.launch(launchOptions)).browser);
this._didLaunchBrowser(browser, options, logger);
return browser;
});
}
async _connectInsteadOfLaunching(connectOptions, launchOptions) {
var _connectOptions$expos, _connectOptions$timeo;
return this._connect({
wsEndpoint: connectOptions.wsEndpoint,
headers: {
// HTTP headers are ASCII only (not UTF-8).
'x-playwright-launch-options': (0, _utils.jsonStringifyForceASCII)({
...this._defaultLaunchOptions,
...launchOptions
}),
...connectOptions.headers
},
exposeNetwork: (_connectOptions$expos = connectOptions.exposeNetwork) !== null && _connectOptions$expos !== void 0 ? _connectOptions$expos : connectOptions._exposeNetwork,
slowMo: connectOptions.slowMo,
timeout: (_connectOptions$timeo = connectOptions.timeout) !== null && _connectOptions$timeo !== void 0 ? _connectOptions$timeo : 3 * 60 * 1000 // 3 minutes
});
}
async launchServer(options = {}) {
if (!this._serverLauncher) throw new Error('Launching server is not supported');
options = {
...this._defaultLaunchOptions,
...options
};
return this._serverLauncher.launchServer(options);
}
async launchPersistentContext(userDataDir, options = {}) {
var _this$_defaultLaunchO2;
const logger = options.logger || ((_this$_defaultLaunchO2 = this._defaultLaunchOptions) === null || _this$_defaultLaunchO2 === void 0 ? void 0 : _this$_defaultLaunchO2.logger);
(0, _utils.assert)(!options.port, 'Cannot specify a port without launching as a server.');
options = {
...this._defaultLaunchOptions,
...this._defaultContextOptions,
...options
};
const contextParams = await (0, _browserContext.prepareBrowserContextParams)(options);
const persistentParams = {
...contextParams,
ignoreDefaultArgs: Array.isArray(options.ignoreDefaultArgs) ? options.ignoreDefaultArgs : undefined,
ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs),
env: options.env ? (0, _clientHelper.envObjectToArray)(options.env) : undefined,
channel: options.channel,
userDataDir
};
return await this._wrapApiCall(async () => {
const result = await this._channel.launchPersistentContext(persistentParams);
const context = _browserContext.BrowserContext.from(result.context);
await this._didCreateContext(context, contextParams, options, logger);
return context;
});
}
async connect(optionsOrWsEndpoint, options) {
if (typeof optionsOrWsEndpoint === 'string') return this._connect({
...options,
wsEndpoint: optionsOrWsEndpoint
});
(0, _utils.assert)(optionsOrWsEndpoint.wsEndpoint, 'options.wsEndpoint is required');
return this._connect(optionsOrWsEndpoint);
}
async _connect(params) {
const logger = params.logger;
return await this._wrapApiCall(async () => {
var _params$exposeNetwork;
const deadline = params.timeout ? (0, _utils.monotonicTime)() + params.timeout : 0;
const headers = {
'x-playwright-browser': this.name(),
...params.headers
};
const localUtils = this._connection.localUtils();
const connectParams = {
wsEndpoint: params.wsEndpoint,
headers,
exposeNetwork: (_params$exposeNetwork = params.exposeNetwork) !== null && _params$exposeNetwork !== void 0 ? _params$exposeNetwork : params._exposeNetwork,
slowMo: params.slowMo,
timeout: params.timeout
};
if (params.__testHookRedirectPortForwarding) connectParams.socksProxyRedirectPortForTest = params.__testHookRedirectPortForwarding;
const {
pipe,
headers: connectHeaders
} = await localUtils._channel.connect(connectParams);
const closePipe = () => pipe.close().catch(() => {});
const connection = new _connection.Connection(localUtils, this._instrumentation);
connection.markAsRemote();
connection.on('close', closePipe);
let browser;
let closeError;
const onPipeClosed = () => {
var _browser2;
// Emulate all pages, contexts and the browser closing upon disconnect.
for (const context of ((_browser = browser) === null || _browser === void 0 ? void 0 : _browser.contexts()) || []) {
var _browser;
for (const page of context.pages()) page._onClose();
context._onClose();
}
(_browser2 = browser) === null || _browser2 === void 0 ? void 0 : _browser2._didClose();
connection.close(closeError || _errors.kBrowserClosedError);
};
pipe.on('closed', onPipeClosed);
connection.onmessage = message => pipe.send({
message
}).catch(onPipeClosed);
pipe.on('message', ({
message
}) => {
try {
connection.dispatch(message);
} catch (e) {
closeError = e.toString();
closePipe();
}
});
const result = await (0, _timeoutRunner.raceAgainstDeadline)(async () => {
// For tests.
if (params.__testHookBeforeCreateBrowser) await params.__testHookBeforeCreateBrowser();
const playwright = await connection.initializePlaywright();
if (!playwright._initializer.preLaunchedBrowser) {
closePipe();
throw new Error('Malformed endpoint. Did you use BrowserType.launchServer method?');
}
playwright._setSelectors(this._playwright.selectors);
browser = _browser3.Browser.from(playwright._initializer.preLaunchedBrowser);
this._didLaunchBrowser(browser, {}, logger);
browser._shouldCloseConnectionOnClose = true;
browser._connectHeaders = connectHeaders;
browser.on(_events.Events.Browser.Disconnected, closePipe);
return browser;
}, deadline);
if (!result.timedOut) {
return result.result;
} else {
closePipe();
throw new Error(`Timeout ${params.timeout}ms exceeded`);
}
});
}
connectOverCDP(endpointURLOrOptions, options) {
if (typeof endpointURLOrOptions === 'string') return this._connectOverCDP(endpointURLOrOptions, options);
const endpointURL = 'endpointURL' in endpointURLOrOptions ? endpointURLOrOptions.endpointURL : endpointURLOrOptions.wsEndpoint;
(0, _utils.assert)(endpointURL, 'Cannot connect over CDP without wsEndpoint.');
return this.connectOverCDP(endpointURL, endpointURLOrOptions);
}
async _connectOverCDP(endpointURL, params = {}) {
if (this.name() !== 'chromium') throw new Error('Connecting over CDP is only supported in Chromium.');
const headers = params.headers ? (0, _utils.headersObjectToArray)(params.headers) : undefined;
const result = await this._channel.connectOverCDP({
endpointURL,
headers,
slowMo: params.slowMo,
timeout: params.timeout
});
const browser = _browser3.Browser.from(result.browser);
this._didLaunchBrowser(browser, {}, params.logger);
if (result.defaultContext) await this._didCreateContext(_browserContext.BrowserContext.from(result.defaultContext), {}, {}, undefined);
return browser;
}
_didLaunchBrowser(browser, browserOptions, logger) {
browser._browserType = this;
browser._options = browserOptions;
browser._logger = logger;
}
async _didCreateContext(context, contextOptions, browserOptions, logger) {
context._logger = logger;
context._browserType = this;
this._contexts.add(context);
context._setOptions(contextOptions, browserOptions);
if (this._defaultContextTimeout !== undefined) context.setDefaultTimeout(this._defaultContextTimeout);
if (this._defaultContextNavigationTimeout !== undefined) context.setDefaultNavigationTimeout(this._defaultContextNavigationTimeout);
await this._instrumentation.onDidCreateBrowserContext(context);
}
async _willCloseContext(context) {
this._contexts.delete(context);
await this._instrumentation.onWillCloseBrowserContext(context);
}
}
exports.BrowserType = BrowserType;

View File

@ -1,53 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CDPSession = void 0;
var _channelOwner = require("./channelOwner");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class CDPSession extends _channelOwner.ChannelOwner {
static from(cdpSession) {
return cdpSession._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._channel.on('event', ({
method,
params
}) => {
this.emit(method, params);
});
this.on = super.on;
this.addListener = super.addListener;
this.off = super.removeListener;
this.removeListener = super.removeListener;
this.once = super.once;
}
async send(method, params) {
const result = await this._channel.send({
method,
params
});
return result.result;
}
async detach() {
return this._channel.detach();
}
}
exports.CDPSession = CDPSession;

View File

@ -1,223 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ChannelOwner = void 0;
var _events = require("events");
var _validator = require("../protocol/validator");
var _debugLogger = require("../common/debugLogger");
var _stackTrace = require("../utils/stackTrace");
var _utils = require("../utils");
var _zones = require("../utils/zones");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the 'License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class ChannelOwner extends _events.EventEmitter {
constructor(parent, type, guid, initializer) {
super();
this._connection = void 0;
this._parent = void 0;
this._objects = new Map();
this._type = void 0;
this._guid = void 0;
this._channel = void 0;
this._initializer = void 0;
this._logger = void 0;
this._instrumentation = void 0;
this._eventToSubscriptionMapping = new Map();
this.setMaxListeners(0);
this._connection = parent instanceof ChannelOwner ? parent._connection : parent;
this._type = type;
this._guid = guid;
this._parent = parent instanceof ChannelOwner ? parent : undefined;
this._instrumentation = this._connection._instrumentation;
this._connection._objects.set(guid, this);
if (this._parent) {
this._parent._objects.set(guid, this);
this._logger = this._parent._logger;
}
this._channel = this._createChannel(new _events.EventEmitter());
this._initializer = initializer;
}
_setEventToSubscriptionMapping(mapping) {
this._eventToSubscriptionMapping = mapping;
}
_updateSubscription(event, enabled) {
const protocolEvent = this._eventToSubscriptionMapping.get(String(event));
if (protocolEvent) {
this._wrapApiCall(async () => {
await this._channel.updateSubscription({
event: protocolEvent,
enabled
});
}, true).catch(() => {});
}
}
on(event, listener) {
if (!this.listenerCount(event)) this._updateSubscription(event, true);
super.on(event, listener);
return this;
}
addListener(event, listener) {
if (!this.listenerCount(event)) this._updateSubscription(event, true);
super.addListener(event, listener);
return this;
}
prependListener(event, listener) {
if (!this.listenerCount(event)) this._updateSubscription(event, true);
super.prependListener(event, listener);
return this;
}
off(event, listener) {
super.off(event, listener);
if (!this.listenerCount(event)) this._updateSubscription(event, false);
return this;
}
removeListener(event, listener) {
super.removeListener(event, listener);
if (!this.listenerCount(event)) this._updateSubscription(event, false);
return this;
}
_adopt(child) {
child._parent._objects.delete(child._guid);
this._objects.set(child._guid, child);
child._parent = this;
}
_dispose() {
// Clean up from parent and connection.
if (this._parent) this._parent._objects.delete(this._guid);
this._connection._objects.delete(this._guid);
// Dispose all children.
for (const object of [...this._objects.values()]) object._dispose();
this._objects.clear();
}
_debugScopeState() {
return {
_guid: this._guid,
objects: Array.from(this._objects.values()).map(o => o._debugScopeState())
};
}
_createChannel(base) {
const channel = new Proxy(base, {
get: (obj, prop) => {
if (typeof prop === 'string') {
const validator = (0, _validator.maybeFindValidator)(this._type, prop, 'Params');
if (validator) {
return params => {
return this._wrapApiCall(apiZone => {
const {
stackTrace,
csi,
callCookie,
wallTime
} = apiZone.reported ? {
csi: undefined,
callCookie: undefined,
stackTrace: null,
wallTime: undefined
} : apiZone;
apiZone.reported = true;
if (csi && stackTrace && stackTrace.apiName) csi.onApiCallBegin(stackTrace.apiName, params, stackTrace, wallTime, callCookie);
return this._connection.sendMessageToServer(this, this._type, prop, validator(params, '', {
tChannelImpl: tChannelImplToWire,
binary: this._connection.isRemote() ? 'toBase64' : 'buffer'
}), stackTrace, wallTime);
});
};
}
}
return obj[prop];
}
});
channel._object = this;
return channel;
}
async _wrapApiCall(func, isInternal = false) {
const logger = this._logger;
const stack = (0, _stackTrace.captureRawStack)();
const apiZone = _zones.zones.zoneData('apiZone', stack);
if (apiZone) return func(apiZone);
const stackTrace = (0, _stackTrace.captureLibraryStackTrace)(stack);
isInternal = isInternal || this._type === 'LocalUtils';
if (isInternal) delete stackTrace.apiName;
// Enclosing zone could have provided the apiName and wallTime.
const expectZone = _zones.zones.zoneData('expectZone', stack);
const wallTime = expectZone ? expectZone.wallTime : Date.now();
if (!isInternal && expectZone) stackTrace.apiName = expectZone.title;
const csi = isInternal ? undefined : this._instrumentation;
const callCookie = {};
const {
apiName,
frameTexts
} = stackTrace;
try {
logApiCall(logger, `=> ${apiName} started`, isInternal);
const apiZone = {
stackTrace,
isInternal,
reported: false,
csi,
callCookie,
wallTime
};
const result = await _zones.zones.run('apiZone', apiZone, async () => {
return await func(apiZone);
});
csi === null || csi === void 0 ? void 0 : csi.onApiCallEnd(callCookie);
logApiCall(logger, `<= ${apiName} succeeded`, isInternal);
return result;
} catch (e) {
const innerError = (process.env.PWDEBUGIMPL || (0, _utils.isUnderTest)()) && e.stack ? '\n<inner error>\n' + e.stack : '';
if (apiName && !apiName.includes('<anonymous>')) e.message = apiName + ': ' + e.message;
const stackFrames = '\n' + frameTexts.join('\n') + innerError;
if (stackFrames.trim()) e.stack = e.message + stackFrames;else e.stack = '';
csi === null || csi === void 0 ? void 0 : csi.onApiCallEnd(callCookie, e);
logApiCall(logger, `<= ${apiName} failed`, isInternal);
throw e;
}
}
_toImpl() {
var _this$_connection$toI, _this$_connection;
return (_this$_connection$toI = (_this$_connection = this._connection).toImpl) === null || _this$_connection$toI === void 0 ? void 0 : _this$_connection$toI.call(_this$_connection, this);
}
toJSON() {
// Jest's expect library tries to print objects sometimes.
// RPC objects can contain links to lots of other objects,
// which can cause jest to crash. Let's help it out
// by just returning the important values.
return {
_type: this._type,
_guid: this._guid
};
}
}
exports.ChannelOwner = ChannelOwner;
function logApiCall(logger, message, isNested) {
if (isNested) return;
if (logger && logger.isEnabled('api', 'info')) logger.log('api', 'info', message, [], {
color: 'cyan'
});
_debugLogger.debugLogger.log('api', message);
}
function tChannelImplToWire(names, arg, path, context) {
if (arg._object instanceof ChannelOwner && (names === '*' || names.includes(arg._object._type))) return {
guid: arg._object._guid
};
throw new _validator.ValidationError(`${path}: expected channel ${names.toString()}`);
}

View File

@ -1,53 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.envObjectToArray = envObjectToArray;
exports.evaluationScript = evaluationScript;
var _fs = _interopRequireDefault(require("fs"));
var _utils = require("../utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright 2017 Google Inc. All rights reserved.
* Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function envObjectToArray(env) {
const result = [];
for (const name in env) {
if (!Object.is(env[name], undefined)) result.push({
name,
value: String(env[name])
});
}
return result;
}
async function evaluationScript(fun, arg, addSourceUrl = true) {
if (typeof fun === 'function') {
const source = fun.toString();
const argString = Object.is(arg, undefined) ? 'undefined' : JSON.stringify(arg);
return `(${source})(${argString})`;
}
if (arg !== undefined) throw new Error('Cannot evaluate a string with arguments');
if ((0, _utils.isString)(fun)) return fun;
if (fun.content !== undefined) return fun.content;
if (fun.path !== undefined) {
let source = await _fs.default.promises.readFile(fun.path, 'utf8');
if (addSourceUrl) source += '\n//# sourceURL=' + fun.path.replace(/\n/g, '');
return source;
}
throw new Error('Either path or content property must be present');
}

View File

@ -1,40 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createInstrumentation = createInstrumentation;
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function createInstrumentation() {
const listeners = [];
return new Proxy({}, {
get: (obj, prop) => {
if (typeof prop !== 'string') return obj[prop];
if (prop === 'addListener') return listener => listeners.push(listener);
if (prop === 'removeListener') return listener => listeners.splice(listeners.indexOf(listener), 1);
if (prop === 'removeAllListeners') return () => listeners.splice(0, listeners.length);
if (!prop.startsWith('on')) return obj[prop];
return async (...params) => {
for (const listener of listeners) {
var _prop, _ref;
await ((_prop = (_ref = listener)[prop]) === null || _prop === void 0 ? void 0 : _prop.call(_ref, ...params));
}
};
}
});
}

View File

@ -1,330 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Connection = void 0;
var _browser = require("./browser");
var _browserContext = require("./browserContext");
var _browserType = require("./browserType");
var _channelOwner = require("./channelOwner");
var _elementHandle = require("./elementHandle");
var _frame = require("./frame");
var _jsHandle = require("./jsHandle");
var _network = require("./network");
var _page = require("./page");
var _worker = require("./worker");
var _consoleMessage = require("./consoleMessage");
var _dialog = require("./dialog");
var _serializers = require("../protocol/serializers");
var _cdpSession = require("./cdpSession");
var _playwright = require("./playwright");
var _electron = require("./electron");
var _stream = require("./stream");
var _writableStream = require("./writableStream");
var _debugLogger = require("../common/debugLogger");
var _selectors = require("./selectors");
var _android = require("./android");
var _stackTrace = require("../utils/stackTrace");
var _artifact = require("./artifact");
var _events = require("events");
var _jsonPipe = require("./jsonPipe");
var _fetch = require("./fetch");
var _localUtils = require("./localUtils");
var _tracing = require("./tracing");
var _validator = require("../protocol/validator");
var _clientInstrumentation = require("./clientInstrumentation");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the 'License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Root extends _channelOwner.ChannelOwner {
constructor(connection) {
super(connection, 'Root', '', {});
}
async initialize() {
return _playwright.Playwright.from((await this._channel.initialize({
sdkLanguage: 'javascript'
})).playwright);
}
}
class DummyChannelOwner extends _channelOwner.ChannelOwner {}
class Connection extends _events.EventEmitter {
// Some connections allow resolving in-process dispatchers.
constructor(localUtils, instrumentation) {
super();
this._objects = new Map();
this.onmessage = message => {};
this._lastId = 0;
this._callbacks = new Map();
this._rootObject = void 0;
this._closedErrorMessage = void 0;
this._isRemote = false;
this._localUtils = void 0;
this.toImpl = void 0;
this._tracingCount = 0;
this._instrumentation = void 0;
this._rootObject = new Root(this);
this._localUtils = localUtils;
this._instrumentation = instrumentation || (0, _clientInstrumentation.createInstrumentation)();
}
markAsRemote() {
this._isRemote = true;
}
isRemote() {
return this._isRemote;
}
localUtils() {
return this._localUtils;
}
async initializePlaywright() {
return await this._rootObject.initialize();
}
pendingProtocolCalls() {
return Array.from(this._callbacks.values()).map(callback => callback.stackTrace).filter(Boolean);
}
getObjectWithKnownName(guid) {
return this._objects.get(guid);
}
async setIsTracing(isTracing) {
if (isTracing) this._tracingCount++;else this._tracingCount--;
}
async sendMessageToServer(object, type, method, params, stackTrace, wallTime) {
var _this$_localUtils;
if (this._closedErrorMessage) throw new Error(this._closedErrorMessage);
const {
apiName,
frames
} = stackTrace || {
apiName: '',
frames: []
};
const guid = object._guid;
const id = ++this._lastId;
const converted = {
id,
guid,
method,
params
};
// Do not include metadata in debug logs to avoid noise.
_debugLogger.debugLogger.log('channel:command', converted);
const location = frames[0] ? {
file: frames[0].file,
line: frames[0].line,
column: frames[0].column
} : undefined;
const metadata = {
wallTime,
apiName,
location,
internal: !apiName
};
this.onmessage({
...converted,
metadata
});
if (this._tracingCount && frames && type !== 'LocalUtils') (_this$_localUtils = this._localUtils) === null || _this$_localUtils === void 0 ? void 0 : _this$_localUtils._channel.addStackToTracingNoReply({
callData: {
stack: frames,
id
}
}).catch(() => {});
return await new Promise((resolve, reject) => this._callbacks.set(id, {
resolve,
reject,
stackTrace,
type,
method
}));
}
dispatch(message) {
if (this._closedErrorMessage) return;
const {
id,
guid,
method,
params,
result,
error
} = message;
if (id) {
_debugLogger.debugLogger.log('channel:response', message);
const callback = this._callbacks.get(id);
if (!callback) throw new Error(`Cannot find command to respond: ${id}`);
this._callbacks.delete(id);
if (error && !result) {
callback.reject((0, _serializers.parseError)(error));
} else {
const validator = (0, _validator.findValidator)(callback.type, callback.method, 'Result');
callback.resolve(validator(result, '', {
tChannelImpl: this._tChannelImplFromWire.bind(this),
binary: this.isRemote() ? 'fromBase64' : 'buffer'
}));
}
return;
}
_debugLogger.debugLogger.log('channel:event', message);
if (method === '__create__') {
this._createRemoteObject(guid, params.type, params.guid, params.initializer);
return;
}
const object = this._objects.get(guid);
if (!object) throw new Error(`Cannot find object to "${method}": ${guid}`);
if (method === '__adopt__') {
const child = this._objects.get(params.guid);
if (!child) throw new Error(`Unknown new child: ${params.guid}`);
object._adopt(child);
return;
}
if (method === '__dispose__') {
object._dispose();
return;
}
const validator = (0, _validator.findValidator)(object._type, method, 'Event');
object._channel.emit(method, validator(params, '', {
tChannelImpl: this._tChannelImplFromWire.bind(this),
binary: this.isRemote() ? 'fromBase64' : 'buffer'
}));
}
close(errorMessage = 'Connection closed') {
const stack = (0, _stackTrace.captureLibraryStackTrace)().frameTexts.join('\n');
if (stack) errorMessage += '\n ==== Closed by ====\n' + stack + '\n';
this._closedErrorMessage = errorMessage;
for (const callback of this._callbacks.values()) callback.reject(new Error(errorMessage));
this._callbacks.clear();
this.emit('close');
}
_tChannelImplFromWire(names, arg, path, context) {
if (arg && typeof arg === 'object' && typeof arg.guid === 'string') {
const object = this._objects.get(arg.guid);
if (!object) throw new Error(`Object with guid ${arg.guid} was not bound in the connection`);
if (names !== '*' && !names.includes(object._type)) throw new _validator.ValidationError(`${path}: expected channel ${names.toString()}`);
return object._channel;
}
throw new _validator.ValidationError(`${path}: expected channel ${names.toString()}`);
}
_createRemoteObject(parentGuid, type, guid, initializer) {
const parent = this._objects.get(parentGuid);
if (!parent) throw new Error(`Cannot find parent object ${parentGuid} to create ${guid}`);
let result;
const validator = (0, _validator.findValidator)(type, '', 'Initializer');
initializer = validator(initializer, '', {
tChannelImpl: this._tChannelImplFromWire.bind(this),
binary: this.isRemote() ? 'fromBase64' : 'buffer'
});
switch (type) {
case 'Android':
result = new _android.Android(parent, type, guid, initializer);
break;
case 'AndroidSocket':
result = new _android.AndroidSocket(parent, type, guid, initializer);
break;
case 'AndroidDevice':
result = new _android.AndroidDevice(parent, type, guid, initializer);
break;
case 'APIRequestContext':
result = new _fetch.APIRequestContext(parent, type, guid, initializer);
break;
case 'Artifact':
result = new _artifact.Artifact(parent, type, guid, initializer);
break;
case 'BindingCall':
result = new _page.BindingCall(parent, type, guid, initializer);
break;
case 'Browser':
result = new _browser.Browser(parent, type, guid, initializer);
break;
case 'BrowserContext':
result = new _browserContext.BrowserContext(parent, type, guid, initializer);
break;
case 'BrowserType':
result = new _browserType.BrowserType(parent, type, guid, initializer);
break;
case 'CDPSession':
result = new _cdpSession.CDPSession(parent, type, guid, initializer);
break;
case 'ConsoleMessage':
result = new _consoleMessage.ConsoleMessage(parent, type, guid, initializer);
break;
case 'Dialog':
result = new _dialog.Dialog(parent, type, guid, initializer);
break;
case 'Electron':
result = new _electron.Electron(parent, type, guid, initializer);
break;
case 'ElectronApplication':
result = new _electron.ElectronApplication(parent, type, guid, initializer);
break;
case 'ElementHandle':
result = new _elementHandle.ElementHandle(parent, type, guid, initializer);
break;
case 'Frame':
result = new _frame.Frame(parent, type, guid, initializer);
break;
case 'JSHandle':
result = new _jsHandle.JSHandle(parent, type, guid, initializer);
break;
case 'JsonPipe':
result = new _jsonPipe.JsonPipe(parent, type, guid, initializer);
break;
case 'LocalUtils':
result = new _localUtils.LocalUtils(parent, type, guid, initializer);
if (!this._localUtils) this._localUtils = result;
break;
case 'Page':
result = new _page.Page(parent, type, guid, initializer);
break;
case 'Playwright':
result = new _playwright.Playwright(parent, type, guid, initializer);
break;
case 'Request':
result = new _network.Request(parent, type, guid, initializer);
break;
case 'Response':
result = new _network.Response(parent, type, guid, initializer);
break;
case 'Route':
result = new _network.Route(parent, type, guid, initializer);
break;
case 'Stream':
result = new _stream.Stream(parent, type, guid, initializer);
break;
case 'Selectors':
result = new _selectors.SelectorsOwner(parent, type, guid, initializer);
break;
case 'SocksSupport':
result = new DummyChannelOwner(parent, type, guid, initializer);
break;
case 'Tracing':
result = new _tracing.Tracing(parent, type, guid, initializer);
break;
case 'WebSocket':
result = new _network.WebSocket(parent, type, guid, initializer);
break;
case 'Worker':
result = new _worker.Worker(parent, type, guid, initializer);
break;
case 'WritableStream':
result = new _writableStream.WritableStream(parent, type, guid, initializer);
break;
default:
throw new Error('Missing type ' + type);
}
return result;
}
}
exports.Connection = Connection;

View File

@ -1,61 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ConsoleMessage = void 0;
var util = _interopRequireWildcard(require("util"));
var _jsHandle = require("./jsHandle");
var _channelOwner = require("./channelOwner");
var _page = require("./page");
let _util$inspect$custom;
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
_util$inspect$custom = util.inspect.custom;
class ConsoleMessage extends _channelOwner.ChannelOwner {
static from(message) {
return message._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
// Note: currently, we only report console messages for pages and they always have a page.
// However, in the future we might report console messages for service workers or something else,
// where page() would be null.
this._page = void 0;
this._page = _page.Page.fromNullable(initializer.page);
}
page() {
return this._page;
}
type() {
return this._initializer.type;
}
text() {
return this._initializer.text;
}
args() {
return this._initializer.args.map(_jsHandle.JSHandle.from);
}
location() {
return this._initializer.location;
}
[_util$inspect$custom]() {
return this.text();
}
}
exports.ConsoleMessage = ConsoleMessage;

View File

@ -1,41 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Coverage = void 0;
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Coverage {
constructor(channel) {
this._channel = void 0;
this._channel = channel;
}
async startJSCoverage(options = {}) {
await this._channel.startJSCoverage(options);
}
async stopJSCoverage() {
return (await this._channel.stopJSCoverage()).entries;
}
async startCSSCoverage(options = {}) {
await this._channel.startCSSCoverage(options);
}
async stopCSSCoverage() {
return (await this._channel.stopCSSCoverage()).entries;
}
}
exports.Coverage = Coverage;

View File

@ -1,57 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Dialog = void 0;
var _channelOwner = require("./channelOwner");
var _page = require("./page");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Dialog extends _channelOwner.ChannelOwner {
static from(dialog) {
return dialog._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
// Note: dialogs that open early during page initialization block it.
// Therefore, we must report the dialog without a page to be able to handle it.
this._page = void 0;
this._page = _page.Page.fromNullable(initializer.page);
}
page() {
return this._page;
}
type() {
return this._initializer.type;
}
message() {
return this._initializer.message;
}
defaultValue() {
return this._initializer.defaultValue;
}
async accept(promptText) {
await this._channel.accept({
promptText
});
}
async dismiss() {
await this._channel.dismiss();
}
}
exports.Dialog = Dialog;

View File

@ -1,62 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Download = void 0;
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Download {
constructor(page, url, suggestedFilename, artifact) {
this._page = void 0;
this._url = void 0;
this._suggestedFilename = void 0;
this._artifact = void 0;
this._page = page;
this._url = url;
this._suggestedFilename = suggestedFilename;
this._artifact = artifact;
}
page() {
return this._page;
}
url() {
return this._url;
}
suggestedFilename() {
return this._suggestedFilename;
}
async path() {
return this._artifact.pathAfterFinished();
}
async saveAs(path) {
return this._artifact.saveAs(path);
}
async failure() {
return this._artifact.failure();
}
async createReadStream() {
return this._artifact.createReadStream();
}
async cancel() {
return this._artifact.cancel();
}
async delete() {
return this._artifact.delete();
}
}
exports.Download = Download;

View File

@ -1,125 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ElectronApplication = exports.Electron = void 0;
var _timeoutSettings = require("../common/timeoutSettings");
var _browserContext = require("./browserContext");
var _channelOwner = require("./channelOwner");
var _clientHelper = require("./clientHelper");
var _events = require("./events");
var _jsHandle = require("./jsHandle");
var _waiter = require("./waiter");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Electron extends _channelOwner.ChannelOwner {
static from(electron) {
return electron._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
}
async launch(options = {}) {
const params = {
...(await (0, _browserContext.prepareBrowserContextParams)(options)),
env: (0, _clientHelper.envObjectToArray)(options.env ? options.env : process.env),
tracesDir: options.tracesDir
};
const app = ElectronApplication.from((await this._channel.launch(params)).electronApplication);
app._context._options = params;
return app;
}
}
exports.Electron = Electron;
class ElectronApplication extends _channelOwner.ChannelOwner {
static from(electronApplication) {
return electronApplication._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._context = void 0;
this._windows = new Set();
this._timeoutSettings = new _timeoutSettings.TimeoutSettings();
this._isClosed = false;
this._context = _browserContext.BrowserContext.from(initializer.context);
for (const page of this._context._pages) this._onPage(page);
this._context.on(_events.Events.BrowserContext.Page, page => this._onPage(page));
this._channel.on('close', () => {
this._isClosed = true;
this.emit(_events.Events.ElectronApplication.Close);
});
}
process() {
return this._toImpl().process();
}
_onPage(page) {
this._windows.add(page);
this.emit(_events.Events.ElectronApplication.Window, page);
page.once(_events.Events.Page.Close, () => this._windows.delete(page));
}
windows() {
// TODO: add ElectronPage class inherting from Page.
return [...this._windows];
}
async firstWindow(options) {
if (this._windows.size) return this._windows.values().next().value;
return this.waitForEvent('window', options);
}
context() {
return this._context;
}
async close() {
if (this._isClosed) return;
await this._channel.close().catch(() => {});
}
async waitForEvent(event, optionsOrPredicate = {}) {
return this._wrapApiCall(async () => {
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
const waiter = _waiter.Waiter.createForEvent(this, event);
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
if (event !== _events.Events.ElectronApplication.Close) waiter.rejectOnEvent(this, _events.Events.ElectronApplication.Close, new Error('Electron application closed'));
const result = await waiter.waitForEvent(this, event, predicate);
waiter.dispose();
return result;
});
}
async browserWindow(page) {
const result = await this._channel.browserWindow({
page: page._channel
});
return _jsHandle.JSHandle.from(result.handle);
}
async evaluate(pageFunction, arg) {
const result = await this._channel.evaluateExpression({
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: (0, _jsHandle.serializeArgument)(arg)
});
return (0, _jsHandle.parseResult)(result.value);
}
async evaluateHandle(pageFunction, arg) {
const result = await this._channel.evaluateExpressionHandle({
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: (0, _jsHandle.serializeArgument)(arg)
});
return _jsHandle.JSHandle.from(result.handle);
}
}
exports.ElectronApplication = ElectronApplication;

View File

@ -1,312 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ElementHandle = void 0;
exports.convertInputFiles = convertInputFiles;
exports.convertSelectOptionValues = convertSelectOptionValues;
exports.determineScreenshotType = determineScreenshotType;
var _frame = require("./frame");
var _jsHandle = require("./jsHandle");
var _fs = _interopRequireDefault(require("fs"));
var _utilsBundle = require("../utilsBundle");
var _path = _interopRequireDefault(require("path"));
var _utils = require("../utils");
var _fileUtils = require("../utils/fileUtils");
var _writableStream = require("./writableStream");
var _stream = require("stream");
var _util = require("util");
var _debugLogger = require("../common/debugLogger");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const pipelineAsync = (0, _util.promisify)(_stream.pipeline);
class ElementHandle extends _jsHandle.JSHandle {
static from(handle) {
return handle._object;
}
static fromNullable(handle) {
return handle ? ElementHandle.from(handle) : null;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._elementChannel = void 0;
this._elementChannel = this._channel;
}
asElement() {
return this;
}
async ownerFrame() {
return _frame.Frame.fromNullable((await this._elementChannel.ownerFrame()).frame);
}
async contentFrame() {
return _frame.Frame.fromNullable((await this._elementChannel.contentFrame()).frame);
}
async getAttribute(name) {
const value = (await this._elementChannel.getAttribute({
name
})).value;
return value === undefined ? null : value;
}
async inputValue() {
return (await this._elementChannel.inputValue()).value;
}
async textContent() {
const value = (await this._elementChannel.textContent()).value;
return value === undefined ? null : value;
}
async innerText() {
return (await this._elementChannel.innerText()).value;
}
async innerHTML() {
return (await this._elementChannel.innerHTML()).value;
}
async isChecked() {
return (await this._elementChannel.isChecked()).value;
}
async isDisabled() {
return (await this._elementChannel.isDisabled()).value;
}
async isEditable() {
return (await this._elementChannel.isEditable()).value;
}
async isEnabled() {
return (await this._elementChannel.isEnabled()).value;
}
async isHidden() {
return (await this._elementChannel.isHidden()).value;
}
async isVisible() {
return (await this._elementChannel.isVisible()).value;
}
async dispatchEvent(type, eventInit = {}) {
await this._elementChannel.dispatchEvent({
type,
eventInit: (0, _jsHandle.serializeArgument)(eventInit)
});
}
async scrollIntoViewIfNeeded(options = {}) {
await this._elementChannel.scrollIntoViewIfNeeded(options);
}
async hover(options = {}) {
await this._elementChannel.hover(options);
}
async click(options = {}) {
return await this._elementChannel.click(options);
}
async dblclick(options = {}) {
return await this._elementChannel.dblclick(options);
}
async tap(options = {}) {
return await this._elementChannel.tap(options);
}
async selectOption(values, options = {}) {
const result = await this._elementChannel.selectOption({
...convertSelectOptionValues(values),
...options
});
return result.values;
}
async fill(value, options = {}) {
return await this._elementChannel.fill({
value,
...options
});
}
async selectText(options = {}) {
await this._elementChannel.selectText(options);
}
async setInputFiles(files, options = {}) {
const frame = await this.ownerFrame();
if (!frame) throw new Error('Cannot set input files to detached element');
const converted = await convertInputFiles(files, frame.page().context());
if (converted.files) {
await this._elementChannel.setInputFiles({
files: converted.files,
...options
});
} else {
_debugLogger.debugLogger.log('api', 'switching to large files mode');
await this._elementChannel.setInputFilePaths({
...converted,
...options
});
}
}
async focus() {
await this._elementChannel.focus();
}
async type(text, options = {}) {
await this._elementChannel.type({
text,
...options
});
}
async press(key, options = {}) {
await this._elementChannel.press({
key,
...options
});
}
async check(options = {}) {
return await this._elementChannel.check(options);
}
async uncheck(options = {}) {
return await this._elementChannel.uncheck(options);
}
async setChecked(checked, options) {
if (checked) await this.check(options);else await this.uncheck(options);
}
async boundingBox() {
const value = (await this._elementChannel.boundingBox()).value;
return value === undefined ? null : value;
}
async screenshot(options = {}) {
const copy = {
...options,
mask: undefined
};
if (!copy.type) copy.type = determineScreenshotType(options);
if (options.mask) {
copy.mask = options.mask.map(locator => ({
frame: locator._frame._channel,
selector: locator._selector
}));
}
const result = await this._elementChannel.screenshot(copy);
if (options.path) {
await (0, _fileUtils.mkdirIfNeeded)(options.path);
await _fs.default.promises.writeFile(options.path, result.binary);
}
return result.binary;
}
async $(selector) {
return ElementHandle.fromNullable((await this._elementChannel.querySelector({
selector
})).element);
}
async $$(selector) {
const result = await this._elementChannel.querySelectorAll({
selector
});
return result.elements.map(h => ElementHandle.from(h));
}
async $eval(selector, pageFunction, arg) {
const result = await this._elementChannel.evalOnSelector({
selector,
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: (0, _jsHandle.serializeArgument)(arg)
});
return (0, _jsHandle.parseResult)(result.value);
}
async $$eval(selector, pageFunction, arg) {
const result = await this._elementChannel.evalOnSelectorAll({
selector,
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: (0, _jsHandle.serializeArgument)(arg)
});
return (0, _jsHandle.parseResult)(result.value);
}
async waitForElementState(state, options = {}) {
return await this._elementChannel.waitForElementState({
state,
...options
});
}
async waitForSelector(selector, options = {}) {
const result = await this._elementChannel.waitForSelector({
selector,
...options
});
return ElementHandle.fromNullable(result.element);
}
}
exports.ElementHandle = ElementHandle;
function convertSelectOptionValues(values) {
if (values === null) return {};
if (!Array.isArray(values)) values = [values];
if (!values.length) return {};
for (let i = 0; i < values.length; i++) (0, _utils.assert)(values[i] !== null, `options[${i}]: expected object, got null`);
if (values[0] instanceof ElementHandle) return {
elements: values.map(v => v._elementChannel)
};
if ((0, _utils.isString)(values[0])) return {
options: values.map(valueOrLabel => ({
valueOrLabel
}))
};
return {
options: values
};
}
async function convertInputFiles(files, context) {
const items = Array.isArray(files) ? files.slice() : [files];
const sizeLimit = 50 * 1024 * 1024;
const totalBufferSizeExceedsLimit = items.reduce((size, item) => size + (typeof item === 'object' && item.buffer ? item.buffer.byteLength : 0), 0) > sizeLimit;
if (totalBufferSizeExceedsLimit) throw new Error('Cannot set buffer larger than 50Mb, please write it to a file and pass its path instead.');
const stats = await Promise.all(items.filter(_utils.isString).map(item => _fs.default.promises.stat(item)));
const totalFileSizeExceedsLimit = stats.reduce((acc, stat) => acc + stat.size, 0) > sizeLimit;
if (totalFileSizeExceedsLimit) {
if (context._connection.isRemote()) {
const streams = await Promise.all(items.map(async item => {
(0, _utils.assert)((0, _utils.isString)(item));
const {
writableStream: stream
} = await context._channel.createTempFile({
name: _path.default.basename(item)
});
const writable = _writableStream.WritableStream.from(stream);
await pipelineAsync(_fs.default.createReadStream(item), writable.stream());
return stream;
}));
return {
streams
};
}
return {
localPaths: items.map(f => _path.default.resolve(f))
};
}
const filePayloads = await Promise.all(items.map(async item => {
if (typeof item === 'string') {
return {
name: _path.default.basename(item),
buffer: await _fs.default.promises.readFile(item)
};
} else {
return {
name: item.name,
mimeType: item.mimeType,
buffer: item.buffer
};
}
}));
return {
files: filePayloads
};
}
function determineScreenshotType(options) {
if (options.path) {
const mimeType = _utilsBundle.mime.getType(options.path);
if (mimeType === 'image/png') return 'png';else if (mimeType === 'image/jpeg') return 'jpeg';
throw new Error(`path: unsupported mime type "${mimeType}"`);
}
return options.type;
}

View File

@ -1,91 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Events = void 0;
/**
* Copyright 2019 Google Inc. All rights reserved.
* Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const Events = {
AndroidDevice: {
WebView: 'webview',
Close: 'close'
},
AndroidSocket: {
Data: 'data',
Close: 'close'
},
AndroidWebView: {
Close: 'close'
},
Browser: {
Disconnected: 'disconnected'
},
BrowserContext: {
Console: 'console',
Close: 'close',
Dialog: 'dialog',
Page: 'page',
BackgroundPage: 'backgroundpage',
ServiceWorker: 'serviceworker',
Request: 'request',
Response: 'response',
RequestFailed: 'requestfailed',
RequestFinished: 'requestfinished'
},
BrowserServer: {
Close: 'close'
},
Page: {
Close: 'close',
Crash: 'crash',
Console: 'console',
Dialog: 'dialog',
Download: 'download',
FileChooser: 'filechooser',
DOMContentLoaded: 'domcontentloaded',
// Can't use just 'error' due to node.js special treatment of error events.
// @see https://nodejs.org/api/events.html#events_error_events
PageError: 'pageerror',
Request: 'request',
Response: 'response',
RequestFailed: 'requestfailed',
RequestFinished: 'requestfinished',
FrameAttached: 'frameattached',
FrameDetached: 'framedetached',
FrameNavigated: 'framenavigated',
Load: 'load',
Popup: 'popup',
WebSocket: 'websocket',
Worker: 'worker'
},
WebSocket: {
Close: 'close',
Error: 'socketerror',
FrameReceived: 'framereceived',
FrameSent: 'framesent'
},
Worker: {
Close: 'close'
},
ElectronApplication: {
Close: 'close',
Window: 'window'
}
};
exports.Events = Events;

View File

@ -1,327 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.APIResponse = exports.APIRequestContext = exports.APIRequest = void 0;
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
var util = _interopRequireWildcard(require("util"));
var _errors = require("../common/errors");
var _utils = require("../utils");
var _fileUtils = require("../utils/fileUtils");
var _channelOwner = require("./channelOwner");
var _network = require("./network");
var _tracing = require("./tracing");
let _util$inspect$custom;
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class APIRequest {
// Instrumentation.
constructor(playwright) {
this._playwright = void 0;
this._contexts = new Set();
this._defaultContextOptions = void 0;
this._playwright = playwright;
}
async newContext(options = {}) {
var _this$_defaultContext;
options = {
...this._defaultContextOptions,
...options
};
const storageState = typeof options.storageState === 'string' ? JSON.parse(await _fs.default.promises.readFile(options.storageState, 'utf8')) : options.storageState;
// We do not expose tracesDir in the API, so do not allow options to accidentally override it.
const tracesDir = (_this$_defaultContext = this._defaultContextOptions) === null || _this$_defaultContext === void 0 ? void 0 : _this$_defaultContext.tracesDir;
const context = APIRequestContext.from((await this._playwright._channel.newRequest({
...options,
extraHTTPHeaders: options.extraHTTPHeaders ? (0, _utils.headersObjectToArray)(options.extraHTTPHeaders) : undefined,
storageState,
tracesDir
})).request);
this._contexts.add(context);
context._request = this;
context._tracing._tracesDir = tracesDir;
await context._instrumentation.onDidCreateRequestContext(context);
return context;
}
}
exports.APIRequest = APIRequest;
class APIRequestContext extends _channelOwner.ChannelOwner {
static from(channel) {
return channel._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._request = void 0;
this._tracing = void 0;
this._tracing = _tracing.Tracing.from(initializer.tracing);
}
async dispose() {
var _this$_request;
await this._instrumentation.onWillCloseRequestContext(this);
await this._channel.dispose();
(_this$_request = this._request) === null || _this$_request === void 0 ? void 0 : _this$_request._contexts.delete(this);
}
async delete(url, options) {
return this.fetch(url, {
...options,
method: 'DELETE'
});
}
async head(url, options) {
return this.fetch(url, {
...options,
method: 'HEAD'
});
}
async get(url, options) {
return this.fetch(url, {
...options,
method: 'GET'
});
}
async patch(url, options) {
return this.fetch(url, {
...options,
method: 'PATCH'
});
}
async post(url, options) {
return this.fetch(url, {
...options,
method: 'POST'
});
}
async put(url, options) {
return this.fetch(url, {
...options,
method: 'PUT'
});
}
async fetch(urlOrRequest, options = {}) {
const url = (0, _utils.isString)(urlOrRequest) ? urlOrRequest : undefined;
const request = (0, _utils.isString)(urlOrRequest) ? undefined : urlOrRequest;
return this._innerFetch({
url,
request,
...options
});
}
async _innerFetch(options = {}) {
return this._wrapApiCall(async () => {
var _options$request, _options$request2, _options$request3;
(0, _utils.assert)(options.request || typeof options.url === 'string', 'First argument must be either URL string or Request');
(0, _utils.assert)((options.data === undefined ? 0 : 1) + (options.form === undefined ? 0 : 1) + (options.multipart === undefined ? 0 : 1) <= 1, `Only one of 'data', 'form' or 'multipart' can be specified`);
(0, _utils.assert)(options.maxRedirects === undefined || options.maxRedirects >= 0, `'maxRedirects' should be greater than or equal to '0'`);
const url = options.url !== undefined ? options.url : options.request.url();
const params = objectToArray(options.params);
const method = options.method || ((_options$request = options.request) === null || _options$request === void 0 ? void 0 : _options$request.method());
const maxRedirects = options.maxRedirects;
// Cannot call allHeaders() here as the request may be paused inside route handler.
const headersObj = options.headers || ((_options$request2 = options.request) === null || _options$request2 === void 0 ? void 0 : _options$request2.headers());
const headers = headersObj ? (0, _utils.headersObjectToArray)(headersObj) : undefined;
let jsonData;
let formData;
let multipartData;
let postDataBuffer;
if (options.data !== undefined) {
if ((0, _utils.isString)(options.data)) {
if (isJsonContentType(headers)) jsonData = options.data;else postDataBuffer = Buffer.from(options.data, 'utf8');
} else if (Buffer.isBuffer(options.data)) {
postDataBuffer = options.data;
} else if (typeof options.data === 'object' || typeof options.data === 'number' || typeof options.data === 'boolean') {
jsonData = options.data;
} else {
throw new Error(`Unexpected 'data' type`);
}
} else if (options.form) {
formData = objectToArray(options.form);
} else if (options.multipart) {
multipartData = [];
// Convert file-like values to ServerFilePayload structs.
for (const [name, value] of Object.entries(options.multipart)) {
if (isFilePayload(value)) {
const payload = value;
if (!Buffer.isBuffer(payload.buffer)) throw new Error(`Unexpected buffer type of 'data.${name}'`);
multipartData.push({
name,
file: filePayloadToJson(payload)
});
} else if (value instanceof _fs.default.ReadStream) {
multipartData.push({
name,
file: await readStreamToJson(value)
});
} else {
multipartData.push({
name,
value: String(value)
});
}
}
}
if (postDataBuffer === undefined && jsonData === undefined && formData === undefined && multipartData === undefined) postDataBuffer = ((_options$request3 = options.request) === null || _options$request3 === void 0 ? void 0 : _options$request3.postDataBuffer()) || undefined;
const fixtures = {
__testHookLookup: options.__testHookLookup
};
const result = await this._channel.fetch({
url,
params,
method,
headers,
postData: postDataBuffer,
jsonData,
formData,
multipartData,
timeout: options.timeout,
failOnStatusCode: options.failOnStatusCode,
ignoreHTTPSErrors: options.ignoreHTTPSErrors,
maxRedirects: maxRedirects,
...fixtures
});
return new APIResponse(this, result.response);
});
}
async storageState(options = {}) {
const state = await this._channel.storageState();
if (options.path) {
await (0, _fileUtils.mkdirIfNeeded)(options.path);
await _fs.default.promises.writeFile(options.path, JSON.stringify(state, undefined, 2), 'utf8');
}
return state;
}
}
exports.APIRequestContext = APIRequestContext;
_util$inspect$custom = util.inspect.custom;
class APIResponse {
constructor(context, initializer) {
this._initializer = void 0;
this._headers = void 0;
this._request = void 0;
this._request = context;
this._initializer = initializer;
this._headers = new _network.RawHeaders(this._initializer.headers);
}
ok() {
return this._initializer.status >= 200 && this._initializer.status <= 299;
}
url() {
return this._initializer.url;
}
status() {
return this._initializer.status;
}
statusText() {
return this._initializer.statusText;
}
headers() {
return this._headers.headers();
}
headersArray() {
return this._headers.headersArray();
}
async body() {
try {
const result = await this._request._channel.fetchResponseBody({
fetchUid: this._fetchUid()
});
if (result.binary === undefined) throw new Error('Response has been disposed');
return result.binary;
} catch (e) {
if (e.message.includes(_errors.kBrowserOrContextClosedError)) throw new Error('Response has been disposed');
throw e;
}
}
async text() {
const content = await this.body();
return content.toString('utf8');
}
async json() {
const content = await this.text();
return JSON.parse(content);
}
async dispose() {
await this._request._channel.disposeAPIResponse({
fetchUid: this._fetchUid()
});
}
[_util$inspect$custom]() {
const headers = this.headersArray().map(({
name,
value
}) => ` ${name}: ${value}`);
return `APIResponse: ${this.status()} ${this.statusText()}\n${headers.join('\n')}`;
}
_fetchUid() {
return this._initializer.fetchUid;
}
async _fetchLog() {
const {
log
} = await this._request._channel.fetchLog({
fetchUid: this._fetchUid()
});
return log;
}
}
exports.APIResponse = APIResponse;
function filePayloadToJson(payload) {
return {
name: payload.name,
mimeType: payload.mimeType,
buffer: payload.buffer
};
}
async function readStreamToJson(stream) {
const buffer = await new Promise((resolve, reject) => {
const chunks = [];
stream.on('data', chunk => chunks.push(chunk));
stream.on('end', () => resolve(Buffer.concat(chunks)));
stream.on('error', err => reject(err));
});
const streamPath = Buffer.isBuffer(stream.path) ? stream.path.toString('utf8') : stream.path;
return {
name: _path.default.basename(streamPath),
buffer
};
}
function isJsonContentType(headers) {
if (!headers) return false;
for (const {
name,
value
} of headers) {
if (name.toLocaleLowerCase() === 'content-type') return value === 'application/json';
}
return false;
}
function objectToArray(map) {
if (!map) return undefined;
const result = [];
for (const [name, value] of Object.entries(map)) result.push({
name,
value: String(value)
});
return result;
}
function isFilePayload(value) {
return typeof value === 'object' && value['name'] && value['mimeType'] && value['buffer'];
}

View File

@ -1,45 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FileChooser = void 0;
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class FileChooser {
constructor(page, elementHandle, isMultiple) {
this._page = void 0;
this._elementHandle = void 0;
this._isMultiple = void 0;
this._page = page;
this._elementHandle = elementHandle;
this._isMultiple = isMultiple;
}
element() {
return this._elementHandle;
}
isMultiple() {
return this._isMultiple;
}
page() {
return this._page;
}
async setFiles(files, options) {
return this._elementHandle.setInputFiles(files, options);
}
}
exports.FileChooser = FileChooser;

View File

@ -1,515 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Frame = void 0;
exports.verifyLoadState = verifyLoadState;
var _utils = require("../utils");
var _channelOwner = require("./channelOwner");
var _locator = require("./locator");
var _locatorUtils = require("../utils/isomorphic/locatorUtils");
var _elementHandle = require("./elementHandle");
var _jsHandle = require("./jsHandle");
var _fs = _interopRequireDefault(require("fs"));
var network = _interopRequireWildcard(require("./network"));
var _events = require("events");
var _waiter = require("./waiter");
var _events2 = require("./events");
var _types = require("./types");
var _network2 = require("../utils/network");
var _debugLogger = require("../common/debugLogger");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright 2017 Google Inc. All rights reserved.
* Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Frame extends _channelOwner.ChannelOwner {
static from(frame) {
return frame._object;
}
static fromNullable(frame) {
return frame ? Frame.from(frame) : null;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._eventEmitter = void 0;
this._loadStates = void 0;
this._parentFrame = null;
this._url = '';
this._name = '';
this._detached = false;
this._childFrames = new Set();
this._page = void 0;
this._eventEmitter = new _events.EventEmitter();
this._eventEmitter.setMaxListeners(0);
this._parentFrame = Frame.fromNullable(initializer.parentFrame);
if (this._parentFrame) this._parentFrame._childFrames.add(this);
this._name = initializer.name;
this._url = initializer.url;
this._loadStates = new Set(initializer.loadStates);
this._channel.on('loadstate', event => {
if (event.add) {
this._loadStates.add(event.add);
this._eventEmitter.emit('loadstate', event.add);
}
if (event.remove) this._loadStates.delete(event.remove);
if (!this._parentFrame && event.add === 'load' && this._page) this._page.emit(_events2.Events.Page.Load, this._page);
if (!this._parentFrame && event.add === 'domcontentloaded' && this._page) this._page.emit(_events2.Events.Page.DOMContentLoaded, this._page);
});
this._channel.on('navigated', event => {
this._url = event.url;
this._name = event.name;
this._eventEmitter.emit('navigated', event);
if (!event.error && this._page) this._page.emit(_events2.Events.Page.FrameNavigated, this);
});
}
page() {
return this._page;
}
async goto(url, options = {}) {
const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
return network.Response.fromNullable((await this._channel.goto({
url,
...options,
waitUntil
})).response);
}
_setupNavigationWaiter(options) {
const waiter = new _waiter.Waiter(this._page, '');
if (this._page.isClosed()) waiter.rejectImmediately(new Error('Navigation failed because page was closed!'));
waiter.rejectOnEvent(this._page, _events2.Events.Page.Close, new Error('Navigation failed because page was closed!'));
waiter.rejectOnEvent(this._page, _events2.Events.Page.Crash, new Error('Navigation failed because page crashed!'));
waiter.rejectOnEvent(this._page, _events2.Events.Page.FrameDetached, new Error('Navigating frame was detached!'), frame => frame === this);
const timeout = this._page._timeoutSettings.navigationTimeout(options);
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded.`);
return waiter;
}
async waitForNavigation(options = {}) {
return this._page._wrapApiCall(async () => {
const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
const waiter = this._setupNavigationWaiter(options);
const toUrl = typeof options.url === 'string' ? ` to "${options.url}"` : '';
waiter.log(`waiting for navigation${toUrl} until "${waitUntil}"`);
const navigatedEvent = await waiter.waitForEvent(this._eventEmitter, 'navigated', event => {
var _this$_page;
// Any failed navigation results in a rejection.
if (event.error) return true;
waiter.log(` navigated to "${event.url}"`);
return (0, _network2.urlMatches)((_this$_page = this._page) === null || _this$_page === void 0 ? void 0 : _this$_page.context()._options.baseURL, event.url, options.url);
});
if (navigatedEvent.error) {
const e = new Error(navigatedEvent.error);
e.stack = '';
await waiter.waitForPromise(Promise.reject(e));
}
if (!this._loadStates.has(waitUntil)) {
await waiter.waitForEvent(this._eventEmitter, 'loadstate', s => {
waiter.log(` "${s}" event fired`);
return s === waitUntil;
});
}
const request = navigatedEvent.newDocument ? network.Request.fromNullable(navigatedEvent.newDocument.request) : null;
const response = request ? await waiter.waitForPromise(request._finalRequest()._internalResponse()) : null;
waiter.dispose();
return response;
});
}
async waitForLoadState(state = 'load', options = {}) {
state = verifyLoadState('state', state);
return this._page._wrapApiCall(async () => {
const waiter = this._setupNavigationWaiter(options);
if (this._loadStates.has(state)) {
waiter.log(` not waiting, "${state}" event already fired`);
} else {
await waiter.waitForEvent(this._eventEmitter, 'loadstate', s => {
waiter.log(` "${s}" event fired`);
return s === state;
});
}
waiter.dispose();
});
}
async waitForURL(url, options = {}) {
var _this$_page2;
if ((0, _network2.urlMatches)((_this$_page2 = this._page) === null || _this$_page2 === void 0 ? void 0 : _this$_page2.context()._options.baseURL, this.url(), url)) return await this.waitForLoadState(options.waitUntil, options);
await this.waitForNavigation({
url,
...options
});
}
async frameElement() {
return _elementHandle.ElementHandle.from((await this._channel.frameElement()).element);
}
async evaluateHandle(pageFunction, arg) {
(0, _jsHandle.assertMaxArguments)(arguments.length, 2);
const result = await this._channel.evaluateExpressionHandle({
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: (0, _jsHandle.serializeArgument)(arg)
});
return _jsHandle.JSHandle.from(result.handle);
}
async evaluate(pageFunction, arg) {
(0, _jsHandle.assertMaxArguments)(arguments.length, 2);
const result = await this._channel.evaluateExpression({
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: (0, _jsHandle.serializeArgument)(arg)
});
return (0, _jsHandle.parseResult)(result.value);
}
async _evaluateExposeUtilityScript(pageFunction, arg) {
(0, _jsHandle.assertMaxArguments)(arguments.length, 2);
const result = await this._channel.evaluateExpression({
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
exposeUtilityScript: true,
arg: (0, _jsHandle.serializeArgument)(arg)
});
return (0, _jsHandle.parseResult)(result.value);
}
async $(selector, options) {
const result = await this._channel.querySelector({
selector,
...options
});
return _elementHandle.ElementHandle.fromNullable(result.element);
}
async waitForSelector(selector, options = {}) {
if (options.visibility) throw new Error('options.visibility is not supported, did you mean options.state?');
if (options.waitFor && options.waitFor !== 'visible') throw new Error('options.waitFor is not supported, did you mean options.state?');
const result = await this._channel.waitForSelector({
selector,
...options
});
return _elementHandle.ElementHandle.fromNullable(result.element);
}
async dispatchEvent(selector, type, eventInit, options = {}) {
await this._channel.dispatchEvent({
selector,
type,
eventInit: (0, _jsHandle.serializeArgument)(eventInit),
...options
});
}
async $eval(selector, pageFunction, arg) {
(0, _jsHandle.assertMaxArguments)(arguments.length, 3);
const result = await this._channel.evalOnSelector({
selector,
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: (0, _jsHandle.serializeArgument)(arg)
});
return (0, _jsHandle.parseResult)(result.value);
}
async $$eval(selector, pageFunction, arg) {
(0, _jsHandle.assertMaxArguments)(arguments.length, 3);
const result = await this._channel.evalOnSelectorAll({
selector,
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: (0, _jsHandle.serializeArgument)(arg)
});
return (0, _jsHandle.parseResult)(result.value);
}
async $$(selector) {
const result = await this._channel.querySelectorAll({
selector
});
return result.elements.map(e => _elementHandle.ElementHandle.from(e));
}
async _queryCount(selector) {
return (await this._channel.queryCount({
selector
})).value;
}
async content() {
return (await this._channel.content()).value;
}
async setContent(html, options = {}) {
const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
await this._channel.setContent({
html,
...options,
waitUntil
});
}
name() {
return this._name || '';
}
url() {
return this._url;
}
parentFrame() {
return this._parentFrame;
}
childFrames() {
return Array.from(this._childFrames);
}
isDetached() {
return this._detached;
}
async addScriptTag(options = {}) {
const copy = {
...options
};
if (copy.path) {
copy.content = (await _fs.default.promises.readFile(copy.path)).toString();
copy.content += '//# sourceURL=' + copy.path.replace(/\n/g, '');
}
return _elementHandle.ElementHandle.from((await this._channel.addScriptTag({
...copy
})).element);
}
async addStyleTag(options = {}) {
const copy = {
...options
};
if (copy.path) {
copy.content = (await _fs.default.promises.readFile(copy.path)).toString();
copy.content += '/*# sourceURL=' + copy.path.replace(/\n/g, '') + '*/';
}
return _elementHandle.ElementHandle.from((await this._channel.addStyleTag({
...copy
})).element);
}
async click(selector, options = {}) {
return await this._channel.click({
selector,
...options
});
}
async dblclick(selector, options = {}) {
return await this._channel.dblclick({
selector,
...options
});
}
async dragAndDrop(source, target, options = {}) {
return await this._channel.dragAndDrop({
source,
target,
...options
});
}
async tap(selector, options = {}) {
return await this._channel.tap({
selector,
...options
});
}
async fill(selector, value, options = {}) {
return await this._channel.fill({
selector,
value,
...options
});
}
async _highlight(selector) {
return await this._channel.highlight({
selector
});
}
locator(selector, options) {
return new _locator.Locator(this, selector, options);
}
getByTestId(testId) {
return this.locator((0, _locatorUtils.getByTestIdSelector)((0, _locator.testIdAttributeName)(), testId));
}
getByAltText(text, options) {
return this.locator((0, _locatorUtils.getByAltTextSelector)(text, options));
}
getByLabel(text, options) {
return this.locator((0, _locatorUtils.getByLabelSelector)(text, options));
}
getByPlaceholder(text, options) {
return this.locator((0, _locatorUtils.getByPlaceholderSelector)(text, options));
}
getByText(text, options) {
return this.locator((0, _locatorUtils.getByTextSelector)(text, options));
}
getByTitle(text, options) {
return this.locator((0, _locatorUtils.getByTitleSelector)(text, options));
}
getByRole(role, options = {}) {
return this.locator((0, _locatorUtils.getByRoleSelector)(role, options));
}
frameLocator(selector) {
return new _locator.FrameLocator(this, selector);
}
async focus(selector, options = {}) {
await this._channel.focus({
selector,
...options
});
}
async textContent(selector, options = {}) {
const value = (await this._channel.textContent({
selector,
...options
})).value;
return value === undefined ? null : value;
}
async innerText(selector, options = {}) {
return (await this._channel.innerText({
selector,
...options
})).value;
}
async innerHTML(selector, options = {}) {
return (await this._channel.innerHTML({
selector,
...options
})).value;
}
async getAttribute(selector, name, options = {}) {
const value = (await this._channel.getAttribute({
selector,
name,
...options
})).value;
return value === undefined ? null : value;
}
async inputValue(selector, options = {}) {
return (await this._channel.inputValue({
selector,
...options
})).value;
}
async isChecked(selector, options = {}) {
return (await this._channel.isChecked({
selector,
...options
})).value;
}
async isDisabled(selector, options = {}) {
return (await this._channel.isDisabled({
selector,
...options
})).value;
}
async isEditable(selector, options = {}) {
return (await this._channel.isEditable({
selector,
...options
})).value;
}
async isEnabled(selector, options = {}) {
return (await this._channel.isEnabled({
selector,
...options
})).value;
}
async isHidden(selector, options = {}) {
return (await this._channel.isHidden({
selector,
...options
})).value;
}
async isVisible(selector, options = {}) {
return (await this._channel.isVisible({
selector,
...options
})).value;
}
async hover(selector, options = {}) {
await this._channel.hover({
selector,
...options
});
}
async selectOption(selector, values, options = {}) {
return (await this._channel.selectOption({
selector,
...(0, _elementHandle.convertSelectOptionValues)(values),
...options
})).values;
}
async setInputFiles(selector, files, options = {}) {
const converted = await (0, _elementHandle.convertInputFiles)(files, this.page().context());
if (converted.files) {
await this._channel.setInputFiles({
selector,
files: converted.files,
...options
});
} else {
_debugLogger.debugLogger.log('api', 'switching to large files mode');
await this._channel.setInputFilePaths({
selector,
...converted,
...options
});
}
}
async type(selector, text, options = {}) {
await this._channel.type({
selector,
text,
...options
});
}
async press(selector, key, options = {}) {
await this._channel.press({
selector,
key,
...options
});
}
async check(selector, options = {}) {
await this._channel.check({
selector,
...options
});
}
async uncheck(selector, options = {}) {
await this._channel.uncheck({
selector,
...options
});
}
async setChecked(selector, checked, options) {
if (checked) await this.check(selector, options);else await this.uncheck(selector, options);
}
async waitForTimeout(timeout) {
await this._channel.waitForTimeout({
timeout
});
}
async waitForFunction(pageFunction, arg, options = {}) {
if (typeof options.polling === 'string') (0, _utils.assert)(options.polling === 'raf', 'Unknown polling option: ' + options.polling);
const result = await this._channel.waitForFunction({
...options,
pollingInterval: options.polling === 'raf' ? undefined : options.polling,
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: (0, _jsHandle.serializeArgument)(arg)
});
return _jsHandle.JSHandle.from(result.handle);
}
async title() {
return (await this._channel.title()).value;
}
}
exports.Frame = Frame;
function verifyLoadState(name, waitUntil) {
if (waitUntil === 'networkidle0') waitUntil = 'networkidle';
if (!_types.kLifecycleEvents.has(waitUntil)) throw new Error(`${name}: expected one of (load|domcontentloaded|networkidle|commit)`);
return waitUntil;
}

View File

@ -1,92 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.HarRouter = void 0;
var _debugLogger = require("../common/debugLogger");
var _events = require("./events");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class HarRouter {
static async create(localUtils, file, notFoundAction, options) {
const {
harId,
error
} = await localUtils._channel.harOpen({
file
});
if (error) throw new Error(error);
return new HarRouter(localUtils, harId, notFoundAction, options);
}
constructor(localUtils, harId, notFoundAction, options) {
this._localUtils = void 0;
this._harId = void 0;
this._notFoundAction = void 0;
this._options = void 0;
this._localUtils = localUtils;
this._harId = harId;
this._options = options;
this._notFoundAction = notFoundAction;
}
async _handle(route) {
const request = route.request();
const response = await this._localUtils._channel.harLookup({
harId: this._harId,
url: request.url(),
method: request.method(),
headers: await request.headersArray(),
postData: request.postDataBuffer() || undefined,
isNavigationRequest: request.isNavigationRequest()
});
if (response.action === 'redirect') {
_debugLogger.debugLogger.log('api', `HAR: ${route.request().url()} redirected to ${response.redirectURL}`);
await route._redirectNavigationRequest(response.redirectURL);
return;
}
if (response.action === 'fulfill') {
await route.fulfill({
status: response.status,
headers: Object.fromEntries(response.headers.map(h => [h.name, h.value])),
body: response.body
});
return;
}
if (response.action === 'error') _debugLogger.debugLogger.log('api', 'HAR: ' + response.message);
// Report the error, but fall through to the default handler.
if (this._notFoundAction === 'abort') {
await route.abort();
return;
}
await route.fallback();
}
async addContextRoute(context) {
await context.route(this._options.urlMatch || '**/*', route => this._handle(route));
context.once(_events.Events.BrowserContext.Close, () => this.dispose());
}
async addPageRoute(page) {
await page.route(this._options.urlMatch || '**/*', route => this._handle(route));
page.once(_events.Events.Page.Close, () => this.dispose());
}
dispose() {
this._localUtils._channel.harClose({
harId: this._harId
}).catch(() => {});
}
}
exports.HarRouter = HarRouter;

View File

@ -1,111 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Touchscreen = exports.Mouse = exports.Keyboard = void 0;
/**
* Copyright 2017 Google Inc. All rights reserved.
* Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Keyboard {
constructor(page) {
this._page = void 0;
this._page = page;
}
async down(key) {
await this._page._channel.keyboardDown({
key
});
}
async up(key) {
await this._page._channel.keyboardUp({
key
});
}
async insertText(text) {
await this._page._channel.keyboardInsertText({
text
});
}
async type(text, options = {}) {
await this._page._channel.keyboardType({
text,
...options
});
}
async press(key, options = {}) {
await this._page._channel.keyboardPress({
key,
...options
});
}
}
exports.Keyboard = Keyboard;
class Mouse {
constructor(page) {
this._page = void 0;
this._page = page;
}
async move(x, y, options = {}) {
await this._page._channel.mouseMove({
x,
y,
...options
});
}
async down(options = {}) {
await this._page._channel.mouseDown({
...options
});
}
async up(options = {}) {
await this._page._channel.mouseUp(options);
}
async click(x, y, options = {}) {
await this._page._channel.mouseClick({
x,
y,
...options
});
}
async dblclick(x, y, options = {}) {
await this.click(x, y, {
...options,
clickCount: 2
});
}
async wheel(deltaX, deltaY) {
await this._page._channel.mouseWheel({
deltaX,
deltaY
});
}
}
exports.Mouse = Mouse;
class Touchscreen {
constructor(page) {
this._page = void 0;
this._page = page;
}
async tap(x, y) {
await this._page._channel.touchscreenTap({
x,
y
});
}
}
exports.Touchscreen = Touchscreen;

View File

@ -1,119 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.JSHandle = void 0;
exports.assertMaxArguments = assertMaxArguments;
exports.parseResult = parseResult;
exports.serializeArgument = serializeArgument;
var _channelOwner = require("./channelOwner");
var _serializers = require("../protocol/serializers");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class JSHandle extends _channelOwner.ChannelOwner {
static from(handle) {
return handle._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._preview = void 0;
this._preview = this._initializer.preview;
this._channel.on('previewUpdated', ({
preview
}) => this._preview = preview);
}
async evaluate(pageFunction, arg) {
const result = await this._channel.evaluateExpression({
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: serializeArgument(arg)
});
return parseResult(result.value);
}
async evaluateHandle(pageFunction, arg) {
const result = await this._channel.evaluateExpressionHandle({
expression: String(pageFunction),
isFunction: typeof pageFunction === 'function',
arg: serializeArgument(arg)
});
return JSHandle.from(result.handle);
}
async getProperty(propertyName) {
const result = await this._channel.getProperty({
name: propertyName
});
return JSHandle.from(result.handle);
}
async getProperties() {
const map = new Map();
for (const {
name,
value
} of (await this._channel.getPropertyList()).properties) map.set(name, JSHandle.from(value));
return map;
}
async jsonValue() {
return parseResult((await this._channel.jsonValue()).value);
}
asElement() {
return null;
}
async dispose() {
return await this._channel.dispose();
}
async _objectCount() {
return this._wrapApiCall(async () => {
const {
count
} = await this._channel.objectCount();
return count;
});
}
toString() {
return this._preview;
}
}
// This function takes care of converting all JSHandles to their channels,
// so that generic channel serializer converts them to guids.
exports.JSHandle = JSHandle;
function serializeArgument(arg) {
const handles = [];
const pushHandle = channel => {
handles.push(channel);
return handles.length - 1;
};
const value = (0, _serializers.serializeValue)(arg, value => {
if (value instanceof JSHandle) return {
h: pushHandle(value._channel)
};
return {
fallThrough: value
};
});
return {
value,
handles
};
}
function parseResult(value) {
return (0, _serializers.parseSerializedValue)(value, undefined);
}
function assertMaxArguments(count, max) {
if (count > max) throw new Error('Too many arguments. If you need to pass more than 1 argument to the function wrap them in an object.');
}

View File

@ -1,35 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.JsonPipe = void 0;
var _channelOwner = require("./channelOwner");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class JsonPipe extends _channelOwner.ChannelOwner {
static from(jsonPipe) {
return jsonPipe._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
}
channel() {
return this._channel;
}
}
exports.JsonPipe = JsonPipe;

View File

@ -1,29 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LocalUtils = void 0;
var _channelOwner = require("./channelOwner");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class LocalUtils extends _channelOwner.ChannelOwner {
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
}
}
exports.LocalUtils = LocalUtils;

View File

@ -1,429 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Locator = exports.FrameLocator = void 0;
exports.setTestIdAttribute = setTestIdAttribute;
exports.testIdAttributeName = testIdAttributeName;
var util = _interopRequireWildcard(require("util"));
var _utils = require("../utils");
var _elementHandle = require("./elementHandle");
var _jsHandle = require("./jsHandle");
var _stringUtils = require("../utils/isomorphic/stringUtils");
var _locatorUtils = require("../utils/isomorphic/locatorUtils");
let _util$inspect$custom;
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
_util$inspect$custom = util.inspect.custom;
class Locator {
constructor(frame, selector, options) {
this._frame = void 0;
this._selector = void 0;
this._frame = frame;
this._selector = selector;
if (options !== null && options !== void 0 && options.hasText) this._selector += ` >> internal:has-text=${(0, _stringUtils.escapeForTextSelector)(options.hasText, false)}`;
if (options !== null && options !== void 0 && options.hasNotText) this._selector += ` >> internal:has-not-text=${(0, _stringUtils.escapeForTextSelector)(options.hasNotText, false)}`;
if (options !== null && options !== void 0 && options.has) {
const locator = options.has;
if (locator._frame !== frame) throw new Error(`Inner "has" locator must belong to the same frame.`);
this._selector += ` >> internal:has=` + JSON.stringify(locator._selector);
}
if (options !== null && options !== void 0 && options.hasNot) {
const locator = options.hasNot;
if (locator._frame !== frame) throw new Error(`Inner "hasNot" locator must belong to the same frame.`);
this._selector += ` >> internal:has-not=` + JSON.stringify(locator._selector);
}
}
async _withElement(task, timeout) {
timeout = this._frame.page()._timeoutSettings.timeout({
timeout
});
const deadline = timeout ? (0, _utils.monotonicTime)() + timeout : 0;
return this._frame._wrapApiCall(async () => {
const result = await this._frame._channel.waitForSelector({
selector: this._selector,
strict: true,
state: 'attached',
timeout
});
const handle = _elementHandle.ElementHandle.fromNullable(result.element);
if (!handle) throw new Error(`Could not resolve ${this._selector} to DOM Element`);
try {
return await task(handle, deadline ? deadline - (0, _utils.monotonicTime)() : 0);
} finally {
await handle.dispose();
}
});
}
page() {
return this._frame.page();
}
async boundingBox(options) {
return this._withElement(h => h.boundingBox(), options === null || options === void 0 ? void 0 : options.timeout);
}
async check(options = {}) {
return this._frame.check(this._selector, {
strict: true,
...options
});
}
async click(options = {}) {
return this._frame.click(this._selector, {
strict: true,
...options
});
}
async dblclick(options = {}) {
return this._frame.dblclick(this._selector, {
strict: true,
...options
});
}
async dispatchEvent(type, eventInit = {}, options) {
return this._frame.dispatchEvent(this._selector, type, eventInit, {
strict: true,
...options
});
}
async dragTo(target, options = {}) {
return this._frame.dragAndDrop(this._selector, target._selector, {
strict: true,
...options
});
}
async evaluate(pageFunction, arg, options) {
return this._withElement(h => h.evaluate(pageFunction, arg), options === null || options === void 0 ? void 0 : options.timeout);
}
async evaluateAll(pageFunction, arg) {
return this._frame.$$eval(this._selector, pageFunction, arg);
}
async evaluateHandle(pageFunction, arg, options) {
return this._withElement(h => h.evaluateHandle(pageFunction, arg), options === null || options === void 0 ? void 0 : options.timeout);
}
async fill(value, options = {}) {
return this._frame.fill(this._selector, value, {
strict: true,
...options
});
}
async clear(options = {}) {
return this.fill('', options);
}
async _highlight() {
// VS Code extension uses this one, keep it for now.
return this._frame._highlight(this._selector);
}
async highlight() {
return this._frame._highlight(this._selector);
}
locator(selectorOrLocator, options) {
if ((0, _utils.isString)(selectorOrLocator)) return new Locator(this._frame, this._selector + ' >> ' + selectorOrLocator, options);
if (selectorOrLocator._frame !== this._frame) throw new Error(`Locators must belong to the same frame.`);
return new Locator(this._frame, this._selector + ' >> internal:chain=' + JSON.stringify(selectorOrLocator._selector), options);
}
getByTestId(testId) {
return this.locator((0, _locatorUtils.getByTestIdSelector)(testIdAttributeName(), testId));
}
getByAltText(text, options) {
return this.locator((0, _locatorUtils.getByAltTextSelector)(text, options));
}
getByLabel(text, options) {
return this.locator((0, _locatorUtils.getByLabelSelector)(text, options));
}
getByPlaceholder(text, options) {
return this.locator((0, _locatorUtils.getByPlaceholderSelector)(text, options));
}
getByText(text, options) {
return this.locator((0, _locatorUtils.getByTextSelector)(text, options));
}
getByTitle(text, options) {
return this.locator((0, _locatorUtils.getByTitleSelector)(text, options));
}
getByRole(role, options = {}) {
return this.locator((0, _locatorUtils.getByRoleSelector)(role, options));
}
frameLocator(selector) {
return new FrameLocator(this._frame, this._selector + ' >> ' + selector);
}
filter(options) {
return new Locator(this._frame, this._selector, options);
}
async elementHandle(options) {
return await this._frame.waitForSelector(this._selector, {
strict: true,
state: 'attached',
...options
});
}
async elementHandles() {
return this._frame.$$(this._selector);
}
first() {
return new Locator(this._frame, this._selector + ' >> nth=0');
}
last() {
return new Locator(this._frame, this._selector + ` >> nth=-1`);
}
nth(index) {
return new Locator(this._frame, this._selector + ` >> nth=${index}`);
}
and(locator) {
if (locator._frame !== this._frame) throw new Error(`Locators must belong to the same frame.`);
return new Locator(this._frame, this._selector + ` >> internal:and=` + JSON.stringify(locator._selector));
}
or(locator) {
if (locator._frame !== this._frame) throw new Error(`Locators must belong to the same frame.`);
return new Locator(this._frame, this._selector + ` >> internal:or=` + JSON.stringify(locator._selector));
}
async focus(options) {
return this._frame.focus(this._selector, {
strict: true,
...options
});
}
async blur(options) {
await this._frame._channel.blur({
selector: this._selector,
strict: true,
...options
});
}
async count() {
return this._frame._queryCount(this._selector);
}
async getAttribute(name, options) {
return this._frame.getAttribute(this._selector, name, {
strict: true,
...options
});
}
async hover(options = {}) {
return this._frame.hover(this._selector, {
strict: true,
...options
});
}
async innerHTML(options) {
return this._frame.innerHTML(this._selector, {
strict: true,
...options
});
}
async innerText(options) {
return this._frame.innerText(this._selector, {
strict: true,
...options
});
}
async inputValue(options) {
return this._frame.inputValue(this._selector, {
strict: true,
...options
});
}
async isChecked(options) {
return this._frame.isChecked(this._selector, {
strict: true,
...options
});
}
async isDisabled(options) {
return this._frame.isDisabled(this._selector, {
strict: true,
...options
});
}
async isEditable(options) {
return this._frame.isEditable(this._selector, {
strict: true,
...options
});
}
async isEnabled(options) {
return this._frame.isEnabled(this._selector, {
strict: true,
...options
});
}
async isHidden(options) {
return this._frame.isHidden(this._selector, {
strict: true,
...options
});
}
async isVisible(options) {
return this._frame.isVisible(this._selector, {
strict: true,
...options
});
}
async press(key, options = {}) {
return this._frame.press(this._selector, key, {
strict: true,
...options
});
}
async screenshot(options = {}) {
return this._withElement((h, timeout) => h.screenshot({
...options,
timeout
}), options.timeout);
}
async scrollIntoViewIfNeeded(options = {}) {
return this._withElement((h, timeout) => h.scrollIntoViewIfNeeded({
...options,
timeout
}), options.timeout);
}
async selectOption(values, options = {}) {
return this._frame.selectOption(this._selector, values, {
strict: true,
...options
});
}
async selectText(options = {}) {
return this._withElement((h, timeout) => h.selectText({
...options,
timeout
}), options.timeout);
}
async setChecked(checked, options) {
if (checked) await this.check(options);else await this.uncheck(options);
}
async setInputFiles(files, options = {}) {
return this._frame.setInputFiles(this._selector, files, {
strict: true,
...options
});
}
async tap(options = {}) {
return this._frame.tap(this._selector, {
strict: true,
...options
});
}
async textContent(options) {
return this._frame.textContent(this._selector, {
strict: true,
...options
});
}
async type(text, options = {}) {
return this._frame.type(this._selector, text, {
strict: true,
...options
});
}
async uncheck(options = {}) {
return this._frame.uncheck(this._selector, {
strict: true,
...options
});
}
async all() {
return new Array(await this.count()).fill(0).map((e, i) => this.nth(i));
}
async allInnerTexts() {
return this._frame.$$eval(this._selector, ee => ee.map(e => e.innerText));
}
async allTextContents() {
return this._frame.$$eval(this._selector, ee => ee.map(e => e.textContent || ''));
}
async waitFor(options) {
await this._frame._channel.waitForSelector({
selector: this._selector,
strict: true,
omitReturnValue: true,
...options
});
}
async _expect(expression, options) {
const params = {
selector: this._selector,
expression,
...options,
isNot: !!options.isNot
};
params.expectedValue = (0, _jsHandle.serializeArgument)(options.expectedValue);
const result = await this._frame._channel.expect(params);
if (result.received !== undefined) result.received = (0, _jsHandle.parseResult)(result.received);
return result;
}
[_util$inspect$custom]() {
return this.toString();
}
toString() {
return `Locator@${this._selector}`;
}
}
exports.Locator = Locator;
class FrameLocator {
constructor(frame, selector) {
this._frame = void 0;
this._frameSelector = void 0;
this._frame = frame;
this._frameSelector = selector;
}
locator(selectorOrLocator, options) {
if ((0, _utils.isString)(selectorOrLocator)) return new Locator(this._frame, this._frameSelector + ' >> internal:control=enter-frame >> ' + selectorOrLocator, options);
if (selectorOrLocator._frame !== this._frame) throw new Error(`Locators must belong to the same frame.`);
return new Locator(this._frame, this._frameSelector + ' >> internal:control=enter-frame >> ' + selectorOrLocator._selector, options);
}
getByTestId(testId) {
return this.locator((0, _locatorUtils.getByTestIdSelector)(testIdAttributeName(), testId));
}
getByAltText(text, options) {
return this.locator((0, _locatorUtils.getByAltTextSelector)(text, options));
}
getByLabel(text, options) {
return this.locator((0, _locatorUtils.getByLabelSelector)(text, options));
}
getByPlaceholder(text, options) {
return this.locator((0, _locatorUtils.getByPlaceholderSelector)(text, options));
}
getByText(text, options) {
return this.locator((0, _locatorUtils.getByTextSelector)(text, options));
}
getByTitle(text, options) {
return this.locator((0, _locatorUtils.getByTitleSelector)(text, options));
}
getByRole(role, options = {}) {
return this.locator((0, _locatorUtils.getByRoleSelector)(role, options));
}
frameLocator(selector) {
return new FrameLocator(this._frame, this._frameSelector + ' >> internal:control=enter-frame >> ' + selector);
}
first() {
return new FrameLocator(this._frame, this._frameSelector + ' >> nth=0');
}
last() {
return new FrameLocator(this._frame, this._frameSelector + ` >> nth=-1`);
}
nth(index) {
return new FrameLocator(this._frame, this._frameSelector + ` >> nth=${index}`);
}
}
exports.FrameLocator = FrameLocator;
let _testIdAttributeName = 'data-testid';
function testIdAttributeName() {
return _testIdAttributeName;
}
function setTestIdAttribute(attributeName) {
_testIdAttributeName = attributeName;
}

View File

@ -1,552 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.WebSocket = exports.RouteHandler = exports.Route = exports.Response = exports.Request = exports.RawHeaders = void 0;
exports.validateHeaders = validateHeaders;
var _url = require("url");
var _channelOwner = require("./channelOwner");
var _frame = require("./frame");
var _worker = require("./worker");
var _fs = _interopRequireDefault(require("fs"));
var _utilsBundle = require("../utilsBundle");
var _utils = require("../utils");
var _manualPromise = require("../utils/manualPromise");
var _events = require("./events");
var _waiter = require("./waiter");
var _network = require("../utils/network");
var _multimap = require("../utils/multimap");
var _fetch = require("./fetch");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Request extends _channelOwner.ChannelOwner {
static from(request) {
return request._object;
}
static fromNullable(request) {
return request ? Request.from(request) : null;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._redirectedFrom = null;
this._redirectedTo = null;
this._failureText = null;
this._provisionalHeaders = void 0;
this._actualHeadersPromise = void 0;
this._timing = void 0;
this._fallbackOverrides = {};
this._redirectedFrom = Request.fromNullable(initializer.redirectedFrom);
if (this._redirectedFrom) this._redirectedFrom._redirectedTo = this;
this._provisionalHeaders = new RawHeaders(initializer.headers);
this._fallbackOverrides.postDataBuffer = initializer.postData;
this._timing = {
startTime: 0,
domainLookupStart: -1,
domainLookupEnd: -1,
connectStart: -1,
secureConnectionStart: -1,
connectEnd: -1,
requestStart: -1,
responseStart: -1,
responseEnd: -1
};
}
url() {
return this._fallbackOverrides.url || this._initializer.url;
}
resourceType() {
return this._initializer.resourceType;
}
method() {
return this._fallbackOverrides.method || this._initializer.method;
}
postData() {
var _this$_fallbackOverri;
return ((_this$_fallbackOverri = this._fallbackOverrides.postDataBuffer) === null || _this$_fallbackOverri === void 0 ? void 0 : _this$_fallbackOverri.toString('utf-8')) || null;
}
postDataBuffer() {
return this._fallbackOverrides.postDataBuffer || null;
}
postDataJSON() {
const postData = this.postData();
if (!postData) return null;
const contentType = this.headers()['content-type'];
if (contentType === 'application/x-www-form-urlencoded') {
const entries = {};
const parsed = new _url.URLSearchParams(postData);
for (const [k, v] of parsed.entries()) entries[k] = v;
return entries;
}
try {
return JSON.parse(postData);
} catch (e) {
throw new Error('POST data is not a valid JSON object: ' + postData);
}
}
/**
* @deprecated
*/
headers() {
if (this._fallbackOverrides.headers) return RawHeaders._fromHeadersObjectLossy(this._fallbackOverrides.headers).headers();
return this._provisionalHeaders.headers();
}
_context() {
// TODO: make sure this works for service worker requests.
return this.frame().page().context();
}
_actualHeaders() {
if (this._fallbackOverrides.headers) return Promise.resolve(RawHeaders._fromHeadersObjectLossy(this._fallbackOverrides.headers));
if (!this._actualHeadersPromise) {
this._actualHeadersPromise = this._wrapApiCall(async () => {
return new RawHeaders((await this._channel.rawRequestHeaders()).headers);
});
}
return this._actualHeadersPromise;
}
async allHeaders() {
return (await this._actualHeaders()).headers();
}
async headersArray() {
return (await this._actualHeaders()).headersArray();
}
async headerValue(name) {
return (await this._actualHeaders()).get(name);
}
async response() {
return Response.fromNullable((await this._channel.response()).response);
}
async _internalResponse() {
return this._wrapApiCall(async () => {
return Response.fromNullable((await this._channel.response()).response);
}, true);
}
frame() {
if (!this._initializer.frame) {
(0, _utils.assert)(this.serviceWorker());
throw new Error('Service Worker requests do not have an associated frame.');
}
return _frame.Frame.from(this._initializer.frame);
}
serviceWorker() {
return this._initializer.serviceWorker ? _worker.Worker.from(this._initializer.serviceWorker) : null;
}
isNavigationRequest() {
return this._initializer.isNavigationRequest;
}
redirectedFrom() {
return this._redirectedFrom;
}
redirectedTo() {
return this._redirectedTo;
}
failure() {
if (this._failureText === null) return null;
return {
errorText: this._failureText
};
}
timing() {
return this._timing;
}
async sizes() {
const response = await this.response();
if (!response) throw new Error('Unable to fetch sizes for failed request');
return (await response._channel.sizes()).sizes;
}
_setResponseEndTiming(responseEndTiming) {
this._timing.responseEnd = responseEndTiming;
if (this._timing.responseStart === -1) this._timing.responseStart = responseEndTiming;
}
_finalRequest() {
return this._redirectedTo ? this._redirectedTo._finalRequest() : this;
}
_applyFallbackOverrides(overrides) {
if (overrides.url) this._fallbackOverrides.url = overrides.url;
if (overrides.method) this._fallbackOverrides.method = overrides.method;
if (overrides.headers) this._fallbackOverrides.headers = overrides.headers;
if ((0, _utils.isString)(overrides.postData)) this._fallbackOverrides.postDataBuffer = Buffer.from(overrides.postData, 'utf-8');else if (overrides.postData instanceof Buffer) this._fallbackOverrides.postDataBuffer = overrides.postData;else if (overrides.postData) this._fallbackOverrides.postDataBuffer = Buffer.from(JSON.stringify(overrides.postData), 'utf-8');
}
_fallbackOverridesForContinue() {
return this._fallbackOverrides;
}
_targetClosedScope() {
var _this$serviceWorker, _this$frame$_page;
return ((_this$serviceWorker = this.serviceWorker()) === null || _this$serviceWorker === void 0 ? void 0 : _this$serviceWorker._closedScope) || ((_this$frame$_page = this.frame()._page) === null || _this$frame$_page === void 0 ? void 0 : _this$frame$_page._closedOrCrashedScope) || new _manualPromise.LongStandingScope();
}
}
exports.Request = Request;
class Route extends _channelOwner.ChannelOwner {
static from(route) {
return route._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._handlingPromise = null;
}
request() {
return Request.from(this._initializer.request);
}
_raceWithTargetClose(promise) {
// When page closes or crashes, we catch any potential rejects from this Route.
// Note that page could be missing when routing popup's initial request that
// does not have a Page initialized just yet.
return this.request()._targetClosedScope().safeRace(promise);
}
_startHandling() {
this._handlingPromise = new _manualPromise.ManualPromise();
return this._handlingPromise;
}
async fallback(options = {}) {
this._checkNotHandled();
this.request()._applyFallbackOverrides(options);
this._reportHandled(false);
}
async abort(errorCode) {
this._checkNotHandled();
await this._raceWithTargetClose(this._channel.abort({
requestUrl: this.request()._initializer.url,
errorCode
}));
this._reportHandled(true);
}
async _redirectNavigationRequest(url) {
this._checkNotHandled();
await this._raceWithTargetClose(this._channel.redirectNavigationRequest({
url
}));
this._reportHandled(true);
}
async fetch(options = {}) {
return await this._wrapApiCall(async () => {
const context = this.request()._context();
return context.request._innerFetch({
request: this.request(),
data: options.postData,
...options
});
});
}
async fulfill(options = {}) {
this._checkNotHandled();
await this._wrapApiCall(async () => {
await this._innerFulfill(options);
this._reportHandled(true);
});
}
async _innerFulfill(options = {}) {
let fetchResponseUid;
let {
status: statusOption,
headers: headersOption,
body
} = options;
if (options.json !== undefined) {
(0, _utils.assert)(options.body === undefined, 'Can specify either body or json parameters');
body = JSON.stringify(options.json);
}
if (options.response instanceof _fetch.APIResponse) {
var _statusOption, _headersOption;
(_statusOption = statusOption) !== null && _statusOption !== void 0 ? _statusOption : statusOption = options.response.status();
(_headersOption = headersOption) !== null && _headersOption !== void 0 ? _headersOption : headersOption = options.response.headers();
if (body === undefined && options.path === undefined) {
if (options.response._request._connection === this._connection) fetchResponseUid = options.response._fetchUid();else body = await options.response.body();
}
}
let isBase64 = false;
let length = 0;
if (options.path) {
const buffer = await _fs.default.promises.readFile(options.path);
body = buffer.toString('base64');
isBase64 = true;
length = buffer.length;
} else if ((0, _utils.isString)(body)) {
isBase64 = false;
length = Buffer.byteLength(body);
} else if (body) {
length = body.length;
body = body.toString('base64');
isBase64 = true;
}
const headers = {};
for (const header of Object.keys(headersOption || {})) headers[header.toLowerCase()] = String(headersOption[header]);
if (options.contentType) headers['content-type'] = String(options.contentType);else if (options.json) headers['content-type'] = 'application/json';else if (options.path) headers['content-type'] = _utilsBundle.mime.getType(options.path) || 'application/octet-stream';
if (length && !('content-length' in headers)) headers['content-length'] = String(length);
await this._raceWithTargetClose(this._channel.fulfill({
requestUrl: this.request()._initializer.url,
status: statusOption || 200,
headers: (0, _utils.headersObjectToArray)(headers),
body,
isBase64,
fetchResponseUid
}));
}
async continue(options = {}) {
this._checkNotHandled();
this.request()._applyFallbackOverrides(options);
await this._innerContinue();
this._reportHandled(true);
}
_checkNotHandled() {
if (!this._handlingPromise) throw new Error('Route is already handled!');
}
_reportHandled(done) {
const chain = this._handlingPromise;
this._handlingPromise = null;
chain.resolve(done);
}
async _innerContinue(internal = false) {
const options = this.request()._fallbackOverridesForContinue();
return await this._wrapApiCall(async () => {
await this._raceWithTargetClose(this._channel.continue({
requestUrl: this.request()._initializer.url,
url: options.url,
method: options.method,
headers: options.headers ? (0, _utils.headersObjectToArray)(options.headers) : undefined,
postData: options.postDataBuffer,
isFallback: internal
}));
}, !!internal);
}
}
exports.Route = Route;
class Response extends _channelOwner.ChannelOwner {
static from(response) {
return response._object;
}
static fromNullable(response) {
return response ? Response.from(response) : null;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._provisionalHeaders = void 0;
this._actualHeadersPromise = void 0;
this._request = void 0;
this._finishedPromise = new _manualPromise.ManualPromise();
this._provisionalHeaders = new RawHeaders(initializer.headers);
this._request = Request.from(this._initializer.request);
Object.assign(this._request._timing, this._initializer.timing);
}
url() {
return this._initializer.url;
}
ok() {
// Status 0 is for file:// URLs
return this._initializer.status === 0 || this._initializer.status >= 200 && this._initializer.status <= 299;
}
status() {
return this._initializer.status;
}
statusText() {
return this._initializer.statusText;
}
fromServiceWorker() {
return this._initializer.fromServiceWorker;
}
/**
* @deprecated
*/
headers() {
return this._provisionalHeaders.headers();
}
async _actualHeaders() {
if (!this._actualHeadersPromise) {
this._actualHeadersPromise = (async () => {
return new RawHeaders((await this._channel.rawResponseHeaders()).headers);
})();
}
return this._actualHeadersPromise;
}
async allHeaders() {
return (await this._actualHeaders()).headers();
}
async headersArray() {
return (await this._actualHeaders()).headersArray().slice();
}
async headerValue(name) {
return (await this._actualHeaders()).get(name);
}
async headerValues(name) {
return (await this._actualHeaders()).getAll(name);
}
async finished() {
return this.request()._targetClosedScope().race(this._finishedPromise);
}
async body() {
return (await this._channel.body()).binary;
}
async text() {
const content = await this.body();
return content.toString('utf8');
}
async json() {
const content = await this.text();
return JSON.parse(content);
}
request() {
return this._request;
}
frame() {
return this._request.frame();
}
async serverAddr() {
return (await this._channel.serverAddr()).value || null;
}
async securityDetails() {
return (await this._channel.securityDetails()).value || null;
}
}
exports.Response = Response;
class WebSocket extends _channelOwner.ChannelOwner {
static from(webSocket) {
return webSocket._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._page = void 0;
this._isClosed = void 0;
this._isClosed = false;
this._page = parent;
this._channel.on('frameSent', event => {
if (event.opcode === 1) this.emit(_events.Events.WebSocket.FrameSent, {
payload: event.data
});else if (event.opcode === 2) this.emit(_events.Events.WebSocket.FrameSent, {
payload: Buffer.from(event.data, 'base64')
});
});
this._channel.on('frameReceived', event => {
if (event.opcode === 1) this.emit(_events.Events.WebSocket.FrameReceived, {
payload: event.data
});else if (event.opcode === 2) this.emit(_events.Events.WebSocket.FrameReceived, {
payload: Buffer.from(event.data, 'base64')
});
});
this._channel.on('socketError', ({
error
}) => this.emit(_events.Events.WebSocket.Error, error));
this._channel.on('close', () => {
this._isClosed = true;
this.emit(_events.Events.WebSocket.Close, this);
});
}
url() {
return this._initializer.url;
}
isClosed() {
return this._isClosed;
}
async waitForEvent(event, optionsOrPredicate = {}) {
return this._wrapApiCall(async () => {
const timeout = this._page._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
const waiter = _waiter.Waiter.createForEvent(this, event);
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
if (event !== _events.Events.WebSocket.Error) waiter.rejectOnEvent(this, _events.Events.WebSocket.Error, new Error('Socket error'));
if (event !== _events.Events.WebSocket.Close) waiter.rejectOnEvent(this, _events.Events.WebSocket.Close, new Error('Socket closed'));
waiter.rejectOnEvent(this._page, _events.Events.Page.Close, new Error('Page closed'));
const result = await waiter.waitForEvent(this, event, predicate);
waiter.dispose();
return result;
});
}
}
exports.WebSocket = WebSocket;
function validateHeaders(headers) {
for (const key of Object.keys(headers)) {
const value = headers[key];
if (!Object.is(value, undefined) && !(0, _utils.isString)(value)) throw new Error(`Expected value of header "${key}" to be String, but "${typeof value}" is found.`);
}
}
class RouteHandler {
constructor(baseURL, url, handler, times = Number.MAX_SAFE_INTEGER) {
this.handledCount = 0;
this._baseURL = void 0;
this._times = void 0;
this.url = void 0;
this.handler = void 0;
this._baseURL = baseURL;
this._times = times;
this.url = url;
this.handler = handler;
}
static prepareInterceptionPatterns(handlers) {
const patterns = [];
let all = false;
for (const handler of handlers) {
if ((0, _utils.isString)(handler.url)) patterns.push({
glob: handler.url
});else if ((0, _utils.isRegExp)(handler.url)) patterns.push({
regexSource: handler.url.source,
regexFlags: handler.url.flags
});else all = true;
}
if (all) return [{
glob: '**/*'
}];
return patterns;
}
matches(requestURL) {
return (0, _network.urlMatches)(this._baseURL, requestURL, this.url);
}
async handle(route) {
++this.handledCount;
const handledPromise = route._startHandling();
// Extract handler into a variable to avoid [RouteHandler.handler] in the stack.
const handler = this.handler;
const [handled] = await Promise.all([handledPromise, handler(route, route.request())]);
return handled;
}
willExpire() {
return this.handledCount + 1 >= this._times;
}
}
exports.RouteHandler = RouteHandler;
class RawHeaders {
static _fromHeadersObjectLossy(headers) {
const headersArray = Object.entries(headers).map(([name, value]) => ({
name,
value
})).filter(header => header.value !== undefined);
return new RawHeaders(headersArray);
}
constructor(headers) {
this._headersArray = void 0;
this._headersMap = new _multimap.MultiMap();
this._headersArray = headers;
for (const header of headers) this._headersMap.set(header.name.toLowerCase(), header.value);
}
get(name) {
const values = this.getAll(name);
if (!values || !values.length) return null;
return values.join(name.toLowerCase() === 'set-cookie' ? '\n' : ', ');
}
getAll(name) {
return [...this._headersMap.get(name.toLowerCase())];
}
headers() {
const result = {};
for (const name of this._headersMap.keys()) result[name] = this.get(name);
return result;
}
headersArray() {
return this._headersArray;
}
}
exports.RawHeaders = RawHeaders;

View File

@ -1,655 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Page = exports.BindingCall = void 0;
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
var _errors = require("../common/errors");
var _network = require("../utils/network");
var _timeoutSettings = require("../common/timeoutSettings");
var _serializers = require("../protocol/serializers");
var _utils = require("../utils");
var _fileUtils = require("../utils/fileUtils");
var _accessibility = require("./accessibility");
var _artifact = require("./artifact");
var _channelOwner = require("./channelOwner");
var _clientHelper = require("./clientHelper");
var _coverage = require("./coverage");
var _download = require("./download");
var _elementHandle = require("./elementHandle");
var _events = require("./events");
var _fileChooser = require("./fileChooser");
var _frame = require("./frame");
var _input = require("./input");
var _jsHandle = require("./jsHandle");
var _network2 = require("./network");
var _video = require("./video");
var _waiter = require("./waiter");
var _worker = require("./worker");
var _harRouter = require("./harRouter");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright 2017 Google Inc. All rights reserved.
* Modifications copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Page extends _channelOwner.ChannelOwner {
static from(page) {
return page._object;
}
static fromNullable(page) {
return page ? Page.from(page) : null;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._browserContext = void 0;
this._ownedContext = void 0;
this._mainFrame = void 0;
this._frames = new Set();
this._workers = new Set();
this._closed = false;
this._closedOrCrashedScope = new _utils.LongStandingScope();
this._viewportSize = void 0;
this._routes = [];
this.accessibility = void 0;
this.coverage = void 0;
this.keyboard = void 0;
this.mouse = void 0;
this.request = void 0;
this.touchscreen = void 0;
this._bindings = new Map();
this._timeoutSettings = void 0;
this._video = null;
this._opener = void 0;
this._browserContext = parent;
this._timeoutSettings = new _timeoutSettings.TimeoutSettings(this._browserContext._timeoutSettings);
this.accessibility = new _accessibility.Accessibility(this._channel);
this.keyboard = new _input.Keyboard(this);
this.mouse = new _input.Mouse(this);
this.request = this._browserContext.request;
this.touchscreen = new _input.Touchscreen(this);
this._mainFrame = _frame.Frame.from(initializer.mainFrame);
this._mainFrame._page = this;
this._frames.add(this._mainFrame);
this._viewportSize = initializer.viewportSize || null;
this._closed = initializer.isClosed;
this._opener = Page.fromNullable(initializer.opener);
this._channel.on('bindingCall', ({
binding
}) => this._onBinding(BindingCall.from(binding)));
this._channel.on('close', () => this._onClose());
this._channel.on('crash', () => this._onCrash());
this._channel.on('download', ({
url,
suggestedFilename,
artifact
}) => {
const artifactObject = _artifact.Artifact.from(artifact);
this.emit(_events.Events.Page.Download, new _download.Download(this, url, suggestedFilename, artifactObject));
});
this._channel.on('fileChooser', ({
element,
isMultiple
}) => this.emit(_events.Events.Page.FileChooser, new _fileChooser.FileChooser(this, _elementHandle.ElementHandle.from(element), isMultiple)));
this._channel.on('frameAttached', ({
frame
}) => this._onFrameAttached(_frame.Frame.from(frame)));
this._channel.on('frameDetached', ({
frame
}) => this._onFrameDetached(_frame.Frame.from(frame)));
this._channel.on('pageError', ({
error
}) => this.emit(_events.Events.Page.PageError, (0, _serializers.parseError)(error)));
this._channel.on('route', ({
route
}) => this._onRoute(_network2.Route.from(route)));
this._channel.on('video', ({
artifact
}) => {
const artifactObject = _artifact.Artifact.from(artifact);
this._forceVideo()._artifactReady(artifactObject);
});
this._channel.on('webSocket', ({
webSocket
}) => this.emit(_events.Events.Page.WebSocket, _network2.WebSocket.from(webSocket)));
this._channel.on('worker', ({
worker
}) => this._onWorker(_worker.Worker.from(worker)));
this.coverage = new _coverage.Coverage(this._channel);
this.once(_events.Events.Page.Close, () => this._closedOrCrashedScope.close(_errors.kBrowserOrContextClosedError));
this.once(_events.Events.Page.Crash, () => this._closedOrCrashedScope.close(_errors.kBrowserOrContextClosedError));
this._setEventToSubscriptionMapping(new Map([[_events.Events.Page.Console, 'console'], [_events.Events.Page.Dialog, 'dialog'], [_events.Events.Page.Request, 'request'], [_events.Events.Page.Response, 'response'], [_events.Events.Page.RequestFinished, 'requestFinished'], [_events.Events.Page.RequestFailed, 'requestFailed'], [_events.Events.Page.FileChooser, 'fileChooser']]));
}
_onFrameAttached(frame) {
frame._page = this;
this._frames.add(frame);
if (frame._parentFrame) frame._parentFrame._childFrames.add(frame);
this.emit(_events.Events.Page.FrameAttached, frame);
}
_onFrameDetached(frame) {
this._frames.delete(frame);
frame._detached = true;
if (frame._parentFrame) frame._parentFrame._childFrames.delete(frame);
this.emit(_events.Events.Page.FrameDetached, frame);
}
async _onRoute(route) {
const routeHandlers = this._routes.slice();
for (const routeHandler of routeHandlers) {
if (!routeHandler.matches(route.request().url())) continue;
if (routeHandler.willExpire()) this._routes.splice(this._routes.indexOf(routeHandler), 1);
const handled = await routeHandler.handle(route);
if (!this._routes.length) this._wrapApiCall(() => this._updateInterceptionPatterns(), true).catch(() => {});
if (handled) return;
}
await this._browserContext._onRoute(route);
}
async _onBinding(bindingCall) {
const func = this._bindings.get(bindingCall._initializer.name);
if (func) {
await bindingCall.call(func);
return;
}
await this._browserContext._onBinding(bindingCall);
}
_onWorker(worker) {
this._workers.add(worker);
worker._page = this;
this.emit(_events.Events.Page.Worker, worker);
}
_onClose() {
this._closed = true;
this._browserContext._pages.delete(this);
this._browserContext._backgroundPages.delete(this);
this.emit(_events.Events.Page.Close, this);
}
_onCrash() {
this.emit(_events.Events.Page.Crash, this);
}
context() {
return this._browserContext;
}
async opener() {
if (!this._opener || this._opener.isClosed()) return null;
return this._opener;
}
mainFrame() {
return this._mainFrame;
}
frame(frameSelector) {
const name = (0, _utils.isString)(frameSelector) ? frameSelector : frameSelector.name;
const url = (0, _utils.isObject)(frameSelector) ? frameSelector.url : undefined;
(0, _utils.assert)(name || url, 'Either name or url matcher should be specified');
return this.frames().find(f => {
if (name) return f.name() === name;
return (0, _network.urlMatches)(this._browserContext._options.baseURL, f.url(), url);
}) || null;
}
frames() {
return [...this._frames];
}
setDefaultNavigationTimeout(timeout) {
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
this._wrapApiCall(async () => {
this._channel.setDefaultNavigationTimeoutNoReply({
timeout
}).catch(() => {});
}, true);
}
setDefaultTimeout(timeout) {
this._timeoutSettings.setDefaultTimeout(timeout);
this._wrapApiCall(async () => {
this._channel.setDefaultTimeoutNoReply({
timeout
}).catch(() => {});
}, true);
}
_forceVideo() {
if (!this._video) this._video = new _video.Video(this, this._connection);
return this._video;
}
video() {
// Note: we are creating Video object lazily, because we do not know
// BrowserContextOptions when constructing the page - it is assigned
// too late during launchPersistentContext.
if (!this._browserContext._options.recordVideo) return null;
return this._forceVideo();
}
async $(selector, options) {
return this._mainFrame.$(selector, options);
}
async waitForSelector(selector, options) {
return this._mainFrame.waitForSelector(selector, options);
}
async dispatchEvent(selector, type, eventInit, options) {
return this._mainFrame.dispatchEvent(selector, type, eventInit, options);
}
async evaluateHandle(pageFunction, arg) {
(0, _jsHandle.assertMaxArguments)(arguments.length, 2);
return this._mainFrame.evaluateHandle(pageFunction, arg);
}
async $eval(selector, pageFunction, arg) {
(0, _jsHandle.assertMaxArguments)(arguments.length, 3);
return this._mainFrame.$eval(selector, pageFunction, arg);
}
async $$eval(selector, pageFunction, arg) {
(0, _jsHandle.assertMaxArguments)(arguments.length, 3);
return this._mainFrame.$$eval(selector, pageFunction, arg);
}
async $$(selector) {
return this._mainFrame.$$(selector);
}
async addScriptTag(options = {}) {
return this._mainFrame.addScriptTag(options);
}
async addStyleTag(options = {}) {
return this._mainFrame.addStyleTag(options);
}
async exposeFunction(name, callback) {
await this._channel.exposeBinding({
name
});
const binding = (source, ...args) => callback(...args);
this._bindings.set(name, binding);
}
async exposeBinding(name, callback, options = {}) {
await this._channel.exposeBinding({
name,
needsHandle: options.handle
});
this._bindings.set(name, callback);
}
async setExtraHTTPHeaders(headers) {
(0, _network2.validateHeaders)(headers);
await this._channel.setExtraHTTPHeaders({
headers: (0, _utils.headersObjectToArray)(headers)
});
}
url() {
return this._mainFrame.url();
}
async content() {
return this._mainFrame.content();
}
async setContent(html, options) {
return this._mainFrame.setContent(html, options);
}
async goto(url, options) {
return this._mainFrame.goto(url, options);
}
async reload(options = {}) {
const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
return _network2.Response.fromNullable((await this._channel.reload({
...options,
waitUntil
})).response);
}
async waitForLoadState(state, options) {
return this._mainFrame.waitForLoadState(state, options);
}
async waitForNavigation(options) {
return this._mainFrame.waitForNavigation(options);
}
async waitForURL(url, options) {
return this._mainFrame.waitForURL(url, options);
}
async waitForRequest(urlOrPredicate, options = {}) {
const predicate = request => {
if ((0, _utils.isString)(urlOrPredicate) || (0, _utils.isRegExp)(urlOrPredicate)) return (0, _network.urlMatches)(this._browserContext._options.baseURL, request.url(), urlOrPredicate);
return urlOrPredicate(request);
};
const trimmedUrl = trimUrl(urlOrPredicate);
const logLine = trimmedUrl ? `waiting for request ${trimmedUrl}` : undefined;
return this._waitForEvent(_events.Events.Page.Request, {
predicate,
timeout: options.timeout
}, logLine);
}
async waitForResponse(urlOrPredicate, options = {}) {
const predicate = response => {
if ((0, _utils.isString)(urlOrPredicate) || (0, _utils.isRegExp)(urlOrPredicate)) return (0, _network.urlMatches)(this._browserContext._options.baseURL, response.url(), urlOrPredicate);
return urlOrPredicate(response);
};
const trimmedUrl = trimUrl(urlOrPredicate);
const logLine = trimmedUrl ? `waiting for response ${trimmedUrl}` : undefined;
return this._waitForEvent(_events.Events.Page.Response, {
predicate,
timeout: options.timeout
}, logLine);
}
async waitForEvent(event, optionsOrPredicate = {}) {
return this._waitForEvent(event, optionsOrPredicate, `waiting for event "${event}"`);
}
async _waitForEvent(event, optionsOrPredicate, logLine) {
return this._wrapApiCall(async () => {
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
const waiter = _waiter.Waiter.createForEvent(this, event);
if (logLine) waiter.log(logLine);
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
if (event !== _events.Events.Page.Crash) waiter.rejectOnEvent(this, _events.Events.Page.Crash, new Error('Page crashed'));
if (event !== _events.Events.Page.Close) waiter.rejectOnEvent(this, _events.Events.Page.Close, new Error('Page closed'));
const result = await waiter.waitForEvent(this, event, predicate);
waiter.dispose();
return result;
});
}
async goBack(options = {}) {
const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
return _network2.Response.fromNullable((await this._channel.goBack({
...options,
waitUntil
})).response);
}
async goForward(options = {}) {
const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
return _network2.Response.fromNullable((await this._channel.goForward({
...options,
waitUntil
})).response);
}
async emulateMedia(options = {}) {
await this._channel.emulateMedia({
media: options.media === null ? 'no-override' : options.media,
colorScheme: options.colorScheme === null ? 'no-override' : options.colorScheme,
reducedMotion: options.reducedMotion === null ? 'no-override' : options.reducedMotion,
forcedColors: options.forcedColors === null ? 'no-override' : options.forcedColors
});
}
async setViewportSize(viewportSize) {
this._viewportSize = viewportSize;
await this._channel.setViewportSize({
viewportSize
});
}
viewportSize() {
return this._viewportSize;
}
async evaluate(pageFunction, arg) {
(0, _jsHandle.assertMaxArguments)(arguments.length, 2);
return this._mainFrame.evaluate(pageFunction, arg);
}
async addInitScript(script, arg) {
const source = await (0, _clientHelper.evaluationScript)(script, arg);
await this._channel.addInitScript({
source
});
}
async route(url, handler, options = {}) {
this._routes.unshift(new _network2.RouteHandler(this._browserContext._options.baseURL, url, handler, options.times));
await this._updateInterceptionPatterns();
}
async routeFromHAR(har, options = {}) {
if (options.update) {
await this._browserContext._recordIntoHAR(har, this, options);
return;
}
const harRouter = await _harRouter.HarRouter.create(this._connection.localUtils(), har, options.notFound || 'abort', {
urlMatch: options.url
});
harRouter.addPageRoute(this);
}
async unroute(url, handler) {
this._routes = this._routes.filter(route => !(0, _utils.urlMatchesEqual)(route.url, url) || handler && route.handler !== handler);
await this._updateInterceptionPatterns();
}
async _updateInterceptionPatterns() {
const patterns = _network2.RouteHandler.prepareInterceptionPatterns(this._routes);
await this._channel.setNetworkInterceptionPatterns({
patterns
});
}
async screenshot(options = {}) {
const copy = {
...options,
mask: undefined
};
if (!copy.type) copy.type = (0, _elementHandle.determineScreenshotType)(options);
if (options.mask) {
copy.mask = options.mask.map(locator => ({
frame: locator._frame._channel,
selector: locator._selector
}));
}
const result = await this._channel.screenshot(copy);
if (options.path) {
await (0, _fileUtils.mkdirIfNeeded)(options.path);
await _fs.default.promises.writeFile(options.path, result.binary);
}
return result.binary;
}
async _expectScreenshot(options) {
var _options$screenshotOp, _options$screenshotOp2;
const mask = (_options$screenshotOp = options.screenshotOptions) !== null && _options$screenshotOp !== void 0 && _options$screenshotOp.mask ? (_options$screenshotOp2 = options.screenshotOptions) === null || _options$screenshotOp2 === void 0 ? void 0 : _options$screenshotOp2.mask.map(locator => ({
frame: locator._frame._channel,
selector: locator._selector
})) : undefined;
const locator = options.locator ? {
frame: options.locator._frame._channel,
selector: options.locator._selector
} : undefined;
return await this._channel.expectScreenshot({
...options,
isNot: !!options.isNot,
locator,
screenshotOptions: {
...options.screenshotOptions,
mask
}
});
}
async title() {
return this._mainFrame.title();
}
async bringToFront() {
await this._channel.bringToFront();
}
async close(options = {
runBeforeUnload: undefined
}) {
try {
if (this._ownedContext) await this._ownedContext.close();else await this._channel.close(options);
} catch (e) {
if ((0, _errors.isSafeCloseError)(e) && !options.runBeforeUnload) return;
throw e;
}
}
isClosed() {
return this._closed;
}
async click(selector, options) {
return this._mainFrame.click(selector, options);
}
async dragAndDrop(source, target, options) {
return this._mainFrame.dragAndDrop(source, target, options);
}
async dblclick(selector, options) {
return this._mainFrame.dblclick(selector, options);
}
async tap(selector, options) {
return this._mainFrame.tap(selector, options);
}
async fill(selector, value, options) {
return this._mainFrame.fill(selector, value, options);
}
locator(selector, options) {
return this.mainFrame().locator(selector, options);
}
getByTestId(testId) {
return this.mainFrame().getByTestId(testId);
}
getByAltText(text, options) {
return this.mainFrame().getByAltText(text, options);
}
getByLabel(text, options) {
return this.mainFrame().getByLabel(text, options);
}
getByPlaceholder(text, options) {
return this.mainFrame().getByPlaceholder(text, options);
}
getByText(text, options) {
return this.mainFrame().getByText(text, options);
}
getByTitle(text, options) {
return this.mainFrame().getByTitle(text, options);
}
getByRole(role, options = {}) {
return this.mainFrame().getByRole(role, options);
}
frameLocator(selector) {
return this.mainFrame().frameLocator(selector);
}
async focus(selector, options) {
return this._mainFrame.focus(selector, options);
}
async textContent(selector, options) {
return this._mainFrame.textContent(selector, options);
}
async innerText(selector, options) {
return this._mainFrame.innerText(selector, options);
}
async innerHTML(selector, options) {
return this._mainFrame.innerHTML(selector, options);
}
async getAttribute(selector, name, options) {
return this._mainFrame.getAttribute(selector, name, options);
}
async inputValue(selector, options) {
return this._mainFrame.inputValue(selector, options);
}
async isChecked(selector, options) {
return this._mainFrame.isChecked(selector, options);
}
async isDisabled(selector, options) {
return this._mainFrame.isDisabled(selector, options);
}
async isEditable(selector, options) {
return this._mainFrame.isEditable(selector, options);
}
async isEnabled(selector, options) {
return this._mainFrame.isEnabled(selector, options);
}
async isHidden(selector, options) {
return this._mainFrame.isHidden(selector, options);
}
async isVisible(selector, options) {
return this._mainFrame.isVisible(selector, options);
}
async hover(selector, options) {
return this._mainFrame.hover(selector, options);
}
async selectOption(selector, values, options) {
return this._mainFrame.selectOption(selector, values, options);
}
async setInputFiles(selector, files, options) {
return this._mainFrame.setInputFiles(selector, files, options);
}
async type(selector, text, options) {
return this._mainFrame.type(selector, text, options);
}
async press(selector, key, options) {
return this._mainFrame.press(selector, key, options);
}
async check(selector, options) {
return this._mainFrame.check(selector, options);
}
async uncheck(selector, options) {
return this._mainFrame.uncheck(selector, options);
}
async setChecked(selector, checked, options) {
return this._mainFrame.setChecked(selector, checked, options);
}
async waitForTimeout(timeout) {
return this._mainFrame.waitForTimeout(timeout);
}
async waitForFunction(pageFunction, arg, options) {
return this._mainFrame.waitForFunction(pageFunction, arg, options);
}
workers() {
return [...this._workers];
}
async pause() {
var _this$_instrumentatio;
if (require('inspector').url()) return;
const defaultNavigationTimeout = this._browserContext._timeoutSettings.defaultNavigationTimeout();
const defaultTimeout = this._browserContext._timeoutSettings.defaultTimeout();
this._browserContext.setDefaultNavigationTimeout(0);
this._browserContext.setDefaultTimeout(0);
(_this$_instrumentatio = this._instrumentation) === null || _this$_instrumentatio === void 0 ? void 0 : _this$_instrumentatio.onWillPause();
await this._closedOrCrashedScope.safeRace(this.context()._channel.pause());
this._browserContext.setDefaultNavigationTimeout(defaultNavigationTimeout);
this._browserContext.setDefaultTimeout(defaultTimeout);
}
async pdf(options = {}) {
const transportOptions = {
...options
};
if (transportOptions.margin) transportOptions.margin = {
...transportOptions.margin
};
if (typeof options.width === 'number') transportOptions.width = options.width + 'px';
if (typeof options.height === 'number') transportOptions.height = options.height + 'px';
for (const margin of ['top', 'right', 'bottom', 'left']) {
const index = margin;
if (options.margin && typeof options.margin[index] === 'number') transportOptions.margin[index] = transportOptions.margin[index] + 'px';
}
const result = await this._channel.pdf(transportOptions);
if (options.path) {
await _fs.default.promises.mkdir(_path.default.dirname(options.path), {
recursive: true
});
await _fs.default.promises.writeFile(options.path, result.pdf);
}
return result.pdf;
}
}
exports.Page = Page;
class BindingCall extends _channelOwner.ChannelOwner {
static from(channel) {
return channel._object;
}
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
}
async call(func) {
try {
const frame = _frame.Frame.from(this._initializer.frame);
const source = {
context: frame._page.context(),
page: frame._page,
frame
};
let result;
if (this._initializer.handle) result = await func(source, _jsHandle.JSHandle.from(this._initializer.handle));else result = await func(source, ...this._initializer.args.map(_jsHandle.parseResult));
this._channel.resolve({
result: (0, _jsHandle.serializeArgument)(result)
}).catch(() => {});
} catch (e) {
this._channel.reject({
error: (0, _serializers.serializeError)(e)
}).catch(() => {});
}
}
}
exports.BindingCall = BindingCall;
function trimEnd(s) {
if (s.length > 50) s = s.substring(0, 50) + '\u2026';
return s;
}
function trimUrl(param) {
if ((0, _utils.isRegExp)(param)) return `/${trimEnd(param.source)}/${param.flags}`;
if ((0, _utils.isString)(param)) return `"${trimEnd(param)}"`;
}

View File

@ -1,77 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Playwright = void 0;
var _errors = require("../common/errors");
var _android = require("./android");
var _browserType = require("./browserType");
var _channelOwner = require("./channelOwner");
var _electron = require("./electron");
var _fetch = require("./fetch");
var _selectors = require("./selectors");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Playwright extends _channelOwner.ChannelOwner {
constructor(parent, type, guid, initializer) {
super(parent, type, guid, initializer);
this._android = void 0;
this._electron = void 0;
this.chromium = void 0;
this.firefox = void 0;
this.webkit = void 0;
this.devices = void 0;
this.selectors = void 0;
this.request = void 0;
this.errors = void 0;
this.request = new _fetch.APIRequest(this);
this.chromium = _browserType.BrowserType.from(initializer.chromium);
this.chromium._playwright = this;
this.firefox = _browserType.BrowserType.from(initializer.firefox);
this.firefox._playwright = this;
this.webkit = _browserType.BrowserType.from(initializer.webkit);
this.webkit._playwright = this;
this._android = _android.Android.from(initializer.android);
this._electron = _electron.Electron.from(initializer.electron);
this.devices = {};
for (const {
name,
descriptor
} of initializer.deviceDescriptors) this.devices[name] = descriptor;
this.selectors = new _selectors.Selectors();
this.errors = {
TimeoutError: _errors.TimeoutError
};
const selectorsOwner = _selectors.SelectorsOwner.from(initializer.selectors);
this.selectors._addChannel(selectorsOwner);
this._connection.on('close', () => {
this.selectors._removeChannel(selectorsOwner);
});
global._playwrightInstance = this;
}
_setSelectors(selectors) {
const selectorsOwner = _selectors.SelectorsOwner.from(this._initializer.selectors);
this.selectors._removeChannel(selectorsOwner);
this.selectors = selectors;
this.selectors._addChannel(selectorsOwner);
}
static from(channel) {
return channel._object;
}
}
exports.Playwright = Playwright;

View File

@ -1,67 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SelectorsOwner = exports.Selectors = void 0;
var _clientHelper = require("./clientHelper");
var _channelOwner = require("./channelOwner");
var _locator = require("./locator");
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Selectors {
constructor() {
this._channels = new Set();
this._registrations = [];
}
async register(name, script, options = {}) {
const source = await (0, _clientHelper.evaluationScript)(script, undefined, false);
const params = {
...options,
name,
source
};
for (const channel of this._channels) await channel._channel.register(params);
this._registrations.push(params);
}
setTestIdAttribute(attributeName) {
(0, _locator.setTestIdAttribute)(attributeName);
for (const channel of this._channels) channel._channel.setTestIdAttributeName({
testIdAttributeName: attributeName
}).catch(() => {});
}
_addChannel(channel) {
this._channels.add(channel);
for (const params of this._registrations) {
// This should not fail except for connection closure, but just in case we catch.
channel._channel.register(params).catch(() => {});
channel._channel.setTestIdAttributeName({
testIdAttributeName: (0, _locator.testIdAttributeName)()
}).catch(() => {});
}
}
_removeChannel(channel) {
this._channels.delete(channel);
}
}
exports.Selectors = Selectors;
class SelectorsOwner extends _channelOwner.ChannelOwner {
static from(browser) {
return browser._object;
}
}
exports.SelectorsOwner = SelectorsOwner;

Some files were not shown because too many files have changed in this diff Show More