From 6c9961554f4c4aacde8b0185e15147b08ba50b3b Mon Sep 17 00:00:00 2001 From: titusfortner Date: Fri, 21 Jun 2024 16:23:31 -0500 Subject: [PATCH 01/11] Blog post - still needs examples links --- .../blog/2024/selenium-4-22-released.md | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 website_and_docs/content/blog/2024/selenium-4-22-released.md diff --git a/website_and_docs/content/blog/2024/selenium-4-22-released.md b/website_and_docs/content/blog/2024/selenium-4-22-released.md new file mode 100644 index 000000000000..10887bf3f48c --- /dev/null +++ b/website_and_docs/content/blog/2024/selenium-4-22-released.md @@ -0,0 +1,151 @@ +--- +title: "Selenium 4.22 Released!" +linkTitle: "Selenium 4.22 Released!" +date: 2024-05-16 +tags: ["selenium"] +categories: ["releases"] +author: Titus Fortner [@titusfortner](https://titusfortner.com) +description: > + Today we're happy to announce that Selenium 4.22 has been released! +--- + +We're very happy to announce the release of Selenium 4.22.0 for +Javascript, Ruby, Python, .NET, Java and the Grid! +Links to everything can be found on our [downloads page][downloads]. + +### Highlights + + * Selenium has at least [2.6 active users](https://plausible.io/manager.selenium.dev) in the last 30 days. 200k more than last month! + * All information we collect is publicly available. + * The numbers only represent users who have Selenium Manager enabled and are using Selenium v4.17 or greater. + * Python, Chrome and Windows all see the majority of use. +* Chrome DevTools support is now: v124, v125, and v126 (Firefox still uses v85 for all versions) +* The first implementations of the final BiDi API have rolled out. + +#### Noteworthy changes per language + + * Java + * Enabling BiDi can now be accomplished by calling `enableBiDi()` on an Options class instance. + * Video file name in Dynamic Grid can be seet with `se:videoName` capability. + * [See all changes](https://github.com/SeleniumHQ/selenium/blob/trunk/java/CHANGELOG) + +
+ + * JavaScript + * BiDi API for console logging and JavaScript errors has been implemented. + * Additional BiDi implementations. + * [See all changes](https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/node/selenium-webdriver/CHANGES.md) + +
+ + * .NET + * The .NET bindings have started to roll out asynchronous methods. + * The synchronous methods will still be supported, but they will call the async methods "under the hood." + * This release adds asynchronous methods to the Navigation class. + * [See all changes](https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/CHANGELOG) + +
+ + * Python + * This release implements a new way of working with Chrome Devtools Protocol + * The previous implementation requires async/await pattern, so it was not backwards compatible. + * The new implementation is backwards compatible and executes async code in separate threads. + * Updated the webkitgtk and wpewebkit driver implementations. + * Enabling BiDi can now be accomplished by setting the `enable_bidi()` property of an Options class instance to `True`. + * BiDi API for console logging and JavaScript errors has been implemented. + * [See all changes](https://github.com/SeleniumHQ/selenium/blob/trunk/py/CHANGES) + +
+ + * Ruby + * Implemented a toggle for BiDi and Classic implementations. + * BiDi API for console logging and JavaScript errors has been implemented. + * [See all changes](https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES) + + +
+ + * Rust + * Added the ability to stream logging information to stdout instead of after execution complete. + * Improved binary location on Windows with native Rust methods. + * [See all changes](https://github.com/SeleniumHQ/selenium/blob/trunk/rust/CHANGELOG.md) + +### Contributors + +**Special shout-out to everyone who helped the Selenium Team get this release out!** + +#### [Selenium](https://github.com/SeleniumHQ/selenium) + +
+
+
+{{< gh-user "https://api.github.com/users/3dprogramin" >}} +{{< gh-user "https://api.github.com/users/VietND96" >}} +{{< gh-user "https://api.github.com/users/aguspe" >}} +{{< gh-user "https://api.github.com/users/bgermann" >}} +{{< gh-user "https://api.github.com/users/Earlopain" >}} +{{< gh-user "https://api.github.com/users/iampopovich" >}} +{{< gh-user "https://api.github.com/users/millin" >}} +{{< gh-user "https://api.github.com/users/sbabcoc" >}} +{{< gh-user "https://api.github.com/users/vlad8x8" >}} +{{< gh-user "https://api.github.com/users/yuzawa-san" >}} +
+
+
+ + +#### [Selenium Docs & Website](https://github.com/SeleniumHQ/seleniumhq.github.io) + +
+
+
+{{< gh-user "https://api.github.com/users/alaahong" >}} +{{< gh-user "https://api.github.com/users/aguspe" >}} +{{< gh-user "https://api.github.com/users/digitalvoice-nz +{{< gh-user "https://api.github.com/users/josh-pinwheelapi +{{< gh-user "https://api.github.com/users/pallavigitwork" >}} +{{< gh-user "https://api.github.com/users/Pexpe" >}} +{{< gh-user "https://api.github.com/users/sangcnguyen" >}} +" >}} +
+
+
+ +#### [Docker Selenium](https://github.com/SeleniumHQ/docker-selenium) + +
+
+
+{{< gh-user "https://api.github.com/users/VietND96" >}} +
+
+
+ +#### [Selenium Team Members][team] + +**Thanks as well to all the team members who contributed to this release:** + +
+
+
+{{< gh-user "https://api.github.com/users/AutomatedTester" >}} +{{< gh-user "https://api.github.com/users/bonigarcia" >}} +{{< gh-user "https://api.github.com/users/diemol" >}} +{{< gh-user "https://api.github.com/users/harsha509" >}} +{{< gh-user "https://api.github.com/users/joerg1985" >}} +{{< gh-user "https://api.github.com/users/p0deje" >}} +{{< gh-user "https://api.github.com/users/pujagani" >}} +{{< gh-user "https://api.github.com/users/shs96c" >}} +{{< gh-user "https://api.github.com/users/titusfortner" >}} +
+
+
+ +Stay tuned for updates by following SeleniumHQ on [X (Formerly Twitter)](https://twitter.com/seleniumhq) or [LinkedIn](https://www.linkedin.com/company/selenium/)! + +Happy automating! + +[downloads]: /downloads +[bindings]: /downloads#bindings +[team]: /project/structure +[BiDi]: https://github.com/w3c/webdriver-bidi From 603cb0c2a69d9fbad78a8721836ac548d13677e5 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 24 Jun 2024 09:17:05 -0500 Subject: [PATCH 02/11] update version and links in downloads --- website_and_docs/layouts/downloads/list.html | 4 ++-- .../selenium-clients-and-webdriver-bindings.html | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/website_and_docs/layouts/downloads/list.html b/website_and_docs/layouts/downloads/list.html index 8d9b46875a3f..65f974b2f8ed 100644 --- a/website_and_docs/layouts/downloads/list.html +++ b/website_and_docs/layouts/downloads/list.html @@ -25,7 +25,7 @@

Latest stable version - 4.21.0 + 4.22.0

To use the Selenium Server in a Grid configuration see the @@ -107,7 +107,7 @@

C# NuGet

- Nuget latest release is 4.21.0 Released on May 16, 2024. + Nuget latest release is 4.22.0 Released on June 20, 2024.

  • diff --git a/website_and_docs/layouts/partials/selenium-clients-and-webdriver-bindings.html b/website_and_docs/layouts/partials/selenium-clients-and-webdriver-bindings.html index bde1e3e243b8..7208bea1e816 100644 --- a/website_and_docs/layouts/partials/selenium-clients-and-webdriver-bindings.html +++ b/website_and_docs/layouts/partials/selenium-clients-and-webdriver-bindings.html @@ -27,7 +27,7 @@

    Selenium Clients and WebDriver Language Bin

    Stable: - 4.21.0 (May 16, 2024) + 4.22.0 (June 20, 2024)

    @@ -54,8 +54,8 @@

    Selenium Clients and WebDriver Language Bin

    Stable: - - 4.21.0 (May 16, 2024) + + 4.22.0 (June 20, 2024)

    @@ -82,8 +82,8 @@

    Selenium Clients and WebDriver Language Bin

    Stable: - - 4.21.0 (May 16, 2024) + + 4.22.0 (June 20, 2024)

    @@ -111,7 +111,7 @@

    Selenium Clients and WebDriver Language Bin

    Stable: - 4.21.0 (May 16, 2024) + 4.22.0 (June 20, 2024)

    @@ -139,7 +139,7 @@

    Selenium Clients and WebDriver Language Bin

    Stable: - 4.21.0 (May 16, 2024) + 4.22.0 (June 20, 2024)

    From f068e2708962114e7c21d67909d92bcf6535a5c7 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 24 Jun 2024 12:57:06 -0500 Subject: [PATCH 03/11] [examples] reorganize code examples for BiDi --- .../BiDi/ChromeDevtools/LoggingTest.cs | 57 ++ .../ChromeDevtools/NetworkTest.cs} | 152 +++--- .../BiDi/ChromeDevtools/ScriptTest.cs | 60 +++ .../ChromeDevtools/CdpApiTest.cs | 91 ---- .../ChromeDevtools/CdpEndpointTest.cs | 81 --- .../WebDriverBiDi/BrowsingContextTest.cs | 10 - .../Bidirectional/WebDriverBiDi/LogTest.cs | 10 - .../chrome_devtools/CdpApiTest.java | 46 -- .../chrome_devtools/CdpEndpointTest.java | 0 .../bidi/chrome_devtools/LogTest.java | 49 ++ .../chrome_devtools/NetworkTest.java} | 40 -- .../bidi/chrome_devtools/ScriptTest.java | 58 ++ .../webdriver_bidi/LogTest.java | 0 .../webdriver_bidi/ActionsTest.java | 73 --- .../BrowsingContextInspectorTest.java | 185 ------- .../webdriver_bidi/BrowsingContextTest.java | 368 ------------- .../webdriver_bidi/LocateNodesTest.java | 221 -------- .../webdriver_bidi/NetworkCommandsTest.java | 112 ---- .../webdriver_bidi/NetworkEventsTest.java | 113 ---- .../webdriver_bidi/ScriptEventsTest.java | 87 --- .../webdriver_bidi/ScriptTest.java | 494 ------------------ .../test/bidirectional/bidi.spec.js | 52 -- .../bidirectional/browsingContext.spec.js | 437 ---------------- .../browsingContextInspector.spec.js | 122 ----- .../bidirectional/emulateGeoLocation.spec.js | 33 -- .../test/bidirectional/input.spec.js | 65 --- .../test/bidirectional/locateNodes.spec.js | 245 --------- .../bidirectional/network_commands.spec.js | 82 --- .../test/bidirectional/network_events.spec.js | 111 ---- .../bidirectional/script_commands.spec.js | 478 ----------------- .../test/bidirectional/script_events.spec.js | 93 ---- .../chrome_devtools/test_logging.py} | 12 - .../chrome_devtools/test_network.py} | 32 +- .../tests/bidi/chrome_devtools/test_script.py | 15 + examples/python/tests/bidi/test_log.py | 51 ++ .../chrome_devtools/test_cdp_endpoint.py | 44 -- .../webdriver_bidi/test_browsing_context.py | 2 - .../bidirectional/webdriver_bidi/test_log.py | 2 - examples/python/tests/conftest.py | 22 +- .../spec/bidi/chrome_devtools/logging_spec.rb | 33 ++ .../chrome_devtools/network_spec.rb} | 91 ++-- .../spec/bidi/chrome_devtools/scripts_spec.rb | 29 + examples/ruby/spec/bidi/logging_spec.rb | 50 ++ .../chrome_devtools/bidi_api_spec.rb | 100 ---- .../chrome_devtools/cdp_endpoint_spec.rb | 49 -- .../webdriver_bidi/browsing_context_spec.rb | 18 - .../bidirectional/webdriver_bidi/log_spec.rb | 9 - examples/ruby/spec/spec_helper.rb | 5 + 48 files changed, 551 insertions(+), 4038 deletions(-) create mode 100644 examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/LoggingTest.cs rename examples/dotnet/SeleniumDocs/{Bidirectional/ChromeDevtools/BidiApiTest.cs => BiDi/ChromeDevtools/NetworkTest.cs} (52%) create mode 100644 examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/ScriptTest.cs delete mode 100644 examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs delete mode 100644 examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs delete mode 100644 examples/dotnet/SeleniumDocs/Bidirectional/WebDriverBiDi/BrowsingContextTest.cs delete mode 100644 examples/dotnet/SeleniumDocs/Bidirectional/WebDriverBiDi/LogTest.cs rename examples/java/src/test/java/dev/selenium/{bidirectional => bidi}/chrome_devtools/CdpApiTest.java (75%) rename examples/java/src/test/java/dev/selenium/{bidirectional => bidi}/chrome_devtools/CdpEndpointTest.java (100%) create mode 100644 examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/LogTest.java rename examples/java/src/test/java/dev/selenium/{bidirectional/chrome_devtools/BidiApiTest.java => bidi/chrome_devtools/NetworkTest.java} (73%) create mode 100644 examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/ScriptTest.java rename examples/java/src/test/java/dev/selenium/{bidirectional => bidi}/webdriver_bidi/LogTest.java (100%) delete mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java delete mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java delete mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java delete mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LocateNodesTest.java delete mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java delete mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java delete mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java delete mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java delete mode 100644 examples/javascript/test/bidirectional/bidi.spec.js delete mode 100644 examples/javascript/test/bidirectional/browsingContext.spec.js delete mode 100644 examples/javascript/test/bidirectional/browsingContextInspector.spec.js delete mode 100644 examples/javascript/test/bidirectional/emulateGeoLocation.spec.js delete mode 100644 examples/javascript/test/bidirectional/input.spec.js delete mode 100644 examples/javascript/test/bidirectional/locateNodes.spec.js delete mode 100644 examples/javascript/test/bidirectional/network_commands.spec.js delete mode 100644 examples/javascript/test/bidirectional/network_events.spec.js delete mode 100644 examples/javascript/test/bidirectional/script_commands.spec.js delete mode 100644 examples/javascript/test/bidirectional/script_events.spec.js rename examples/python/tests/{bidirectional/chrome_devtools/test_bidi_api.py => bidi/chrome_devtools/test_logging.py} (71%) rename examples/python/tests/{bidirectional/chrome_devtools/test_cdp_api.py => bidi/chrome_devtools/test_network.py} (99%) create mode 100644 examples/python/tests/bidi/chrome_devtools/test_script.py create mode 100644 examples/python/tests/bidi/test_log.py delete mode 100644 examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py delete mode 100644 examples/python/tests/bidirectional/webdriver_bidi/test_browsing_context.py delete mode 100644 examples/python/tests/bidirectional/webdriver_bidi/test_log.py create mode 100644 examples/ruby/spec/bidi/chrome_devtools/logging_spec.rb rename examples/ruby/spec/{bidirectional/chrome_devtools/cdp_api_spec.rb => bidi/chrome_devtools/network_spec.rb} (57%) create mode 100644 examples/ruby/spec/bidi/chrome_devtools/scripts_spec.rb create mode 100644 examples/ruby/spec/bidi/logging_spec.rb delete mode 100644 examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb delete mode 100644 examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb delete mode 100644 examples/ruby/spec/bidirectional/webdriver_bidi/browsing_context_spec.rb delete mode 100644 examples/ruby/spec/bidirectional/webdriver_bidi/log_spec.rb diff --git a/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/LoggingTest.cs b/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/LoggingTest.cs new file mode 100644 index 000000000000..4b26d7362ae9 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/LoggingTest.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.IdentityModel.Tokens; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium; +using OpenQA.Selenium.Support.UI; + +namespace SeleniumDocs.Bidirectional.ChromeDevTools +{ + [TestClass] + public class LoggingTest : BaseChromeTest + { + [TestMethod] + public async Task ConsoleLogs() + { + driver.Url = "https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"; + + using IJavaScriptEngine monitor = new JavaScriptEngine(driver); + var messages = new List(); + monitor.JavaScriptConsoleApiCalled += (_, e) => + { + messages.Add(e.MessageContent); + }; + + await monitor.StartEventMonitoring(); + driver.FindElement(By.Id("consoleLog")).Click(); + driver.FindElement(By.Id("consoleError")).Click(); + new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(_ => messages.Count > 1); + monitor.StopEventMonitoring(); + + Assert.IsTrue(messages.Contains("Hello, world!")); + Assert.IsTrue(messages.Contains("I am console error")); + } + + [TestMethod] + public async Task JsErrors() + { + driver.Url = "https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"; + + using IJavaScriptEngine monitor = new JavaScriptEngine(driver); + var messages = new List(); + monitor.JavaScriptExceptionThrown += (_, e) => + { + messages.Add(e.Message); + }; + + await monitor.StartEventMonitoring(); + driver.FindElement(By.Id("jsException")).Click(); + new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(_ => !messages.IsNullOrEmpty()); + monitor.StopEventMonitoring(); + + Assert.IsTrue(messages.Contains("Uncaught")); + } + } +} \ No newline at end of file diff --git a/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs b/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/NetworkTest.cs similarity index 52% rename from examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs rename to examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/NetworkTest.cs index f088fb915cab..7d3a7a3954f8 100644 --- a/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/NetworkTest.cs @@ -1,17 +1,24 @@ -using System; -using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; -using Microsoft.IdentityModel.Tokens; using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; -using OpenQA.Selenium.Support.UI; +using OpenQA.Selenium.DevTools; +using System.Linq; +using OpenQA.Selenium.DevTools.V126.Network; +using OpenQA.Selenium.DevTools.V126.Performance; -namespace SeleniumDocs.Bidirectional.ChromeDevTools + +namespace SeleniumDocs.BiDi.ChromeDevTools { [TestClass] - public class BidiApiTest : BaseChromeTest + public class NetworkTest : BaseTest { + [TestInitialize] + public void Startup() + { + StartDriver("126"); + } + [TestMethod] public async Task BasicAuthentication() { @@ -31,93 +38,6 @@ public async Task BasicAuthentication() Assert.AreEqual("Congratulations! You must have the proper credentials.", driver.FindElement(By.TagName("p")).Text); } - - [TestMethod] - public async Task PinScript() - { - driver.Url = "https://www.selenium.dev/selenium/web/xhtmlTest.html"; - var element = driver.FindElement(By.Id("id1")); - - var key = await new JavaScriptEngine(driver).PinScript("return arguments;"); - - var arguments = ((WebDriver)driver).ExecuteScript(key, 1, true, element); - - var expected = new List - { - 1L, - true, - element - }; - CollectionAssert.AreEqual(expected, (ICollection)arguments); - } - - [TestMethod] - public async Task MutatedElements() - { - driver.Url = "https://www.selenium.dev/selenium/web/dynamic.html"; - - var mutations = new List(); - using IJavaScriptEngine monitor = new JavaScriptEngine(driver); - monitor.DomMutated += (_, e) => - { - var locator = By.CssSelector($"*[data-__webdriver_id='{e.AttributeData.TargetId}']"); - mutations.Add(driver.FindElement(locator)); - }; - - await monitor.StartEventMonitoring(); - await monitor.EnableDomMutationMonitoring(); - - driver.FindElement(By.Id("reveal")).Click(); - - new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(_ => !mutations.IsNullOrEmpty()); - await monitor.DisableDomMutationMonitoring(); - monitor.StopEventMonitoring(); - - var revealed = driver.FindElement(By.Id("revealed")); - Assert.AreEqual(revealed, mutations[0]); - } - - [TestMethod] - public async Task ConsoleLogs() - { - driver.Url = "https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"; - - using IJavaScriptEngine monitor = new JavaScriptEngine(driver); - var messages = new List(); - monitor.JavaScriptConsoleApiCalled += (_, e) => - { - messages.Add(e.MessageContent); - }; - - await monitor.StartEventMonitoring(); - driver.FindElement(By.Id("consoleLog")).Click(); - driver.FindElement(By.Id("consoleError")).Click(); - new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(_ => messages.Count > 1); - monitor.StopEventMonitoring(); - - Assert.IsTrue(messages.Contains("Hello, world!")); - Assert.IsTrue(messages.Contains("I am console error")); - } - - [TestMethod] - public async Task JsErrors() - { - driver.Url = "https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"; - - using IJavaScriptEngine monitor = new JavaScriptEngine(driver); - var messages = new List(); - monitor.JavaScriptExceptionThrown += (_, e) => - { - messages.Add(e.Message); - }; - - await monitor.StartEventMonitoring(); - driver.FindElement(By.Id("jsException")).Click(); - new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(_ => !messages.IsNullOrEmpty()); - monitor.StopEventMonitoring(); - - Assert.IsTrue(messages.Contains("Uncaught")); - } [TestMethod] public async Task RecordNetworkResponse() @@ -185,5 +105,51 @@ public async Task TransformNetworkRequest() Assert.AreEqual("two", driver.FindElement(By.Id("result")).Text); } + + [TestMethod] + public async Task SetCookie() + { + var session = ((IDevTools)driver).GetDevToolsSession(); + var domains = session.GetVersionSpecificDomains(); + await domains.Network.Enable(new OpenQA.Selenium.DevTools.V126.Network.EnableCommandSettings()); + + var cookieCommandSettings = new SetCookieCommandSettings + { + Name = "cheese", + Value = "gouda", + Domain = "www.selenium.dev", + Secure = true + }; + + await domains.Network.SetCookie(cookieCommandSettings); + + driver.Url = "https://www.selenium.dev"; + OpenQA.Selenium.Cookie cheese = driver.Manage().Cookies.GetCookieNamed("cheese"); + Assert.AreEqual("gouda", cheese.Value); + } + + [TestMethod] + public async Task PerformanceMetrics() + { + driver.Url = "https://www.selenium.dev/selenium/web/frameset.html"; + + var session = ((IDevTools)driver).GetDevToolsSession(); + var domains = session.GetVersionSpecificDomains(); + await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V126.Performance.EnableCommandSettings()); + + var metricsResponse = + await session.SendCommand( + new GetMetricsCommandSettings() + ); + + var metrics = metricsResponse.Metrics.ToDictionary( + dict => dict.Name, + dict => dict.Value + ); + + Assert.IsTrue(metrics["DevToolsCommandDuration"] > 0); + Assert.AreEqual(12, metrics["Frames"]); + } + } } \ No newline at end of file diff --git a/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/ScriptTest.cs b/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/ScriptTest.cs new file mode 100644 index 000000000000..eae07106060c --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/ScriptTest.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.IdentityModel.Tokens; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium; +using OpenQA.Selenium.Support.UI; + +namespace SeleniumDocs.Bidirectional.ChromeDevTools +{ + [TestClass] + public class ScriptTest : BaseChromeTest + { + [TestMethod] + public async Task PinScript() + { + driver.Url = "https://www.selenium.dev/selenium/web/xhtmlTest.html"; + var element = driver.FindElement(By.Id("id1")); + + var key = await new JavaScriptEngine(driver).PinScript("return arguments;"); + + var arguments = ((WebDriver)driver).ExecuteScript(key, 1, true, element); + + var expected = new List + { + 1L, + true, + element + }; + CollectionAssert.AreEqual(expected, (ICollection)arguments); + } + + [TestMethod] + public async Task MutatedElements() + { + driver.Url = "https://www.selenium.dev/selenium/web/dynamic.html"; + + var mutations = new List(); + using IJavaScriptEngine monitor = new JavaScriptEngine(driver); + monitor.DomMutated += (_, e) => + { + var locator = By.CssSelector($"*[data-__webdriver_id='{e.AttributeData.TargetId}']"); + mutations.Add(driver.FindElement(locator)); + }; + + await monitor.StartEventMonitoring(); + await monitor.EnableDomMutationMonitoring(); + + driver.FindElement(By.Id("reveal")).Click(); + + new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(_ => !mutations.IsNullOrEmpty()); + await monitor.DisableDomMutationMonitoring(); + monitor.StopEventMonitoring(); + + var revealed = driver.FindElement(By.Id("revealed")); + Assert.AreEqual(revealed, mutations[0]); + } + } +} \ No newline at end of file diff --git a/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs b/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs deleted file mode 100644 index f5e5b88fd90b..000000000000 --- a/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using OpenQA.Selenium; -using OpenQA.Selenium.DevTools; -using OpenQA.Selenium.DevTools.V124.Network; -using OpenQA.Selenium.DevTools.V124.Performance; - -namespace SeleniumDocs.Bidirectional.ChromeDevtools -{ - [TestClass] - public class CdpApiTest : BaseTest - { - [TestInitialize] - public void Startup() - { - StartDriver("124"); - } - - [TestMethod] - public async Task SetCookie() - { - var session = ((IDevTools)driver).GetDevToolsSession(); - var domains = session.GetVersionSpecificDomains(); - await domains.Network.Enable(new OpenQA.Selenium.DevTools.V124.Network.EnableCommandSettings()); - - var cookieCommandSettings = new SetCookieCommandSettings - { - Name = "cheese", - Value = "gouda", - Domain = "www.selenium.dev", - Secure = true - }; - - await domains.Network.SetCookie(cookieCommandSettings); - - driver.Url = "https://www.selenium.dev"; - OpenQA.Selenium.Cookie cheese = driver.Manage().Cookies.GetCookieNamed("cheese"); - Assert.AreEqual("gouda", cheese.Value); - } - - [TestMethod] - public async Task PerformanceMetrics() - { - driver.Url = "https://www.selenium.dev/selenium/web/frameset.html"; - - var session = ((IDevTools)driver).GetDevToolsSession(); - var domains = session.GetVersionSpecificDomains(); - await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V124.Performance.EnableCommandSettings()); - - var metricsResponse = - await session.SendCommand( - new GetMetricsCommandSettings() - ); - - var metrics = metricsResponse.Metrics.ToDictionary( - dict => dict.Name, - dict => dict.Value - ); - - Assert.IsTrue(metrics["DevToolsCommandDuration"] > 0); - Assert.AreEqual(12, metrics["Frames"]); - } - - [TestMethod] - public async Task BasicAuth() - { - var session = ((IDevTools)driver).GetDevToolsSession(); - var domains = session.GetVersionSpecificDomains(); - await domains.Network.Enable(new OpenQA.Selenium.DevTools.V124.Network.EnableCommandSettings()); - - var encodedAuth = Convert.ToBase64String(Encoding.Default.GetBytes("admin:admin")); - var headerSettings = new SetExtraHTTPHeadersCommandSettings - { - Headers = new Headers() - { - { "authorization", "Basic " + encodedAuth } - } - }; - - await domains.Network.SetExtraHTTPHeaders(headerSettings); - - driver.Url = "https://the-internet.herokuapp.com/basic_auth"; - - var element = driver.FindElement(By.TagName("p")); - Assert.AreEqual("Congratulations! You must have the proper credentials.", element.Text); - } - } -} \ No newline at end of file diff --git a/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs b/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs deleted file mode 100644 index ff4c4d089c3c..000000000000 --- a/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using OpenQA.Selenium; -using OpenQA.Selenium.Chrome; - -namespace SeleniumDocs.Bidirectional.ChromeDevtools -{ - [TestClass] - public class CdpEndpointTest : BaseTest - { - private readonly Dictionary emptyDictionary = new(); - - [TestInitialize] - public void Startup() - { - StartDriver(); - } - - [TestMethod] - public void SetCookie() - { - var cookie = new Dictionary - { - { "name", "cheese" }, - { "value", "gouda" }, - { "domain", "www.selenium.dev" }, - { "secure", true } - }; - - ((ChromeDriver)driver).ExecuteCdpCommand("Network.setCookie", cookie); - - driver.Url = "https://www.selenium.dev"; - Cookie cheese = driver.Manage().Cookies.GetCookieNamed("cheese"); - Assert.AreEqual("gouda", cheese.Value); - - } - - [TestMethod] - public void PerformanceMetrics() - { - driver.Url = "https://www.selenium.dev/selenium/web/frameset.html"; - - ((ChromeDriver)driver).ExecuteCdpCommand("Performance.enable", emptyDictionary); - - Dictionary response = (Dictionary)((ChromeDriver)driver) - .ExecuteCdpCommand("Performance.getMetrics", emptyDictionary); - - Object[] metricList = (object[])response["metrics"]; - var metrics = metricList.OfType>() - .ToDictionary( - dict => (string)dict["name"], - dict => dict["value"] - ); - - Assert.IsTrue((double)metrics["DevToolsCommandDuration"] > 0); - Assert.AreEqual((long)12, metrics["Frames"]); - } - - [TestMethod] - public void BasicAuth() - { - ((ChromeDriver)driver).ExecuteCdpCommand("Network.enable", emptyDictionary); - - string encodedAuth = Convert.ToBase64String(Encoding.Default.GetBytes("admin:admin")); - var headers = new Dictionary - { - { "headers", new Dictionary { { "authorization", "Basic " + encodedAuth } } } - }; - - ((ChromeDriver)driver).ExecuteCdpCommand("Network.setExtraHTTPHeaders", headers); - - driver.Url = "https://the-internet.herokuapp.com/basic_auth"; - - var element = driver.FindElement(By.TagName("p")); - Assert.AreEqual("Congratulations! You must have the proper credentials.", element.Text); - } - } -} \ No newline at end of file diff --git a/examples/dotnet/SeleniumDocs/Bidirectional/WebDriverBiDi/BrowsingContextTest.cs b/examples/dotnet/SeleniumDocs/Bidirectional/WebDriverBiDi/BrowsingContextTest.cs deleted file mode 100644 index 7de31af093f6..000000000000 --- a/examples/dotnet/SeleniumDocs/Bidirectional/WebDriverBiDi/BrowsingContextTest.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace SeleniumDocs.Bidirectional.WebDriverBiDi -{ - [TestClass] - public class BrowsingContextTest : BaseTest - { - - } -} \ No newline at end of file diff --git a/examples/dotnet/SeleniumDocs/Bidirectional/WebDriverBiDi/LogTest.cs b/examples/dotnet/SeleniumDocs/Bidirectional/WebDriverBiDi/LogTest.cs deleted file mode 100644 index 54e3f92884b2..000000000000 --- a/examples/dotnet/SeleniumDocs/Bidirectional/WebDriverBiDi/LogTest.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace SeleniumDocs.Bidirectional.WebDriverBiDi -{ - [TestClass] - public class LogTest : BaseTest - { - - } -} \ No newline at end of file diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java b/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/CdpApiTest.java similarity index 75% rename from examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java rename to examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/CdpApiTest.java index b10941ecda9a..0f9d56950f74 100644 --- a/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java +++ b/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/CdpApiTest.java @@ -42,33 +42,6 @@ public void createSession() { wait = new WebDriverWait(driver, Duration.ofSeconds(10)); } - @Test - public void setCookie() { - devTools = ((HasDevTools) driver).getDevTools(); - devTools.createSession(); - - devTools.send( - Network.setCookie( - "cheese", - "gouda", - Optional.empty(), - Optional.of("www.selenium.dev"), - Optional.empty(), - Optional.of(true), - Optional.empty(), - Optional.empty(), - Optional.empty(), - Optional.empty(), - Optional.empty(), - Optional.empty(), - Optional.empty(), - Optional.empty())); - - driver.get("https://www.selenium.dev"); - Cookie cheese = driver.manage().getCookieNamed("cheese"); - Assertions.assertEquals("gouda", cheese.getValue()); - } - @Test @Disabled("4.15 broke the casting") public void performanceMetrics() { @@ -107,25 +80,6 @@ public void basicAuth() { driver.findElement(By.tagName("p")).getText()); } - @Test - public void consoleLogs() { - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - - DevTools devTools = ((HasDevTools) driver).getDevTools(); - devTools.createSession(); - devTools.send(Runtime.enable()); - - CopyOnWriteArrayList logs = new CopyOnWriteArrayList<>(); - devTools.addListener( - Runtime.consoleAPICalled(), - event -> logs.add((String) event.getArgs().get(0).getValue().orElse(""))); - - driver.findElement(By.id("consoleLog")).click(); - - wait.until(_d -> !logs.isEmpty()); - Assertions.assertEquals("Hello, world!", logs.get(0)); - } - @Test public void jsErrors() { driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java b/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/CdpEndpointTest.java similarity index 100% rename from examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java rename to examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/CdpEndpointTest.java diff --git a/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/LogTest.java b/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/LogTest.java new file mode 100644 index 000000000000..635a1e7afa4e --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/LogTest.java @@ -0,0 +1,49 @@ +package dev.selenium.bidirectional.chrome_devtools; + +import static org.openqa.selenium.devtools.events.CdpEventTypes.consoleEvent; +import static org.openqa.selenium.devtools.events.CdpEventTypes.domMutation; + +import com.google.common.net.MediaType; +import dev.selenium.BaseTest; +import java.net.*; +import java.time.Duration; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Predicate; +import java.util.function.Supplier; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.*; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.devtools.NetworkInterceptor; +import org.openqa.selenium.logging.HasLogEvents; +import org.openqa.selenium.remote.http.*; +import org.openqa.selenium.support.ui.WebDriverWait; + +public class BidiApiTest extends BaseTest { + + @BeforeEach + public void createSession() { + driver = new ChromeDriver(); + wait = new WebDriverWait(driver, Duration.ofSeconds(10)); + } + + @Test + public void consoleLogs() { + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + + CopyOnWriteArrayList messages = new CopyOnWriteArrayList<>(); + ((HasLogEvents) driver).onLogEvent(consoleEvent(e -> messages.add(e.getMessages().get(0)))); + + driver.findElement(By.id("consoleLog")).click(); + driver.findElement(By.id("consoleError")).click(); + + wait.until(_d -> messages.size() > 1); + Assertions.assertTrue(messages.contains("Hello, world!")); + Assertions.assertTrue(messages.contains("I am console error")); + } + +} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java b/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/NetworkTest.java similarity index 73% rename from examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java rename to examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/NetworkTest.java index cb657347d34c..826fd5ddec26 100644 --- a/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java +++ b/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/NetworkTest.java @@ -45,46 +45,6 @@ public void basicAuthentication() { Assertions.assertEquals(successMessage, elementMessage.getText()); } - @Test - public void pinScript() { - driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); - WebElement element = driver.findElement(By.id("id1")); - - ScriptKey key = ((JavascriptExecutor) driver).pin("return arguments;"); - List arguments = - (List) ((JavascriptExecutor) driver).executeScript(key, 1, true, element); - - Assertions.assertEquals(List.of(1L, true, element), arguments); - } - - @Test - public void mutatedElements() { - driver.get("https://www.selenium.dev/selenium/web/dynamic.html"); - - CopyOnWriteArrayList mutations = new CopyOnWriteArrayList<>(); - ((HasLogEvents) driver).onLogEvent(domMutation(e -> mutations.add(e.getElement()))); - - driver.findElement(By.id("reveal")).click(); - - wait.until(_d -> !mutations.isEmpty()); - Assertions.assertEquals(mutations.get(0), driver.findElement(By.id("revealed"))); - } - - @Test - public void consoleLogs() { - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - - CopyOnWriteArrayList messages = new CopyOnWriteArrayList<>(); - ((HasLogEvents) driver).onLogEvent(consoleEvent(e -> messages.add(e.getMessages().get(0)))); - - driver.findElement(By.id("consoleLog")).click(); - driver.findElement(By.id("consoleError")).click(); - - wait.until(_d -> messages.size() > 1); - Assertions.assertTrue(messages.contains("Hello, world!")); - Assertions.assertTrue(messages.contains("I am console error")); - } - @Test public void recordResponse() { CopyOnWriteArrayList contentType = new CopyOnWriteArrayList<>(); diff --git a/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/ScriptTest.java b/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/ScriptTest.java new file mode 100644 index 000000000000..421dbbc1b5c5 --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/ScriptTest.java @@ -0,0 +1,58 @@ +package dev.selenium.bidirectional.chrome_devtools; + +import static org.openqa.selenium.devtools.events.CdpEventTypes.consoleEvent; +import static org.openqa.selenium.devtools.events.CdpEventTypes.domMutation; + +import com.google.common.net.MediaType; +import dev.selenium.BaseTest; +import java.net.*; +import java.time.Duration; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Predicate; +import java.util.function.Supplier; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.*; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.devtools.NetworkInterceptor; +import org.openqa.selenium.logging.HasLogEvents; +import org.openqa.selenium.remote.http.*; +import org.openqa.selenium.support.ui.WebDriverWait; + +public class BidiApiTest extends BaseTest { + + @BeforeEach + public void createSession() { + driver = new ChromeDriver(); + wait = new WebDriverWait(driver, Duration.ofSeconds(10)); + } + + @Test + public void pinScript() { + driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); + WebElement element = driver.findElement(By.id("id1")); + + ScriptKey key = ((JavascriptExecutor) driver).pin("return arguments;"); + List arguments = + (List) ((JavascriptExecutor) driver).executeScript(key, 1, true, element); + + Assertions.assertEquals(List.of(1L, true, element), arguments); + } + + @Test + public void mutatedElements() { + driver.get("https://www.selenium.dev/selenium/web/dynamic.html"); + + CopyOnWriteArrayList mutations = new CopyOnWriteArrayList<>(); + ((HasLogEvents) driver).onLogEvent(domMutation(e -> mutations.add(e.getElement()))); + + driver.findElement(By.id("reveal")).click(); + + wait.until(_d -> !mutations.isEmpty()); + Assertions.assertEquals(mutations.get(0), driver.findElement(By.id("revealed"))); + } +} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java b/examples/java/src/test/java/dev/selenium/bidi/webdriver_bidi/LogTest.java similarity index 100% rename from examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java rename to examples/java/src/test/java/dev/selenium/bidi/webdriver_bidi/LogTest.java diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java deleted file mode 100644 index ffc692a8fc9a..000000000000 --- a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package dev.selenium.bidirectional.webdriver_bidi; - -import dev.selenium.BaseTest; -import java.util.List; -import java.util.Map; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.Keys; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.bidi.module.Input; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.firefox.FirefoxOptions; -import org.openqa.selenium.interactions.Actions; - -class ActionsTest extends BaseTest { - private Input input; - - private String windowHandle; - - @BeforeEach - public void setup() { - FirefoxOptions options = new FirefoxOptions(); - options.setCapability("webSocketUrl", true); - driver = new FirefoxDriver(options); - windowHandle = driver.getWindowHandle(); - input = new Input(driver); - } - - @Test - void canPerformInputActions() { - driver.get("https://www.selenium.dev/selenium/web/formSelectionPage.html"); - - List options = driver.findElements(By.tagName("option")); - - Actions actions = new Actions(driver); - Actions selectThreeOptions = - actions.click(options.get(1)).keyDown(Keys.SHIFT).click(options.get(3)).keyUp(Keys.SHIFT); - - input.perform(windowHandle, selectThreeOptions.getSequences()); - - WebElement showButton = driver.findElement(By.name("showselected")); - showButton.click(); - - WebElement resultElement = driver.findElement(By.id("result")); - Assertions.assertTrue(resultElement.getText().contains("roquefort parmigiano cheddar")); - } - - @Test - void canPerformReleaseAction() { - driver.get("https://www.selenium.dev/selenium/web/bidi/release_action.html"); - - WebElement inputTextBox = driver.findElement(By.id("keys")); - - Actions sendLowercase = - new Actions(driver).keyDown(inputTextBox, "a").keyDown(inputTextBox, "b"); - - input.perform(windowHandle, sendLowercase.getSequences()); - ((JavascriptExecutor) driver).executeScript("resetEvents()"); - - input.release(windowHandle); - - List> events = - (List>) - ((JavascriptExecutor) driver).executeScript("return allEvents.events"); - Assertions.assertEquals("KeyB", events.get(0).get("code")); - Assertions.assertEquals("KeyA", events.get(1).get("code")); - } - } diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java deleted file mode 100644 index bd12d14e2b26..000000000000 --- a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java +++ /dev/null @@ -1,185 +0,0 @@ -package dev.selenium.bidirectional.webdriver_bidi; - -import dev.selenium.BaseTest; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WindowType; -import org.openqa.selenium.bidi.module.BrowsingContextInspector; -import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; -import org.openqa.selenium.bidi.browsingcontext.BrowsingContextInfo; -import org.openqa.selenium.bidi.browsingcontext.NavigationInfo; -import org.openqa.selenium.bidi.browsingcontext.ReadinessState; -import org.openqa.selenium.bidi.browsingcontext.UserPromptClosed; -import org.openqa.selenium.bidi.browsingcontext.UserPromptOpened; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.firefox.FirefoxOptions; - -class BrowsingContextInspectorTest extends BaseTest { - @BeforeEach - public void setup() { - FirefoxOptions options = new FirefoxOptions(); - options.setCapability("webSocketUrl", true); - driver = new FirefoxDriver(options); - } - - @Test - void canListenToWindowBrowsingContextCreatedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - - inspector.onBrowsingContextCreated(future::complete); - - String windowHandle = driver.switchTo().newWindow(WindowType.WINDOW).getWindowHandle(); - - BrowsingContextInfo browsingContextInfo = future.get(5, TimeUnit.SECONDS); - - Assertions.assertEquals(windowHandle, browsingContextInfo.getId()); - } - } - - @Test - void canListenToTabBrowsingContextCreatedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - inspector.onBrowsingContextCreated(future::complete); - - String windowHandle = driver.switchTo().newWindow(WindowType.TAB).getWindowHandle(); - - BrowsingContextInfo browsingContextInfo = future.get(5, TimeUnit.SECONDS); - - Assertions.assertEquals(windowHandle, browsingContextInfo.getId()); - } - } - - @Test - void canListenToDomContentLoadedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - inspector.onDomContentLoaded(future::complete); - - BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); - context.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", ReadinessState.COMPLETE); - - NavigationInfo navigationInfo = future.get(5, TimeUnit.SECONDS); - - Assertions.assertTrue(navigationInfo.getUrl().contains("bidi/logEntryAdded")); - } - } - - @Test - void canListenToBrowsingContextLoadedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - inspector.onBrowsingContextLoaded(future::complete); - - BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); - context.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", ReadinessState.COMPLETE); - - NavigationInfo navigationInfo = future.get(5, TimeUnit.SECONDS); - - Assertions.assertTrue(navigationInfo.getUrl().contains("bidi/logEntryAdded")); - } - } - - @Test - void canListenToNavigationStartedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - inspector.onNavigationStarted(future::complete); - - BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); - context.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", ReadinessState.COMPLETE); - - NavigationInfo navigationInfo = future.get(5, TimeUnit.SECONDS); - - Assertions.assertTrue(navigationInfo.getUrl().contains("bidi/logEntryAdded")); - } - } - - @Test - void canListenToFragmentNavigatedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - - BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); - context.navigate("https://www.selenium.dev/selenium/web/linked_image.html", ReadinessState.COMPLETE); - - inspector.onFragmentNavigated(future::complete); - - context.navigate("https://www.selenium.dev/selenium/web/linked_image.html#linkToAnchorOnThisPage", ReadinessState.COMPLETE); - - NavigationInfo navigationInfo = future.get(5, TimeUnit.SECONDS); - - Assertions.assertTrue(navigationInfo.getUrl().contains("linkToAnchorOnThisPage")); - } - } - - @Test - void canListenToUserPromptOpenedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - - BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); - inspector.onUserPromptOpened(future::complete); - - driver.get("https://www.selenium.dev/selenium/web/alerts.html"); - - driver.findElement(By.id("alert")).click(); - - UserPromptOpened userPromptOpened = future.get(5, TimeUnit.SECONDS); - Assertions.assertEquals(context.getId(), userPromptOpened.getBrowsingContextId()); - } - } - - @Test - void canListenToUserPromptClosedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - - BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); - inspector.onUserPromptClosed(future::complete); - - driver.get("https://www.selenium.dev/selenium/web/alerts.html"); - - driver.findElement(By.id("prompt")).click(); - - context.handleUserPrompt(true, "selenium"); - - UserPromptClosed userPromptClosed = future.get(5, TimeUnit.SECONDS); - Assertions.assertEquals(context.getId(), userPromptClosed.getBrowsingContextId()); - } - } - - @Test - void canListenToBrowsingContextDestroyedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - - inspector.onBrowsingContextDestroyed(future::complete); - - String windowHandle = driver.switchTo().newWindow(WindowType.WINDOW).getWindowHandle(); - - driver.close(); - - BrowsingContextInfo browsingContextInfo = future.get(5, TimeUnit.SECONDS); - - Assertions.assertEquals(windowHandle, browsingContextInfo.getId()); - Assertions.assertTrue(browsingContextInfo.getUrl().contains("about:blank")); - } - } -} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java deleted file mode 100644 index 55e82ed2c20e..000000000000 --- a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java +++ /dev/null @@ -1,368 +0,0 @@ -package dev.selenium.bidirectional.webdriver_bidi; - -import dev.selenium.BaseTest; -import java.util.List; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.Rectangle; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.WindowType; -import org.openqa.selenium.bidi.BiDiException; -import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; -import org.openqa.selenium.bidi.browsingcontext.BrowsingContextInfo; -import org.openqa.selenium.bidi.browsingcontext.NavigationResult; -import org.openqa.selenium.bidi.browsingcontext.ReadinessState; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.firefox.FirefoxOptions; -import org.openqa.selenium.print.PrintOptions; -import org.openqa.selenium.remote.RemoteWebElement; - -import static org.openqa.selenium.support.ui.ExpectedConditions.titleIs; -import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated; - -class BrowsingContextTest extends BaseTest { - - @BeforeEach - public void setup() { - FirefoxOptions options = new FirefoxOptions(); - options.setCapability("webSocketUrl", true); - driver = new FirefoxDriver(options); - } - - @Test - void testCreateABrowsingContextForGivenId() { - String id = driver.getWindowHandle(); - BrowsingContext browsingContext = new BrowsingContext(driver, id); - Assertions.assertEquals(id, browsingContext.getId()); - } - - @Test - void testCreateAWindow() { - BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.WINDOW); - Assertions.assertNotNull(browsingContext.getId()); - } - - @Test - void testCreateAWindowWithAReferenceContext() { - BrowsingContext - browsingContext = - new BrowsingContext(driver, WindowType.WINDOW, driver.getWindowHandle()); - Assertions.assertNotNull(browsingContext.getId()); - } - - @Test - void testCreateATab() { - BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB); - Assertions.assertNotNull(browsingContext.getId()); - } - - @Test - void testCreateATabWithAReferenceContext() { - BrowsingContext - browsingContext = - new BrowsingContext(driver, WindowType.TAB, driver.getWindowHandle()); - Assertions.assertNotNull(browsingContext.getId()); - } - - @Test - void testNavigateToAUrl() { - BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB); - - NavigationResult info = browsingContext.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - - Assertions.assertNotNull(browsingContext.getId()); - Assertions.assertNotNull(info.getNavigationId()); - Assertions.assertTrue(info.getUrl().contains("/bidi/logEntryAdded.html")); - } - - @Test - void testNavigateToAUrlWithReadinessState() { - BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB); - - NavigationResult info = browsingContext.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", - ReadinessState.COMPLETE); - - Assertions.assertNotNull(browsingContext.getId()); - Assertions.assertNotNull(info.getNavigationId()); - Assertions.assertTrue(info.getUrl().contains("/bidi/logEntryAdded.html")); - } - - @Test - void testGetTreeWithAChild() { - String referenceContextId = driver.getWindowHandle(); - BrowsingContext parentWindow = new BrowsingContext(driver, referenceContextId); - - parentWindow.navigate("https://www.selenium.dev/selenium/web/iframes.html", ReadinessState.COMPLETE); - - List contextInfoList = parentWindow.getTree(); - - Assertions.assertEquals(1, contextInfoList.size()); - BrowsingContextInfo info = contextInfoList.get(0); - Assertions.assertEquals(1, info.getChildren().size()); - Assertions.assertEquals(referenceContextId, info.getId()); - Assertions.assertTrue(info.getChildren().get(0).getUrl().contains("formPage.html")); - } - - @Test - void testGetTreeWithDepth() { - String referenceContextId = driver.getWindowHandle(); - BrowsingContext parentWindow = new BrowsingContext(driver, referenceContextId); - - parentWindow.navigate("https://www.selenium.dev/selenium/web/iframes.html", ReadinessState.COMPLETE); - - List contextInfoList = parentWindow.getTree(0); - - Assertions.assertEquals(1, contextInfoList.size()); - BrowsingContextInfo info = contextInfoList.get(0); - Assertions.assertNull(info.getChildren()); // since depth is 0 - Assertions.assertEquals(referenceContextId, info.getId()); - } - - @Test - void testGetAllTopLevelContexts() { - BrowsingContext window1 = new BrowsingContext(driver, driver.getWindowHandle()); - BrowsingContext window2 = new BrowsingContext(driver, WindowType.WINDOW); - - List contextInfoList = window1.getTopLevelContexts(); - - Assertions.assertEquals(2, contextInfoList.size()); - } - - @Test - void testCloseAWindow() { - BrowsingContext window1 = new BrowsingContext(driver, WindowType.WINDOW); - BrowsingContext window2 = new BrowsingContext(driver, WindowType.WINDOW); - - window2.close(); - - Assertions.assertThrows(BiDiException.class, window2::getTree); - } - - @Test - void testCloseATab() { - BrowsingContext tab1 = new BrowsingContext(driver, WindowType.TAB); - BrowsingContext tab2 = new BrowsingContext(driver, WindowType.TAB); - - tab2.close(); - - Assertions.assertThrows(BiDiException.class, tab2::getTree); - } - - @Test - void testActivateABrowsingContext() { - BrowsingContext window1 = new BrowsingContext(driver, driver.getWindowHandle()); - BrowsingContext window2 = new BrowsingContext(driver, WindowType.WINDOW); - - window1.activate(); - - boolean isFocused = (boolean) ((JavascriptExecutor) driver).executeScript("return document.hasFocus();"); - - Assertions.assertTrue(isFocused); - } - - @Test - void testReloadABrowsingContext() { - BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB); - - browsingContext.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", ReadinessState.COMPLETE); - - NavigationResult reloadInfo = browsingContext.reload(ReadinessState.INTERACTIVE); - - Assertions.assertNotNull(reloadInfo.getNavigationId()); - Assertions.assertTrue(reloadInfo.getUrl().contains("/bidi/logEntryAdded.html")); - } - - @Test - void testHandleUserPrompt() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/alerts.html"); - - driver.findElement(By.id("alert")).click(); - - browsingContext.handleUserPrompt(); - - Assertions.assertTrue(driver.getPageSource().contains("Testing Alerts and Stuff")); - } - - @Test - void testAcceptUserPrompt() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/alerts.html"); - - driver.findElement(By.id("alert")).click(); - - browsingContext.handleUserPrompt("true"); - - Assertions.assertTrue(driver.getPageSource().contains("Testing Alerts and Stuff")); - } - - @Test - void testDismissUserPrompt() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/alerts.html"); - - driver.findElement(By.id("alert")).click(); - - browsingContext.handleUserPrompt("true"); - - Assertions.assertTrue(driver.getPageSource().contains("Testing Alerts and Stuff")); - } - - @Test - void testPassUserTextToUserPrompt() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/alerts.html"); - - driver.findElement(By.id("prompt-with-default")).click(); - - String userText = "Selenium automates browsers"; - browsingContext.handleUserPrompt(true, userText); - - Assertions.assertTrue(driver.getPageSource().contains(userText)); - } - - @Test - void testDismissUserPromptWithText() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/alerts.html"); - - driver.findElement(By.id("prompt-with-default")).click(); - - String userText = "Selenium automates browsers"; - browsingContext.handleUserPrompt(false, userText); - - Assertions.assertFalse(driver.getPageSource().contains(userText)); - } - - @Test - void textCaptureScreenshot() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/alerts.html"); - - String screenshot = browsingContext.captureScreenshot(); - - Assertions.assertTrue(screenshot.length() > 0); - } - - @Test - void textCaptureViewportScreenshot() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/coordinates_tests/simple_page.html"); - - WebElement element = driver.findElement(By.id("box")); - Rectangle elementRectangle = element.getRect(); - - String screenshot = - browsingContext.captureBoxScreenshot( - elementRectangle.getX(), elementRectangle.getY(), 5, 5); - - Assertions.assertTrue(screenshot.length() > 0); - } - - @Test - void textCaptureElementScreenshot() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/formPage.html"); - WebElement element = driver.findElement(By.id("checky")); - - String screenshot = browsingContext.captureElementScreenshot(((RemoteWebElement) element).getId()); - - Assertions.assertTrue(screenshot.length() > 0); - } - - @Test - void textSetViewport() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - driver.get("https://www.selenium.dev/selenium/web/formPage.html"); - - browsingContext.setViewport(250, 300); - - List newViewportSize = - (List) - ((JavascriptExecutor) driver) - .executeScript("return [window.innerWidth, window.innerHeight];"); - - Assertions.assertEquals(250, newViewportSize.get(0)); - Assertions.assertEquals(300, newViewportSize.get(1)); - } - - @Test - @Disabled("Supported by Firefox Nightly 124") - void textSetViewportWithDevicePixelRatio() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - driver.get("https://www.selenium.dev/selenium/web/formPage.html"); - - browsingContext.setViewport(250, 300, 5); - - Long newDevicePixelRatio = - (Long) ((JavascriptExecutor) driver).executeScript("return window.devicePixelRatio"); - - Assertions.assertEquals(5, newDevicePixelRatio); - } - - @Test - void testPrintPage() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/formPage.html"); - PrintOptions printOptions = new PrintOptions(); - - String printPage = browsingContext.print(printOptions); - - Assertions.assertTrue(printPage.length() > 0); - } - - @Test - @Disabled("Supported by Firefox Nightly 124") - void testNavigateBackInTheBrowserHistory() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - browsingContext.navigate("https://www.selenium.dev/selenium/web/formPage.html", ReadinessState.COMPLETE); - - wait.until(visibilityOfElementLocated(By.id("imageButton"))).submit(); - wait.until(titleIs("We Arrive Here")); - - browsingContext.back(); - Assertions.assertTrue(driver.getPageSource().contains("We Leave From Here")); - } - - @Test - @Disabled("Supported by Firefox Nightly 124") - void canNavigateForwardInTheBrowserHistory() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - browsingContext.navigate("https://www.selenium.dev/selenium/web/formPage.html", ReadinessState.COMPLETE); - - wait.until(visibilityOfElementLocated(By.id("imageButton"))).submit(); - wait.until(titleIs("We Arrive Here")); - - browsingContext.back(); - Assertions.assertTrue(driver.getPageSource().contains("We Leave From Here")); - - browsingContext.forward(); - wait.until(titleIs("We Arrive Here")); - } - - @Test - @Disabled("Supported by Firefox Nightly 124") - void canTraverseBrowserHistory() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - browsingContext.navigate("https://www.selenium.dev/selenium/web/formPage.html", ReadinessState.COMPLETE); - - wait.until(visibilityOfElementLocated(By.id("imageButton"))).submit(); - wait.until(titleIs("We Arrive Here")); - - browsingContext.traverseHistory(-1); - Assertions.assertTrue(driver.getPageSource().contains("We Leave From Here")); - } -} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LocateNodesTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LocateNodesTest.java deleted file mode 100644 index af0003daacbf..000000000000 --- a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LocateNodesTest.java +++ /dev/null @@ -1,221 +0,0 @@ -package dev.selenium.bidirectional.webdriver_bidi; - -import dev.selenium.BaseTest; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.bidi.module.Script; -import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; -import org.openqa.selenium.bidi.browsingcontext.LocateNodeParameters; -import org.openqa.selenium.bidi.browsingcontext.Locator; -import org.openqa.selenium.bidi.browsingcontext.ReadinessState; -import org.openqa.selenium.bidi.script.EvaluateResult; -import org.openqa.selenium.bidi.script.EvaluateResultSuccess; -import org.openqa.selenium.bidi.script.LocalValue; -import org.openqa.selenium.bidi.script.NodeProperties; -import org.openqa.selenium.bidi.script.RemoteReference; -import org.openqa.selenium.bidi.script.RemoteValue; -import org.openqa.selenium.bidi.script.ResultOwnership; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.firefox.FirefoxOptions; - -class LocateNodesTest extends BaseTest { - - @BeforeEach - public void setup() { - FirefoxOptions options = new FirefoxOptions(); - options.setCapability("webSocketUrl", true); - driver = new FirefoxDriver(options); - } - - @Test - @Disabled - void testCreateABrowsingContextForGivenId() { - String id = driver.getWindowHandle(); - BrowsingContext browsingContext = new BrowsingContext(driver, id); - Assertions.assertEquals(id, browsingContext.getId()); - } - - @Test - @Disabled - void canLocateNodes() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); - - LocateNodeParameters parameters = new LocateNodeParameters(Locator.css("div")); - - List elements = browsingContext.locateNodes(parameters); - Assertions.assertEquals(13, elements.size()); - } - - @Test - @Disabled - void canLocateNodesWithJustLocator() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); - - List elements = browsingContext.locateNodes(Locator.css("div")); - Assertions.assertEquals(13, elements.size()); - } - - @Test - @Disabled - void canLocateNode() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); - - RemoteValue element = browsingContext.locateNode(Locator.css("div")); - Assertions.assertEquals("node", element.getType()); - } - - @Test - @Disabled - void canLocateNodesWithCSSLocator() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); - - LocateNodeParameters parameters = - new LocateNodeParameters(Locator.css("div.extraDiv, div.content")) - .setMaxNodeCount(1); - - List elements = browsingContext.locateNodes(parameters); - - RemoteValue value = elements.get(0); - NodeProperties properties = (NodeProperties) value.getValue().get(); - Assertions.assertEquals("div", properties.getLocalName().get()); - Assertions.assertEquals("content", properties.getAttributes().get().get("class")); - } - - @Test - @Disabled - void canLocateNodesWithXPathLocator() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); - - LocateNodeParameters parameters = - new LocateNodeParameters(Locator.xpath("/html/body/div[2]")).setMaxNodeCount(1); - - List elements = browsingContext.locateNodes(parameters); - - RemoteValue value = elements.get(0); - NodeProperties properties = (NodeProperties) value.getValue().get(); - Assertions.assertEquals("div", properties.getLocalName().get()); - Assertions.assertEquals("content", properties.getAttributes().get().get("class")); - } - - @Test - @Disabled - void canLocateNodesWithInnerText() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); - - LocateNodeParameters parameters = - new LocateNodeParameters(Locator.innerText("Spaced out")).setMaxNodeCount(1); - - List elements = browsingContext.locateNodes(parameters); - - RemoteValue value = elements.get(0); - Assertions.assertEquals("node", value.getType()); - } - - @Test - @Disabled - void canLocateNodesWithMaxNodeCount() { - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); - - LocateNodeParameters parameters = - new LocateNodeParameters(Locator.css("div")).setMaxNodeCount(4); - - List elements = browsingContext.locateNodes(parameters); - Assertions.assertEquals(4, elements.size()); - } - - @Test - @Disabled - void canLocateNodesGivenStartNodes() { - String handle = driver.getWindowHandle(); - BrowsingContext browsingContext = new BrowsingContext(driver, handle); - - driver.get("https://www.selenium.dev/selenium/web/formPage.html"); - - Script script = new Script(driver); - EvaluateResult result = - script.evaluateFunctionInBrowsingContext( - handle, - "document.querySelectorAll(\"form\")", - false, - Optional.of(ResultOwnership.ROOT)); - - EvaluateResultSuccess resultSuccess = (EvaluateResultSuccess) result; - List startNodes = new ArrayList<>(); - - RemoteValue remoteValue = resultSuccess.getResult(); - List remoteValues = (List) remoteValue.getValue().get(); - - remoteValues.forEach( - value -> - startNodes.add( - new RemoteReference(RemoteReference.Type.SHARED_ID, value.getSharedId().get()))); - - LocateNodeParameters parameters = - new LocateNodeParameters(Locator.css("input")) - .setStartNodes(startNodes) - .setMaxNodeCount(50); - - List elements = browsingContext.locateNodes(parameters); - Assertions.assertEquals(35, elements.size()); - } - - @Test - @Disabled - void canLocateNodesInAGivenSandbox() { - String sandbox = "sandbox"; - BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); - - browsingContext.navigate("https://www.selenium.dev/selenium/web/xhtmlTest.html", ReadinessState.COMPLETE); - - LocateNodeParameters parameters = - new LocateNodeParameters(Locator.css("div")) - .setSandbox(sandbox) - .setMaxNodeCount(1); - - List elements = browsingContext.locateNodes(parameters); - - String nodeId = elements.get(0).getSharedId().get(); - - List arguments = new ArrayList<>(); - - LocalValue value = LocalValue.mapValue(Map.of("sharedId", LocalValue.stringValue(nodeId))); - arguments.add(value); - - Script script = new Script(driver); - - // Since the node was present in the sandbox, the script run in the same sandbox should be able - // to retrieve it - EvaluateResult result = - script.callFunctionInBrowsingContext( - driver.getWindowHandle(), - sandbox, - "function(){ return arguments[0]; }", - true, - Optional.of(arguments), - Optional.empty(), - Optional.empty()); - - Map sharedIdMap = - (Map) ((EvaluateResultSuccess) result).getResult().getValue().get(); - - String sharedId = (String) ((RemoteValue) sharedIdMap.get("sharedId")).getValue().get(); - Assertions.assertEquals(nodeId, sharedId); - } -} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java deleted file mode 100644 index 8050892d27ca..000000000000 --- a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java +++ /dev/null @@ -1,112 +0,0 @@ -package dev.selenium.bidirectional.webdriver_bidi; - -import dev.selenium.BaseTest; -import java.time.Duration; -import java.time.temporal.ChronoUnit; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.Alert; -import org.openqa.selenium.By; -import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.UsernameAndPassword; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.bidi.module.Network; -import org.openqa.selenium.bidi.network.AddInterceptParameters; -import org.openqa.selenium.bidi.network.InterceptPhase; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.firefox.FirefoxOptions; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -class NetworkCommandsTest extends BaseTest { - - @BeforeEach - public void setup() { - FirefoxOptions options = new FirefoxOptions(); - options.setCapability("webSocketUrl", true); - driver = new FirefoxDriver(options); - wait = new WebDriverWait(driver, Duration.ofSeconds(10)); - } - - @Test - @Disabled - void canAddIntercept() { - try (Network network = new Network(driver)) { - String intercept = - network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)); - Assertions.assertNotNull(intercept); - } - } - - @Test - @Disabled - void canRemoveIntercept() { - try (Network network = new Network(driver)) { - String intercept = - network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)); - Assertions.assertNotNull(intercept); - network.removeIntercept(intercept); - } - } - - @Test - @Disabled - void canContinueWithAuthCredentials() { - try (Network network = new Network(driver)) { - network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)); - network.onAuthRequired( - responseDetails -> - network.continueWithAuth( - responseDetails.getRequest().getRequestId(), - new UsernameAndPassword("admin", "admin"))); - driver.get("https://the-internet.herokuapp.com/basic_auth"); - String successMessage = "Congratulations! You must have the proper credentials."; - WebElement elementMessage = driver.findElement(By.tagName("p")); - Assertions.assertEquals(successMessage, elementMessage.getText()); - } - } - - @Test - @Disabled - void canContinueWithoutAuthCredentials() { - try (Network network = new Network(driver)) { - network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)); - network.onAuthRequired( - responseDetails -> - // Does not handle the alert - network.continueWithAuthNoCredentials(responseDetails.getRequest().getRequestId())); - driver.get("https://the-internet.herokuapp.com/basic_auth"); - Alert alert = wait.until(ExpectedConditions.alertIsPresent()); - alert.dismiss(); - Assertions.assertTrue(driver.getPageSource().contains("Not authorized")); - } - } - - @Test - @Disabled - void canCancelAuth() { - try (Network network = new Network(driver)) { - network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)); - network.onAuthRequired( - responseDetails -> - // Does not handle the alert - network.cancelAuth(responseDetails.getRequest().getRequestId())); - driver.get("https://the-internet.herokuapp.com/basic_auth"); - Assertions.assertTrue(driver.getPageSource().contains("Not authorized")); - } - } - - @Test - @Disabled - void canFailRequest() { - try (Network network = new Network(driver)) { - network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)); - network.onBeforeRequestSent( - responseDetails -> network.failRequest(responseDetails.getRequest().getRequestId())); - driver.manage().timeouts().pageLoadTimeout(Duration.of(5, ChronoUnit.SECONDS)); - Assertions.assertThrows(TimeoutException.class, () -> driver.get("https://the-internet.herokuapp.com/basic_auth")); - } - } -} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java deleted file mode 100644 index d00d5af9ce8d..000000000000 --- a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package dev.selenium.bidirectional.webdriver_bidi; - -import dev.selenium.BaseTest; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.Cookie; -import org.openqa.selenium.bidi.module.Network; -import org.openqa.selenium.bidi.network.BeforeRequestSent; -import org.openqa.selenium.bidi.network.ResponseDetails; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.firefox.FirefoxOptions; - -class NetworkEventsTest extends BaseTest { - - @BeforeEach - public void setup() { - FirefoxOptions options = new FirefoxOptions(); - options.setCapability("webSocketUrl", true); - driver = new FirefoxDriver(options); - } - - @Test - void canListenToBeforeRequestSentEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (Network network = new Network(driver)) { - CompletableFuture future = new CompletableFuture<>(); - network.onBeforeRequestSent(future::complete); - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - - BeforeRequestSent requestSent = future.get(5, TimeUnit.SECONDS); - String windowHandle = driver.getWindowHandle(); - Assertions.assertEquals(windowHandle, requestSent.getBrowsingContextId()); - Assertions.assertEquals("get", requestSent.getRequest().getMethod().toLowerCase()); - } - } - - @Test - void canListenToResponseStartedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (Network network = new Network(driver)) { - CompletableFuture future = new CompletableFuture<>(); - network.onResponseStarted(future::complete); - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - - ResponseDetails response = future.get(5, TimeUnit.SECONDS); - String windowHandle = driver.getWindowHandle(); - - Assertions.assertEquals(windowHandle, response.getBrowsingContextId()); - Assertions.assertEquals("get", response.getRequest().getMethod().toLowerCase()); - Assertions.assertEquals(200L, response.getResponseData().getStatus()); - } - } - - @Test - void canListenToResponseCompletedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (Network network = new Network(driver)) { - CompletableFuture future = new CompletableFuture<>(); - network.onResponseCompleted(future::complete); - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - - ResponseDetails response = future.get(5, TimeUnit.SECONDS); - String windowHandle = driver.getWindowHandle(); - - Assertions.assertEquals(windowHandle, response.getBrowsingContextId()); - Assertions.assertEquals("get", response.getRequest().getMethod().toLowerCase()); - Assertions.assertEquals(200L, response.getResponseData().getStatus()); - } - } - - @Test - void canListenToResponseCompletedEventWithCookie() - throws ExecutionException, InterruptedException, TimeoutException { - try (Network network = new Network(driver)) { - CompletableFuture future = new CompletableFuture<>(); - - driver.get("https://www.selenium.dev/selenium/web/blankPage"); - driver.manage().addCookie(new Cookie("foo", "bar")); - network.onBeforeRequestSent(future::complete); - driver.navigate().refresh(); - - BeforeRequestSent requestSent = future.get(5, TimeUnit.SECONDS); - String windowHandle = driver.getWindowHandle(); - - Assertions.assertEquals(windowHandle, requestSent.getBrowsingContextId()); - Assertions.assertEquals("get", requestSent.getRequest().getMethod().toLowerCase()); - - Assertions.assertEquals("foo", requestSent.getRequest().getCookies().get(0).getName()); - Assertions.assertEquals("bar", requestSent.getRequest().getCookies().get(0).getValue().getValue()); - } - } - - @Test - void canListenToOnAuthRequiredEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (Network network = new Network(driver)) { - CompletableFuture future = new CompletableFuture<>(); - network.onAuthRequired(future::complete); - driver.get("https://the-internet.herokuapp.com/basic_auth"); - - ResponseDetails response = future.get(5, TimeUnit.SECONDS); - String windowHandle = driver.getWindowHandle(); - Assertions.assertEquals(windowHandle, response.getBrowsingContextId()); - Assertions.assertEquals("get", response.getRequest().getMethod().toLowerCase()); - Assertions.assertEquals(401L, response.getResponseData().getStatus()); - } - } -} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java deleted file mode 100644 index 7346049cfd9e..000000000000 --- a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package dev.selenium.bidirectional.webdriver_bidi; - -import dev.selenium.BaseTest; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; -import org.openqa.selenium.bidi.module.Script; -import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; -import org.openqa.selenium.bidi.script.LocalValue; -import org.openqa.selenium.bidi.script.Message; -import org.openqa.selenium.bidi.script.RealmInfo; -import org.openqa.selenium.bidi.script.RealmType; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.firefox.FirefoxOptions; - -class ScriptEventsTest extends BaseTest { - - @BeforeEach - public void setup() { - FirefoxOptions options = new FirefoxOptions(); - options.setCapability("webSocketUrl", true); - driver = new FirefoxDriver(options); - } - - @Test - void canListenToChannelMessage() - throws ExecutionException, InterruptedException, TimeoutException { - try (Script script = new Script(driver)) { - CompletableFuture future = new CompletableFuture<>(); - script.onMessage(future::complete); - - script.callFunctionInBrowsingContext( - driver.getWindowHandle(), - "(channel) => channel('foo')", - false, - Optional.of(List.of(LocalValue.channelValue("channel_name"))), - Optional.empty(), - Optional.empty()); - - Message message = future.get(5, TimeUnit.SECONDS); - Assertions.assertEquals("channel_name", message.getChannel()); - } - } - - @Test - @DisabledOnOs(value = OS.MAC, disabledReason = "Works locally, times out on CI") - void canListenToRealmCreatedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (Script script = new Script(driver)) { - CompletableFuture future = new CompletableFuture<>(); - script.onRealmCreated(future::complete); - - BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); - - context.navigate("https://www.selenium.dev/selenium/blankPage"); - RealmInfo realmInfo = future.get(5, TimeUnit.SECONDS); - Assertions.assertNotNull(realmInfo.getRealmId()); - Assertions.assertEquals(RealmType.WINDOW, realmInfo.getRealmType()); - } - } - - @Test - @Disabled - void canListenToRealmDestroyedEvent() - throws ExecutionException, InterruptedException, TimeoutException { - try (Script script = new Script(driver)) { - CompletableFuture future = new CompletableFuture<>(); - script.onRealmDestroyed(future::complete); - - BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); - - context.close(); - RealmInfo realmInfo = future.get(5, TimeUnit.SECONDS); - Assertions.assertNotNull(realmInfo.getRealmId()); - Assertions.assertEquals(RealmType.WINDOW, realmInfo.getRealmType()); - } - } -} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java deleted file mode 100644 index 2e1ab65e9355..000000000000 --- a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java +++ /dev/null @@ -1,494 +0,0 @@ -package dev.selenium.bidirectional.webdriver_bidi; - -import dev.selenium.BaseTest; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.WindowType; -import org.openqa.selenium.bidi.module.LogInspector; -import org.openqa.selenium.bidi.module.Script; -import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; -import org.openqa.selenium.bidi.browsingcontext.ReadinessState; -import org.openqa.selenium.bidi.log.ConsoleLogEntry; -import org.openqa.selenium.bidi.script.ChannelValue; -import org.openqa.selenium.bidi.script.EvaluateResult; -import org.openqa.selenium.bidi.script.EvaluateResultExceptionValue; -import org.openqa.selenium.bidi.script.EvaluateResultSuccess; -import org.openqa.selenium.bidi.script.LocalValue; -import org.openqa.selenium.bidi.script.ObjectLocalValue; -import org.openqa.selenium.bidi.script.PrimitiveProtocolValue; -import org.openqa.selenium.bidi.script.RealmInfo; -import org.openqa.selenium.bidi.script.RealmType; -import org.openqa.selenium.bidi.script.RemoteReference; -import org.openqa.selenium.bidi.script.ResultOwnership; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.firefox.FirefoxOptions; - -class ScriptTest extends BaseTest { - - @BeforeEach - public void setup() { - FirefoxOptions options = new FirefoxOptions(); - options.setCapability("webSocketUrl", true); - driver = new FirefoxDriver(options); - } - - @Test - void canCallFunction() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - List arguments = new ArrayList<>(); - arguments.add(PrimitiveProtocolValue.numberValue(22)); - - Map value = new HashMap<>(); - value.put("some_property", LocalValue.numberValue(42)); - LocalValue thisParameter = LocalValue.objectValue(value); - - arguments.add(thisParameter); - - EvaluateResult result = - script.callFunctionInBrowsingContext( - id, - "function processWithPromise(argument) {\n" - + " return new Promise((resolve, reject) => {\n" - + " setTimeout(() => {\n" - + " resolve(argument + this.some_property);\n" - + " }, 1000)\n" - + " })\n" - + "}", - true, - Optional.of(arguments), - Optional.of(thisParameter), - Optional.of(ResultOwnership.ROOT)); - - EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; - Assertions.assertEquals(64L, (Long) successResult.getResult().getValue().get()); - } - } - - @Test - void canCallFunctionWithDeclaration() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - EvaluateResult result = - script.callFunctionInBrowsingContext( - id, "()=>{return 1+2;}", false, Optional.empty(), Optional.empty(), Optional.empty()); - EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; - Assertions.assertEquals(3L, (Long) successResult.getResult().getValue().get()); - } - } - - @Test - void canCallFunctionWithArguments() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - List arguments = new ArrayList<>(); - LocalValue value1 = PrimitiveProtocolValue.stringValue("ARGUMENT_STRING_VALUE"); - LocalValue value2 = PrimitiveProtocolValue.numberValue(42); - arguments.add(value1); - arguments.add(value2); - - EvaluateResult result = - script.callFunctionInBrowsingContext( - id, - "(...args)=>{return args}", - false, - Optional.of(arguments), - Optional.empty(), - Optional.empty()); - - EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; - Assertions.assertEquals(2, ((List) successResult.getResult().getValue().get()).size()); - } - } - - @Test - void canCallFunctionWithAwaitPromise() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - EvaluateResult result = - script.callFunctionInBrowsingContext( - id, - "async function() {{\n" - + " await new Promise(r => setTimeout(() => r(), 0));\n" - + " return \"SOME_DELAYED_RESULT\";\n" - + " }}", - true, - Optional.empty(), - Optional.empty(), - Optional.empty()); - EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; - Assertions.assertEquals("SOME_DELAYED_RESULT", (String) successResult.getResult().getValue().get()); - } - } - - @Test - void canCallFunctionWithThisParameter() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - Map value = new HashMap<>(); - value.put("some_property", PrimitiveProtocolValue.numberValue(42)); - LocalValue thisParameter = LocalValue.objectValue(value); - - EvaluateResult result = - script.callFunctionInBrowsingContext( - id, - "function(){return this.some_property}", - false, - Optional.empty(), - Optional.of(thisParameter), - Optional.empty()); - - EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; - Assertions.assertEquals("number", successResult.getResult().getType()); - Assertions.assertEquals(42L, (Long) successResult.getResult().getValue().get()); - } - } - - @Test - void canCallFunctionWithOwnershipRoot() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - EvaluateResult result = - script.callFunctionInBrowsingContext( - id, - "async function(){return {a:1}}", - true, - Optional.empty(), - Optional.empty(), - Optional.of(ResultOwnership.ROOT)); - - EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; - Assertions.assertTrue(successResult.getResult().getHandle().isPresent()); - } - } - - @Test - void canCallFunctionThatThrowsException() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - EvaluateResult result = - script.callFunctionInBrowsingContext( - id, - "))) !!@@## some invalid JS script (((", - false, - Optional.empty(), - Optional.empty(), - Optional.empty()); - EvaluateResultExceptionValue exception = (EvaluateResultExceptionValue) result; - Assertions.assertEquals("error", exception.getExceptionDetails().getException().getType()); - Assertions.assertEquals( - "SyntaxError: expected expression, got ')'", exception.getExceptionDetails().getText()); - } - } - - @Test - void canCallFunctionInASandBox() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - EvaluateResult result = - script.callFunctionInBrowsingContext( - id, - "sandbox", - "() => window.foo", - true, - Optional.empty(), - Optional.empty(), - Optional.empty()); - - Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); - } - } - - @Test - void canCallFunctionInARealm() { - String tab = driver.getWindowHandle(); - try (Script script = new Script(tab, driver)) { - List realms = script.getAllRealms(); - String realmId = realms.get(0).getRealmId(); - - EvaluateResult result = script.callFunctionInRealm( - realmId, - "() => { window.foo = 3; }", - true, - Optional.empty(), - Optional.empty(), - Optional.empty()); - - Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); - } - } - - @Test - void canEvaluateScript() { - String id = driver.getWindowHandle(); - - try (Script script = new Script(id, driver)) { - EvaluateResult result = - script.evaluateFunctionInBrowsingContext(id, "1 + 2", true, Optional.empty()); - - EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; - Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); - Assertions.assertEquals(3L, (Long) successResult.getResult().getValue().get()); - } - } - - @Test - void canEvaluateScriptThatThrowsException() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - EvaluateResult result = - script.evaluateFunctionInBrowsingContext( - id, "))) !!@@## some invalid JS script (((", false, Optional.empty()); - - EvaluateResultExceptionValue exception = (EvaluateResultExceptionValue) result; - Assertions.assertEquals("error", exception.getExceptionDetails().getException().getType()); - Assertions.assertEquals( - "SyntaxError: expected expression, got ')'", exception.getExceptionDetails().getText()); - } - } - - @Test - void canEvaluateScriptWithResulWithOwnership() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - EvaluateResult result = - script.evaluateFunctionInBrowsingContext( - id, "Promise.resolve({a:1})", true, Optional.of(ResultOwnership.ROOT)); - - EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; - Assertions.assertTrue(successResult.getResult().getHandle().isPresent()); - } - } - - @Test - void canEvaluateInASandBox() { - String id = driver.getWindowHandle(); - try (Script script = new Script(id, driver)) { - EvaluateResult result = - script.evaluateFunctionInBrowsingContext( - id, "sandbox", "window.foo", true, Optional.empty()); - - - Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); - } - } - - @Test - void canEvaluateInARealm() { - String tab = driver.getWindowHandle(); - try (Script script = new Script(tab, driver)) { - List realms = script.getAllRealms(); - String realmId = realms.get(0).getRealmId(); - - EvaluateResult result = - script.evaluateFunctionInRealm( - realmId, "window.foo", true, Optional.empty()); - - Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); - } - } - - @Test - void canDisownHandle() { - String window = driver.getWindowHandle(); - try (Script script = new Script(window, driver)) { - BrowsingContext context = new BrowsingContext(driver, window); - - context.navigate("https://www.selenium.dev/selenium/web/dynamic.html", ReadinessState.COMPLETE); - - driver.findElement(By.id("adder")).click(); - - getLocatedElement(driver, By.id("box0")); - - EvaluateResult result = - script.evaluateFunctionInBrowsingContext( - window, "document.querySelector('.redbox');", false, Optional.of(ResultOwnership.ROOT)); - String boxId = ((EvaluateResultSuccess)result).getResult().getHandle().get(); - - script.disownBrowsingContextScript( - window, List.of(boxId)); - - LocalValue value = - LocalValue.remoteReference( - RemoteReference.Type.HANDLE, boxId); - - // Since the handle is now eligible for garbage collections, it is no longer available to be used. - Assertions.assertThrows(WebDriverException.class, () -> script.callFunctionInBrowsingContext( - window, - "arg => arg.a", - false, Optional.of(List.of(value)), - Optional.empty(), - Optional.empty())); - } - } - - @Test - void canDisownHandleInARealm() { - String window = driver.getWindowHandle(); - try (Script script = new Script(window, driver)) { - BrowsingContext context = new BrowsingContext(driver, window); - - context.navigate("https://www.selenium.dev/selenium/web/dynamic.html", ReadinessState.COMPLETE); - - driver.findElement(By.id("adder")).click(); - - getLocatedElement(driver, By.id("box0")); - - List realms = script.getAllRealms(); - String realmId = realms.get(0).getRealmId(); - - // Retrieve the handle for the element added to DOM - EvaluateResult result = - script.evaluateFunctionInBrowsingContext( - window, "document.querySelector('.redbox');", false, Optional.of(ResultOwnership.ROOT)); - String boxId = ((EvaluateResultSuccess)result).getResult().getHandle().get(); - - LocalValue value = - LocalValue.remoteReference( - RemoteReference.Type.HANDLE, boxId); - - EvaluateResult checkHandle = script.callFunctionInBrowsingContext( - window, - "arg => arg.a", - false, Optional.of(List.of(value)), - Optional.empty(), - Optional.empty()); - - // The handle is present in memory, else it would result in exception - Assertions.assertEquals(EvaluateResult.Type.SUCCESS, checkHandle.getResultType()); - - // Useful to memory management in a dynamic webpage where DOM mutations happen often - script.disownRealmScript(realmId, List.of(boxId)); - - // Since the handle is now eligible for garbage collections, it is no longer available to be used. - Assertions.assertThrows(WebDriverException.class, () -> script.callFunctionInBrowsingContext( - window, - "arg => arg.a", - false, Optional.of(List.of(value)), - Optional.empty(), - Optional.empty())); - } - } - - @Test - void canGetAllRealms() { - String firstWindow = driver.getWindowHandle(); - String secondWindow = driver.switchTo().newWindow(WindowType.WINDOW).getWindowHandle(); - try (Script script = new Script(firstWindow, driver)) { - List realms = script.getAllRealms(); - Assertions.assertEquals(2, realms.size()); - } - } - - @Test - void canGetRealmByType() { - String firstWindow = driver.getWindowHandle(); - String secondWindow = driver.switchTo().newWindow(WindowType.WINDOW).getWindowHandle(); - try (Script script = new Script(firstWindow, driver)) { - List realms = script.getRealmsByType(RealmType.WINDOW); - Assertions.assertEquals(2, realms.size()); - } - } - - @Test - void canGetRealmInBrowsingContext() { - String windowId = driver.getWindowHandle(); - String tabId = driver.switchTo().newWindow(WindowType.TAB).getWindowHandle(); - try (Script script = new Script(windowId, driver)) { - List realms = script.getRealmsInBrowsingContext(tabId); - Assertions.assertEquals(1, realms.size()); - } - } - - @Test - void canGetRealmInBrowsingContextByType() { - String windowId = driver.getWindowHandle(); - String tabId = driver.switchTo().newWindow(WindowType.TAB).getWindowHandle(); - try (Script script = new Script(windowId, driver)) { - List windowRealms = - script.getRealmsInBrowsingContextByType(windowId, RealmType.WINDOW); - Assertions.assertEquals(1, windowRealms.size()); - } - } - - @Test - void canAddPreloadScript() throws ExecutionException, InterruptedException, TimeoutException { - try (Script script = new Script(driver)) { - String id = - script.addPreloadScript("() => {{ console.log('{preload_script_console_text}') }}"); - - Assertions.assertNotNull(id); - - try (LogInspector logInspector = new LogInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - logInspector.onConsoleEntry(future::complete); - - driver.get("https://www.selenium.dev/selenium/blankPage"); - - ConsoleLogEntry logEntry = future.get(5, TimeUnit.SECONDS); - - Assertions.assertEquals("{preload_script_console_text}", logEntry.getText()); - } - } - } - - @Test - void canAddPreloadScriptWithArguments() { - try (Script script = new Script(driver)) { - String id = - script.addPreloadScript( - "(channel) => channel('will_be_send', 'will_be_ignored')", - List.of(new ChannelValue("channel_name"))); - Assertions.assertNotNull(id); - } - } - - @Test - void canAddPreloadScriptInASandbox() { - try (Script script = new Script(driver)) { - String id = script.addPreloadScript("() => { window.bar=2; }", "sandbox"); - Assertions.assertNotNull(id); - driver.get("https://www.selenium.dev/selenium/blankPage"); - - EvaluateResult result = - script.evaluateFunctionInBrowsingContext( - driver.getWindowHandle(), "sandbox", "window.bar", true, Optional.empty()); - Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); - } - } - - @Test - void canRemovePreloadScript() throws ExecutionException, InterruptedException, TimeoutException { - try (Script script = new Script(driver)) { - String id = - script.addPreloadScript("() => {{ console.log('{preload_script_console_text}') }}"); - - Assertions.assertNotNull(id); - - try (LogInspector logInspector = new LogInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - logInspector.onConsoleEntry(future::complete); - - script.removePreloadScript(id); - - driver.get("https://www.selenium.dev/selenium/blankPage"); - - Assertions.assertThrows(TimeoutException.class, () -> future.get(5, TimeUnit.SECONDS)); - } - } - } -} diff --git a/examples/javascript/test/bidirectional/bidi.spec.js b/examples/javascript/test/bidirectional/bidi.spec.js deleted file mode 100644 index ca3655667bd2..000000000000 --- a/examples/javascript/test/bidirectional/bidi.spec.js +++ /dev/null @@ -1,52 +0,0 @@ -const {suite} = require('selenium-webdriver/testing'); -const assert = require("assert"); -const firefox = require('selenium-webdriver/firefox'); -const LogInspector = require('selenium-webdriver/bidi/logInspector'); -const BrowsingContext = require('selenium-webdriver/bidi/browsingContext'); -const {until} = require('selenium-webdriver'); - -suite(function (env) { - describe('Integration Tests', function () { - let driver - - beforeEach(async function () { - driver = await env - .builder() - .setFirefoxOptions(new firefox.Options().enableBidi()) - .build() - }) - - afterEach(async function () { - await driver.quit() - }) - - it('test navigate and listen to errors', async function () { - let logEntry = null - const inspector = await LogInspector(driver) - await inspector.onJavascriptException(function (log) { - logEntry = log - }) - - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - let info = await browsingContext.navigate('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') - - assert.notEqual(browsingContext.id, null) - assert.notEqual(info.navigationId, null) - assert(info.url.includes('/bidi/logEntryAdded.html')) - - await driver.wait(until.urlIs('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html')) - await driver.findElement({id: 'jsException'}).click() - - assert.equal(logEntry.text, 'Error: Not working') - assert.equal(logEntry.type, 'javascript') - assert.equal(logEntry.level, 'error') - - await inspector.close() - await browsingContext.close() - }) - }) -}, {browsers: ['firefox']}) \ No newline at end of file diff --git a/examples/javascript/test/bidirectional/browsingContext.spec.js b/examples/javascript/test/bidirectional/browsingContext.spec.js deleted file mode 100644 index 1235e24a78f0..000000000000 --- a/examples/javascript/test/bidirectional/browsingContext.spec.js +++ /dev/null @@ -1,437 +0,0 @@ -const {suite} = require('selenium-webdriver/testing'); -const assert = require("assert"); -const firefox = require('selenium-webdriver/firefox'); -const BrowsingContext = require('selenium-webdriver/bidi/browsingContext'); -const {By, until} = require("selenium-webdriver"); - -suite(function (env) { - describe('Browsing Context', function () { - let driver - let startIndex = 0 - let endIndex = 5 - let pdfMagicNumber = 'JVBER' - let pngMagicNumber = 'iVBOR' - - beforeEach(async function () { - driver = await env - .builder() - .setFirefoxOptions(new firefox.Options().enableBidi()) - .build() - }) - - afterEach(async function () { - await driver.quit() - }) - - it('test create a browsing context for given id', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - assert.equal(browsingContext.id, id) - }) - - it('test create a window', async function () { - const browsingContext = await BrowsingContext(driver, { - type: 'window', - }) - assert.notEqual(browsingContext.id, null) - }) - - it('test create a window with a reference context', async function () { - const browsingContext = await BrowsingContext(driver, { - type: 'window', - referenceContext: await driver.getWindowHandle(), - }) - assert.notEqual(browsingContext.id, null) - }) - - it('test create a tab', async function () { - const browsingContext = await BrowsingContext(driver, { - type: 'tab', - }) - assert.notEqual(browsingContext.id, null) - }) - - it('test create a tab with a reference context', async function () { - const browsingContext = await BrowsingContext(driver, { - type: 'tab', - referenceContext: await driver.getWindowHandle(), - }) - assert.notEqual(browsingContext.id, null) - }) - - it('test navigate to a url', async function () { - const browsingContext = await BrowsingContext(driver, { - type: 'tab', - }) - - let info = await browsingContext.navigate('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') - - assert.notEqual(browsingContext.id, null) - assert.notEqual(info.navigationId, null) - assert(info.url.includes('/bidi/logEntryAdded.html')) - }) - - it('test navigate to a url with readiness state', async function () { - const browsingContext = await BrowsingContext(driver, { - type: 'tab', - }) - - const info = await browsingContext.navigate( - 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html', - 'complete' - ) - - assert.notEqual(browsingContext.id, null) - assert.notEqual(info.navigationId, null) - assert(info.url.includes('/bidi/logEntryAdded.html')) - }) - - it('test get tree with a child', async function () { - const browsingContextId = await driver.getWindowHandle() - const parentWindow = await BrowsingContext(driver, { - browsingContextId: browsingContextId, - }) - await parentWindow.navigate('https://www.selenium.dev/selenium/web/iframes.html', 'complete') - - const contextInfo = await parentWindow.getTree() - assert.equal(contextInfo.children.length, 1) - assert.equal(contextInfo.id, browsingContextId) - assert(contextInfo.children[0]['url'].includes('formPage.html')) - }) - - it('test get tree with depth', async function () { - const browsingContextId = await driver.getWindowHandle() - const parentWindow = await BrowsingContext(driver, { - browsingContextId: browsingContextId, - }) - await parentWindow.navigate('https://www.selenium.dev/selenium/web/iframes.html', 'complete') - - const contextInfo = await parentWindow.getTree(0) - assert.equal(contextInfo.children, null) - assert.equal(contextInfo.id, browsingContextId) - }) - - it('test close a window', async function () { - const window1 = await BrowsingContext(driver, {type: 'window'}) - const window2 = await BrowsingContext(driver, {type: 'window'}) - - await window2.close() - - assert.doesNotThrow(async function () { - await window1.getTree() - }) - await assert.rejects(window2.getTree(), {message: 'no such frame'}) - }) - - it('test close a tab', async function () { - const tab1 = await BrowsingContext(driver, {type: 'tab'}) - const tab2 = await BrowsingContext(driver, {type: 'tab'}) - - await tab2.close() - - assert.doesNotThrow(async function () { - await tab1.getTree() - }) - await assert.rejects(tab2.getTree(), {message: 'no such frame'}) - }) - - it('can print PDF with all valid parameters', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get("https://www.selenium.dev/selenium/web/printPage.html") - const result = await browsingContext.printPage({ - orientation: 'landscape', - scale: 1, - background: true, - width: 30, - height: 30, - top: 1, - bottom: 1, - left: 1, - right: 1, - shrinkToFit: true, - pageRanges: ['1-2'], - }) - - let base64Code = result.data.slice(0, 5) - assert.strictEqual(base64Code, 'JVBER') - }) - - it('can take box screenshot', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - const response = await browsingContext.captureBoxScreenshot(5, 5, 10, 10) - - const base64code = response.slice(0, 5) - assert.equal(base64code, 'iVBOR') - }) - - it('can take element screenshot', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get("https://www.selenium.dev/selenium/web/formPage.html") - const element = await driver.findElement(By.id('checky')) - const elementId = await element.getId() - const response = await browsingContext.captureElementScreenshot(elementId) - - const base64code = response.slice(0, 5) - assert.equal(base64code, 'iVBOR') - }) - - it('can activate a browsing context', async function () { - const id = await driver.getWindowHandle() - const window1 = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await BrowsingContext(driver, { - type: 'window', - }) - - const result = await driver.executeScript('return document.hasFocus();') - - assert.equal(result, false) - - await window1.activate() - const result2 = await driver.executeScript('return document.hasFocus();') - - assert.equal(result2, true) - }) - - it('can handle user prompt', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get("https://www.selenium.dev/selenium/web/alerts.html") - - await driver.findElement(By.id('alert')).click() - - await driver.wait(until.alertIsPresent()) - - await browsingContext.handleUserPrompt() - - const result = await driver.getTitle() - - assert.equal(result, 'Testing Alerts') - }) - - it('can accept user prompt', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get("https://www.selenium.dev/selenium/web/alerts.html") - - await driver.findElement(By.id('alert')).click() - - await driver.wait(until.alertIsPresent()) - - await browsingContext.handleUserPrompt(true) - - const result = await driver.getTitle() - - assert.equal(result, 'Testing Alerts') - }) - - it('can dismiss user prompt', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get("https://www.selenium.dev/selenium/web/alerts.html") - - await driver.findElement(By.id('alert')).click() - - await driver.wait(until.alertIsPresent()) - - await browsingContext.handleUserPrompt(false) - - const result = await driver.getTitle() - - assert.equal(result, 'Testing Alerts') - }) - - it('can pass user text to user prompt', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get("https://www.selenium.dev/selenium/web/alerts.html") - - await driver.findElement(By.id('prompt')).click() - - await driver.wait(until.alertIsPresent()) - - const userText = 'Selenium automates browsers' - - await browsingContext.handleUserPrompt(undefined, userText) - - const result = await driver.getPageSource() - assert.equal(result.includes(userText), true) - }) - - it('can accept user prompt with user text', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get("https://www.selenium.dev/selenium/web/alerts.html") - - await driver.findElement(By.id('prompt')).click() - - await driver.wait(until.alertIsPresent()) - - const userText = 'Selenium automates browsers' - - await browsingContext.handleUserPrompt(true, userText) - - const result = await driver.getPageSource() - assert.equal(result.includes(userText), true) - }) - - it('can dismiss user prompt with user text', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get("https://www.selenium.dev/selenium/web/alerts.html") - - await driver.findElement(By.id('alert')).click() - - await driver.wait(until.alertIsPresent()) - - const userText = 'Selenium automates browsers' - - await browsingContext.handleUserPrompt(false, userText) - - const result = await driver.getPageSource() - assert.equal(result.includes(userText), false) - }) - - it('can set viewport', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get("https://www.selenium.dev/selenium/web/blank.html") - - await browsingContext.setViewport(250, 300) - - const result = await driver.executeScript('return [window.innerWidth, window.innerHeight];') - assert.equal(result[0], 250) - assert.equal(result[1], 300) - }) - - it('can reload a browsing context', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - const result = await browsingContext.navigate( - 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html', 'complete') - - await browsingContext.reload(undefined, 'complete') - assert.notEqual(result.navigationId, null) - assert(result.url.includes('/bidi/logEntryAdded.html')) - }) - - it('can take screenshot', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - const response = await browsingContext.captureScreenshot() - const base64code = response.slice(startIndex, endIndex) - assert.equal(base64code, pngMagicNumber) - }) - - it('can traverse browser history', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await browsingContext.navigate('https://www.selenium.dev/selenium/web/formPage.html', 'complete') - - await driver.wait(until.elementLocated(By.id('imageButton'))).submit() - await driver.wait(until.titleIs('We Arrive Here'), 2500) - - await browsingContext.traverseHistory(-1) - - const source = await driver.getPageSource() - - assert.equal(source.includes('We Leave From Here'), true) - }) - - it('can navigate back in browser history', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await browsingContext.navigate('https://www.selenium.dev/selenium/web/formPage.html', 'complete') - - await driver.wait(until.elementLocated(By.id('imageButton'))).submit() - await driver.wait(until.titleIs('We Arrive Here'), 2500) - - await browsingContext.back() - - const source = await driver.getPageSource() - - assert.equal(source.includes('We Leave From Here'), true) - }) - - it('can navigate forward in browser history', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await browsingContext.navigate('https://www.selenium.dev/selenium/web/formPage.html', 'complete') - - await driver.wait(until.elementLocated(By.id('imageButton'))).submit() - await driver.wait(until.titleIs('We Arrive Here'), 2500) - - await browsingContext.back() - - const source = await driver.getPageSource() - - assert.equal(source.includes('We Leave From Here'), true) - - await browsingContext.forward() - - await driver.wait(until.titleIs('We Arrive Here'), 2500) - }); - - it.skip('Get All Top level browsing contexts', async () => { - const id = await driver.getWindowHandle() - const window1 = await BrowsingContext(driver, { - browsingContextId: id, - }) - await BrowsingContext(driver, { type: 'window' }) - const res = await window1.getTopLevelContexts() - assert.equal(res.length, 2) - }) - }) -}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/browsingContextInspector.spec.js b/examples/javascript/test/bidirectional/browsingContextInspector.spec.js deleted file mode 100644 index d542072dca87..000000000000 --- a/examples/javascript/test/bidirectional/browsingContextInspector.spec.js +++ /dev/null @@ -1,122 +0,0 @@ -const {suite} = require('selenium-webdriver/testing'); -const assert = require("assert"); -const firefox = require('selenium-webdriver/firefox'); -const BrowsingContextInspector = require("selenium-webdriver/bidi/browsingContextInspector"); -const BrowsingContext = require("selenium-webdriver/bidi/browsingContext"); - -suite(function (env) { - describe('Browsing Context Inspector', function () { - let driver - - beforeEach(async function () { - driver = await env - .builder() - .setFirefoxOptions(new firefox.Options().enableBidi()) - .build() - }) - - afterEach(async function () { - await driver.quit() - }) - - it('can listen to window browsing context created event', async function () { - let contextInfo = null - const browsingContextInspector = await BrowsingContextInspector(driver) - await browsingContextInspector.onBrowsingContextCreated((entry) => { - contextInfo = entry - }) - - await driver.switchTo().newWindow('window') - const windowHandle = await driver.getWindowHandle() - assert.equal(contextInfo.id, windowHandle) - assert.equal(contextInfo.url, 'about:blank') - assert.equal(contextInfo.children, null) - assert.equal(contextInfo.parentBrowsingContext, null) - }) - - it('can listen to tab browsing context created event', async function () { - let contextInfo = null - const browsingContextInspector = await BrowsingContextInspector(driver) - await browsingContextInspector.onBrowsingContextCreated((entry) => { - contextInfo = entry - }) - - await driver.switchTo().newWindow('tab') - const tabHandle = await driver.getWindowHandle() - - assert.equal(contextInfo.id, tabHandle) - assert.equal(contextInfo.url, 'about:blank') - assert.equal(contextInfo.children, null) - assert.equal(contextInfo.parentBrowsingContext, null) - }) - - it('can listen to dom content loaded event', async function () { - const browsingContextInspector = await BrowsingContextInspector(driver) - let navigationInfo = null - await browsingContextInspector.onDomContentLoaded((entry) => { - navigationInfo = entry - }) - - const browsingContext = await BrowsingContext(driver, { - browsingContextId: await driver.getWindowHandle(), - }) - await browsingContext.navigate('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html', 'complete') - - assert.equal(navigationInfo.browsingContextId, browsingContext.id) - assert.strictEqual(navigationInfo.url.includes('/bidi/logEntryAdded.html'), true) - }) - - it('can listen to browsing context loaded event', async function () { - let navigationInfo = null - const browsingContextInspector = await BrowsingContextInspector(driver) - - await browsingContextInspector.onBrowsingContextLoaded((entry) => { - navigationInfo = entry - }) - const browsingContext = await BrowsingContext(driver, { - browsingContextId: await driver.getWindowHandle(), - }) - await browsingContext.navigate('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html', 'complete') - - assert.equal(navigationInfo.browsingContextId, browsingContext.id) - assert.strictEqual(navigationInfo.url.includes('/bidi/logEntryAdded.html'), true) - }) - - it('can listen to fragment navigated event', async function () { - let navigationInfo = null - const browsingContextInspector = await BrowsingContextInspector(driver) - - const browsingContext = await BrowsingContext(driver, { - browsingContextId: await driver.getWindowHandle(), - }) - await browsingContext.navigate('https://www.selenium.dev/selenium/web/linked_image.html', 'complete') - - await browsingContextInspector.onFragmentNavigated((entry) => { - navigationInfo = entry - }) - - await browsingContext.navigate('https://www.selenium.dev/selenium/web/linked_image.html#linkToAnchorOnThisPage', 'complete') - - assert.equal(navigationInfo.browsingContextId, browsingContext.id) - assert.strictEqual(navigationInfo.url.includes('linkToAnchorOnThisPage'), true) - }) - - it('can listen to browsing context destroyed event', async function () { - let contextInfo = null - const browsingContextInspector = await BrowsingContextInspector(driver) - await browsingContextInspector.onBrowsingContextDestroyed((entry) => { - contextInfo = entry - }) - - await driver.switchTo().newWindow('window') - - const windowHandle = await driver.getWindowHandle() - await driver.close() - - assert.equal(contextInfo.id, windowHandle) - assert.equal(contextInfo.url, 'about:blank') - assert.equal(contextInfo.children, null) - assert.equal(contextInfo.parentBrowsingContext, null) - }) - }) -}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/emulateGeoLocation.spec.js b/examples/javascript/test/bidirectional/emulateGeoLocation.spec.js deleted file mode 100644 index 776a156a18e3..000000000000 --- a/examples/javascript/test/bidirectional/emulateGeoLocation.spec.js +++ /dev/null @@ -1,33 +0,0 @@ -const { By, Key, Browser} = require('selenium-webdriver'); -const { suite } = require('selenium-webdriver/testing'); -const assert = require("assert"); - -suite(function(env) { - describe('Emulate geolocation', function() { - let driver; - - before(async function() { - driver = await env.builder().build(); - }); - - after(() => driver.quit()); - - it('Emulate coordinates of Tokyo', async function() { - const cdpConnection = await driver.createCDPConnection('page'); - - // Latitude and longitude of Tokyo, Japan - const coordinates = { - latitude: 35.689487, - longitude: 139.691706, - accuracy: 100, - }; - - await cdpConnection.execute( - "Emulation.setGeolocationOverride", - coordinates - ); - await driver.get("https://kawasaki-india.com/dealer-locator/"); - }); - - }); -},{ browsers: [Browser.CHROME, Browser.FIREFOX]}); \ No newline at end of file diff --git a/examples/javascript/test/bidirectional/input.spec.js b/examples/javascript/test/bidirectional/input.spec.js deleted file mode 100644 index 64556fd13a63..000000000000 --- a/examples/javascript/test/bidirectional/input.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -const {suite} = require('selenium-webdriver/testing') -const assert = require("assert") -const firefox = require('selenium-webdriver/firefox') -const {By, Key} = require("selenium-webdriver") -const Input = require('selenium-webdriver/bidi/input') - -suite(function (env) { - describe('Input module', function () { - let driver - - beforeEach(async function () { - driver = await env - .builder() - .setFirefoxOptions(new firefox.Options().enableBidi()) - .build() - }) - - afterEach(async function () { - await driver.quit() - }) - - it('can perform input action', async function () { - const browsingContextId = await driver.getWindowHandle() - const input = await Input(driver) - await driver.get('https://www.selenium.dev/selenium/web/formSelectionPage.html') - - let options = await driver.findElements(By.tagName('option')) - - const actions = driver.actions().click(options[1]).keyDown(Key.SHIFT).click(options[3]).keyUp(Key.SHIFT).getSequences() - - await input.perform(browsingContextId, actions) - - let showButton = await driver.findElement(By.name('showselected')) - showButton.click() - - let resultElement = await driver.findElement(By.id('result')) - await resultElement.getText().then(function (text) { - assert(text.includes('oquefort parmigiano cheddar')) - }) - }) - - it('can execute release in browsing context', async function () { - const browsingContextId = await driver.getWindowHandle() - const input = await Input(driver) - await driver.get('https://www.selenium.dev/selenium/web/bidi/release_action.html') - - let inputTextBox = await driver.findElement(By.id('keys')) - - await driver.executeScript('arguments[0].focus()', inputTextBox) - - const actions = await driver.actions().keyDown('a').keyDown('b').getSequences() - - await input.perform(browsingContextId, actions) - - await driver.executeScript('resetEvents()') - - await input.release(browsingContextId) - - const events = await driver.executeScript('return allEvents.events') - - assert.strictEqual(events[0].code, 'KeyB') - assert.strictEqual(events[1].code, 'KeyA') - }) - }) -}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/locateNodes.spec.js b/examples/javascript/test/bidirectional/locateNodes.spec.js deleted file mode 100644 index 53818c26c332..000000000000 --- a/examples/javascript/test/bidirectional/locateNodes.spec.js +++ /dev/null @@ -1,245 +0,0 @@ -const {suite} = require('selenium-webdriver/testing'); -const assert = require("assert"); -const firefox = require('selenium-webdriver/firefox'); -const {BrowsingContext} = require("selenium-webdriver"); -const {Locator} = require("selenium-webdriver/bidi/browsingContext"); -const {LocalValue} = require("selenium-webdriver/bidi/protocolValue"); -const {ArgumentValue} = require("selenium-webdriver/bidi/argumentValue"); - -suite(function (env) { - describe('Locate Nodes', function () { - let driver - - beforeEach(async function () { - driver = await env - .builder() - .setFirefoxOptions(new firefox.Options().enableBidi()) - .build() - }) - - afterEach(async function () { - await driver.quit() - }) - - xit('can locate nodes', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - - const element = await browsingContext.locateNodes(Locator.css('div')) - assert.strictEqual(element.length, 13) - }) - - xit('can locate node', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - - const element = await browsingContext.locateNode(Locator.css('div')) - assert.strictEqual(element.type, 'node') - }) - - xit('can locate node with css locator', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - - const elements = await browsingContext.locateNodes(Locator.css('div.extraDiv, div.content'), 1) - const element = elements[0] - assert.strictEqual(element.type, 'node') - assert.notEqual(element.value, undefined) - assert.strictEqual(element.value.localName, 'div') - assert.strictEqual(element.value.attributes.class, 'content') - assert.notEqual(element.sharedId, undefined) - }) - - xit('can locate node with xpath locator', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - const elements = await browsingContext.locateNodes(Locator.xpath('/html/body/div[2]'), 1) - - const element = elements[0] - assert.strictEqual(element.type, 'node') - assert.notEqual(element.value, undefined) - assert.strictEqual(element.value.localName, 'div') - assert.strictEqual(element.value.attributes.class, 'content') - assert.notEqual(element.sharedId, undefined) - }) - - xit('can locate node with inner test locator', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - const elements = await browsingContext.locateNodes(Locator.innerText('Spaced out'), 1) - - const element = elements[0] - assert.strictEqual(element.type, 'node') - assert.notEqual(element.value, undefined) - assert.strictEqual(element.value.localName, 'div') - assert.strictEqual(element.value.attributes.class, 'content') - assert.notEqual(element.sharedId, undefined) - }) - - xit('can locate node with max node count', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - - const elements = await browsingContext.locateNodes(Locator.css('div'), 4) - assert.strictEqual(elements.length, 4) - }) - - xit('can locate node with none ownership value', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - - const elements = await browsingContext.locateNodes(Locator.css('div'), undefined, 'none') - assert.strictEqual(elements.length, 13) - assert.strictEqual(elements[0].handle, null) - }) - - xit('can locate node with root ownership value', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - - const elements = await browsingContext.locateNodes(Locator.css('div'), undefined, 'root') - assert.strictEqual(elements.length, 13) - assert.notEqual(elements[0].handle, null) - }) - - xit('can locate node with given start nodes', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get(Pages.formPage) - - const script = await ScriptManager(id, driver) - - const result = await script.evaluateFunctionInBrowsingContext( - id, - "document.querySelectorAll('form')", - false, - 'root', - ) - - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.notEqual(result.realmId, null) - assert.equal(result.result.type, 'nodelist') - - const value = result.result.value - - const startNodes = [] - - value.forEach((node) => { - startNodes.push(new ReferenceValue(node.handle, node.sharedId)) - }) - - const elements = await browsingContext.locateNodes( - Locator.css('input'), - 50, - 'none', - undefined, - undefined, - startNodes, - ) - - assert.strictEqual(elements.length, 35) - }) - - xit('can locate nodes in a given sandbox', async function () { - const sandbox = 'sandbox' - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await browsingContext.navigate('https://www.selenium.dev/selenium/web/xhtmlTest.html', 'complete') - - const elements = await browsingContext.locateNodes(Locator.css('div'), 1, undefined, sandbox) - - assert.strictEqual(elements.length, 1) - - const nodeId = elements[0].sharedId - - const script = await ScriptManager(id, driver) - - let argumentValues = [] - let mapValue = { sharedId: LocalValue.createStringValue(nodeId) } - argumentValues.push(new ArgumentValue(LocalValue.createMapValue(mapValue))) - - const response = await script.callFunctionInBrowsingContext( - id, - 'function(){ return arguments[0]; }', - false, - argumentValues, - undefined, - undefined, - sandbox, - ) - - assert.equal(response.resultType, EvaluateResultType.SUCCESS) - assert.equal(response.result.type, 'map') - - const sharedId = response.result.value.sharedId - - assert.strictEqual(sharedId.value, nodeId) - }) - - xit('can find element', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - - const element = await browsingContext.locateElement(Locator.css('p')) - const elementText = await element.getText() - assert.strictEqual(elementText, 'Open new window') - }) - - xit('can find elements', async function () { - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - - const elements = await browsingContext.locateElements(Locator.css('div')) - assert.strictEqual(elements.length, 13) - - const elementText = await elements[0].getText() - assert.strictEqual(elementText.includes('Open new window'), true) - }) - }) -}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/network_commands.spec.js b/examples/javascript/test/bidirectional/network_commands.spec.js deleted file mode 100644 index 9be1942d0986..000000000000 --- a/examples/javascript/test/bidirectional/network_commands.spec.js +++ /dev/null @@ -1,82 +0,0 @@ -const {suite} = require('selenium-webdriver/testing') -const assert = require("assert") -const firefox = require('selenium-webdriver/firefox') -const Network = require('selenium-webdriver/bidi/network') -const {until, By} = require('selenium-webdriver') -const {AddInterceptParameters} = require("selenium-webdriver/bidi/addInterceptParameters"); -const {InterceptPhase} = require("selenium-webdriver/bidi/interceptPhase"); - -suite(function (env) { - describe('Network commands', function () { - let driver - let network - - beforeEach(async function () { - driver = await env - .builder() - .setFirefoxOptions(new firefox.Options().enableBidi()) - .build() - - network = await Network(driver) - }) - - afterEach(async function () { - await network.close() - await driver.quit() - }) - - xit('can add intercept', async function () { - const intercept = await network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)) - assert.notEqual(intercept, null) - }) - - xit('can remove intercept', async function () { - const network = await Network(driver) - const intercept = await network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)) - assert.notEqual(intercept, null) - - await network.removeIntercept(intercept) - }) - - xit('can continue with auth credentials ', async function () { - await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)) - - await network.authRequired(async (event) => { - await network.continueWithAuth(event.request.request, 'admin','admin') - }) - await driver.get('https://the-internet.herokuapp.com/basic_auth') - - const successMessage = 'Congratulations! You must have the proper credentials.' - - let elementMessage = await driver.findElement(By.tagName('p')).getText() - assert.equal(elementMessage, successMessage) - }) - - xit('can continue without auth credentials ', async function () { - await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)) - - await network.authRequired(async (event) => { - await network.continueWithAuthNoCredentials(event.request.request) - }) - - await driver.get('https://the-internet.herokuapp.com/basic_auth') - const alert = await driver.wait(until.alertIsPresent()) - await alert.dismiss() - - let source = await driver.getPageSource() - assert.equal(source.includes('Not authorized'), true) - }) - - xit('can cancel auth ', async function () { - await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)) - - await network.authRequired(async (event) => { - await network.cancelAuth(event.request.request) - }) - - await driver.get('https://the-internet.herokuapp.com/basic_auth') - let source = await driver.getPageSource() - assert.equal(source.includes('Not authorized'), true) - }) - }) -}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/network_events.spec.js b/examples/javascript/test/bidirectional/network_events.spec.js deleted file mode 100644 index 7f5a09b15427..000000000000 --- a/examples/javascript/test/bidirectional/network_events.spec.js +++ /dev/null @@ -1,111 +0,0 @@ -const {suite} = require('selenium-webdriver/testing'); -const assert = require("assert"); -const firefox = require('selenium-webdriver/firefox'); -const Network = require("selenium-webdriver/bidi/network"); -const {until} = require("selenium-webdriver"); - -suite(function (env) { - describe('Network events', function () { - let driver - - beforeEach(async function () { - driver = await env - .builder() - .setFirefoxOptions(new firefox.Options().enableBidi()) - .build() - }) - - afterEach(async function () { - await driver.quit() - }) - - it('can listen to event before request is sent', async function () { - let beforeRequestEvent = null - const network = await Network(driver) - await network.beforeRequestSent(function (event) { - beforeRequestEvent = event - }) - - await driver.get('https://www.selenium.dev/selenium/web/blank.html') - - assert.equal(beforeRequestEvent.request.method, 'GET') - const url = beforeRequestEvent.request.url - assert.equal(url, await driver.getCurrentUrl()) - }) - - it('can request cookies', async function () { - const network = await Network(driver) - let beforeRequestEvent = null - await network.beforeRequestSent(function (event) { - beforeRequestEvent = event - }) - - await driver.get('https://www.selenium.dev/selenium/web/blank.html') - await driver.manage().addCookie({ - name: 'north', - value: 'biryani', - }) - await driver.navigate().refresh() - - assert.equal(beforeRequestEvent.request.method, 'GET') - assert.equal(beforeRequestEvent.request.cookies[0].name, 'north') - assert.equal(beforeRequestEvent.request.cookies[0].value.value, 'biryani') - const url = beforeRequestEvent.request.url - assert.equal(url, await driver.getCurrentUrl()) - - await driver.manage().addCookie({ - name: 'south', - value: 'dosa', - }) - await driver.navigate().refresh() - - assert.equal(beforeRequestEvent.request.cookies[1].name, 'south') - assert.equal(beforeRequestEvent.request.cookies[1].value.value, 'dosa') - }) - - it('can redirect http equiv', async function () { - let beforeRequestEvent = [] - const network = await Network(driver) - await network.beforeRequestSent(function (event) { - beforeRequestEvent.push(event) - }) - - await driver.get('http://www.selenium.dev/selenium/web/bidi/redirected_http_equiv.html') - await driver.wait(until.urlContains('redirected.html'), 1000) - - assert.equal(beforeRequestEvent[0].request.method, 'GET') - assert(beforeRequestEvent[0].request.url.includes('redirected_http_equiv.html')) - assert.equal(beforeRequestEvent[2].request.method, 'GET') - assert(beforeRequestEvent[2].request.url.includes('redirected.html')) - }) - - it('can subscribe to response started', async function () { - let onResponseStarted = [] - const network = await Network(driver) - await network.responseStarted(function (event) { - onResponseStarted.push(event) - }) - - await driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') - - assert.equal(onResponseStarted[0].request.method, 'GET') - assert.equal(onResponseStarted[0].request.url, await driver.getCurrentUrl()) - assert.equal(onResponseStarted[0].response.url, await driver.getCurrentUrl()) - }) - - it('can subscribe to response completed', async function () { - let onResponseCompleted = [] - const network = await Network(driver) - await network.responseCompleted(function (event) { - onResponseCompleted.push(event) - }) - - await driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') - - assert.equal(onResponseCompleted[0].request.method, 'GET') - assert.equal(onResponseCompleted[0].request.url, await driver.getCurrentUrl()) - assert.equal(onResponseCompleted[0].response.fromCache, false) - assert.equal(onResponseCompleted[0].response.status, 200) - }) - }) -}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/script_commands.spec.js b/examples/javascript/test/bidirectional/script_commands.spec.js deleted file mode 100644 index b8ce14bf5ca8..000000000000 --- a/examples/javascript/test/bidirectional/script_commands.spec.js +++ /dev/null @@ -1,478 +0,0 @@ -const {suite} = require('selenium-webdriver/testing') -const assert = require("assert") -const firefox = require('selenium-webdriver/firefox') -const {By, until} = require("selenium-webdriver") -const ScriptManager = require('selenium-webdriver/bidi/scriptManager') -const {ResultOwnership} = require("selenium-webdriver/bidi/resultOwnership"); -const {ArgumentValue} = require("selenium-webdriver/bidi/argumentValue"); -const {LocalValue, RemoteReferenceType, ReferenceValue} = require("selenium-webdriver/bidi/protocolValue"); -const {EvaluateResultType} = require("selenium-webdriver/bidi/evaluateResult"); -const BrowsingContext = require("selenium-webdriver/bidi/browsingContext"); -const {WebDriverError} = require("selenium-webdriver/lib/error"); -const {RealmType} = require("selenium-webdriver/bidi/realmInfo"); -const LogInspector = require("selenium-webdriver/bidi/logInspector"); - -suite(function (env) { - describe('Script commands', function () { - let driver - - beforeEach(async function () { - driver = await env - .builder() - .setFirefoxOptions(new firefox.Options().enableBidi()) - .build() - }) - - afterEach(async function () { - await driver.quit() - }) - - it('can call function', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - let argumentValues = [] - let value = new ArgumentValue(LocalValue.createNumberValue(22)) - argumentValues.push(value) - - let mapValue = {some_property: LocalValue.createNumberValue(42)} - let thisParameter = new ArgumentValue(LocalValue.createObjectValue(mapValue)).asMap() - - const result = await manager.callFunctionInBrowsingContext( - id, - 'function processWithPromise(argument) {' + - 'return new Promise((resolve, reject) => {' + - 'setTimeout(() => {' + - 'resolve(argument + this.some_property);' + - '}, 1000)' + - '})' + - '}', - true, - argumentValues, - thisParameter, - ResultOwnership.ROOT) - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.equal(result.result.value, 64) - }) - - it('can call function with declaration', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const result = await manager.callFunctionInBrowsingContext(id, '()=>{return 1+2;}', false) - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.equal(result.result.value, 3) - }) - - it('can call function to get element', async function () { - await driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded') - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const result = await manager.callFunctionInBrowsingContext( - id, - '() => document.getElementById("consoleLog")', - false, - ) - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.notEqual(result.realmId, null) - assert.equal(result.result.type, 'node') - assert.notEqual(result.result.value, null) - assert.notEqual(result.result.value.nodeType, null) - }) - - it('can call function with arguments', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - let argumentValues = [] - let value1 = new ArgumentValue(LocalValue.createStringValue('ARGUMENT_STRING_VALUE')) - let value2 = new ArgumentValue(LocalValue.createNumberValue(42)) - argumentValues.push(value1) - argumentValues.push(value2) - - const result = await manager.callFunctionInBrowsingContext( - id, - '(...args)=>{return args}', - false, - argumentValues, - ) - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.equal(result.result.value.length, 2) - }) - - it('can call function with await promise', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const result = await manager.callFunctionInBrowsingContext( - id, - 'async function() {{\n' + - ' await new Promise(r => setTimeout(() => r(), 0));\n' + - ' return "SOME_DELAYED_RESULT";\n' + - ' }}', - true, - ) - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.equal(result.result.value, 'SOME_DELAYED_RESULT') - }) - - it('can call function with await promise false', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const result = await manager.callFunctionInBrowsingContext( - id, - 'async function() {{\n' + - ' await new Promise(r => setTimeout(() => r(), 0));\n' + - ' return "SOME_DELAYED_RESULT";\n' + - ' }}', - false, - ) - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.equal(result.result.type, 'promise') - }) - - it('can call function with this parameter', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - let mapValue = {some_property: LocalValue.createNumberValue(42)} - let thisParameter = new ArgumentValue(LocalValue.createObjectValue(mapValue)).asMap() - - const result = await manager.callFunctionInBrowsingContext( - id, - 'function(){return this.some_property}', - false, - null, - thisParameter, - ) - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.equal(result.result.value, 42) - }) - - it('can call function with ownership root', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const result = await manager.callFunctionInBrowsingContext( - id, - 'async function(){return {a:1}}', - true, - null, - null, - ResultOwnership.ROOT, - ) - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - }) - - it('can call function with ownership none', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const result = await manager.callFunctionInBrowsingContext( - id, - 'async function(){return {a:1}}', - true, - null, - null, - ResultOwnership.NONE, - ) - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.notEqual(result.realmId, null) - assert.equal(result.result.handle, undefined) - assert.notEqual(result.result.value, null) - }) - - it('can call function that throws exception', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const result = await manager.callFunctionInBrowsingContext(id, '))) !!@@## some invalid JS script (((', false) - assert.equal(result.resultType, EvaluateResultType.EXCEPTION) - - assert.equal(result.exceptionDetails.exception.type, 'error') - assert.equal(result.exceptionDetails.text, "SyntaxError: expected expression, got ')'") - assert.equal(result.exceptionDetails.columnNumber, 39) - assert.equal(result.exceptionDetails.stackTrace.callFrames.length, 0) - }) - - it('can call function in a sandbox', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - await manager.callFunctionInBrowsingContext(id, '() => { window.foo = 2; }', true, null, null, null, 'sandbox') - - const resultInSandbox = await manager.callFunctionInBrowsingContext( - id, - '() => window.foo', - true, - null, - null, - null, - 'sandbox', - ) - - assert.equal(resultInSandbox.resultType, EvaluateResultType.SUCCESS) - }) - - it('can call function in a realm', async function () { - const firstTab = await driver.getWindowHandle() - await driver.switchTo().newWindow('tab') - const manager = await ScriptManager(firstTab, driver) - - const realms = await manager.getAllRealms() - const realmId = realms[0].realmId - - await manager.callFunctionInRealm(realmId, '() => { window.foo = 3; }', true) - - const result = await manager.callFunctionInRealm(realmId, '() => window.foo', true) - - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.equal(result.result.value, 3) - }) - - it('can evaluate script', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const result = await manager.evaluateFunctionInBrowsingContext(id, '1 + 2', true) - - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.equal(result.result.value, 3) - }) - - it('can evaluate script that throws exception', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const result = await manager.evaluateFunctionInBrowsingContext( - id, - '))) !!@@## some invalid JS script (((', - false, - ) - - assert.equal(result.resultType, EvaluateResultType.EXCEPTION) - assert.equal(result.exceptionDetails.exception.type, 'error') - assert.equal(result.exceptionDetails.text, "SyntaxError: expected expression, got ')'") - assert.equal(result.exceptionDetails.columnNumber, 39) - assert.equal(result.exceptionDetails.stackTrace.callFrames.length, 0) - }) - - it('can evaluate script with result ownership', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const result = await manager.evaluateFunctionInBrowsingContext( - id, - 'Promise.resolve({a:1})', - true, - ResultOwnership.ROOT, - ) - - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.notEqual(result.result.handle, null) - }) - - it('can evaluate in a sandbox', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - await manager.evaluateFunctionInBrowsingContext(id, 'window.foo = 2', true, null, 'sandbox') - - const resultInSandbox = await manager.evaluateFunctionInBrowsingContext(id, 'window.foo', true, null, 'sandbox') - - assert.equal(resultInSandbox.resultType, EvaluateResultType.SUCCESS) - assert.equal(resultInSandbox.result.value, 2) - }) - - it('can evaluate in a realm', async function () { - const firstTab = await driver.getWindowHandle() - await driver.switchTo().newWindow('tab') - const manager = await ScriptManager(firstTab, driver) - - const realms = await manager.getAllRealms() - const realmId = realms[0].realmId - - await manager.evaluateFunctionInRealm(realmId, 'window.foo = 3', true) - - const result = await manager.evaluateFunctionInRealm(realmId, 'window.foo', true) - - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.equal(result.result.value, 3) - }) - - it('can disown handles', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const browsingContext = await BrowsingContext(driver, {browsingContextId: id}) - - const info = await browsingContext.navigate( - 'https://www.selenium.dev/selenium/web/dynamic.html', - 'complete' - ) - - await driver.findElement(By.id('adder')).click() - - await driver.wait(until.elementLocated(By.id('box0')), 10000) - - const evaluateResult = await manager.evaluateFunctionInBrowsingContext( - id, - "document.querySelector('.redbox');", - false, - ResultOwnership.ROOT, - ) - - assert.equal(evaluateResult.resultType, EvaluateResultType.SUCCESS) - let boxId = evaluateResult.result.handle - - await manager.disownBrowsingContextScript(id, boxId) - - await manager.callFunctionInBrowsingContext(id, 'arg => arg.a', false).catch((error) => { - assert(error instanceof WebDriverError) - }) - }) - - it('can disown handles in realm', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const browsingContext = await BrowsingContext(driver, {browsingContextId: id}) - - const info = await browsingContext.navigate( - 'https://www.selenium.dev/selenium/web/dynamic.html', - 'complete' - ) - - await driver.findElement(By.id('adder')).click() - - await driver.wait(until.elementLocated(By.id('box0')), 10000) - - const realms = await manager.getAllRealms() - const realmId = realms[0].realmId - - const evaluateResult = await manager.evaluateFunctionInBrowsingContext( - id, - "document.querySelector('.redbox');", - false, - ResultOwnership.ROOT, - ) - - assert.equal(evaluateResult.resultType, EvaluateResultType.SUCCESS) - let boxId = evaluateResult.result.handle - - let argumentValues = [] - let value1 = new ArgumentValue(new ReferenceValue(RemoteReferenceType.HANDLE, boxId)) - argumentValues.push(value1) - let checkHandle = await manager.callFunctionInBrowsingContext(id, 'arg => arg.a', false, argumentValues) - - assert.equal(checkHandle.resultType, EvaluateResultType.SUCCESS) - - await manager.disownRealmScript(realmId, boxId) - - await manager.callFunctionInBrowsingContext(id, 'arg => arg.a', false).catch((error) => { - assert(error instanceof WebDriverError) - }) - }) - - it('can get all realms', async function () { - const firstWindow = await driver.getWindowHandle() - await driver.switchTo().newWindow('window') - const secondWindow = await driver.getWindowHandle() - const manager = await ScriptManager(firstWindow, driver) - - const realms = await manager.getAllRealms() - assert.equal(realms.length, 2) - }) - - it('can get realm by type', async function () { - const firstWindow = await driver.getWindowHandle() - await driver.switchTo().newWindow('window') - const secondWindow = await driver.getWindowHandle() - const manager = await ScriptManager(firstWindow, driver) - - const realms = await manager.getRealmsByType(RealmType.WINDOW) - assert.equal(realms.length, 2) - }) - - it('can get realm in browsing context', async function () { - const windowId = await driver.getWindowHandle() - await driver.switchTo().newWindow('tab') - const tabId = await driver.getWindowHandle() - const manager = await ScriptManager(windowId, driver) - - const realms = await manager.getRealmsInBrowsingContext(tabId) - - const tabRealm = realms[0] - assert.equal(tabRealm.realmType, RealmType.WINDOW) - }) - - it('can get realm in browsing context by type', async function () { - const windowId = await driver.getWindowHandle() - await driver.switchTo().newWindow('tab') - const manager = await ScriptManager(windowId, driver) - - const realms = await manager.getRealmsInBrowsingContextByType(windowId, RealmType.WINDOW) - - const windowRealm = realms[0] - assert.equal(windowRealm.realmType, RealmType.WINDOW) - }) - - it('can add preload script', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const scriptId = await manager.addPreloadScript('() => {{ console.log(\'{preload_script_console_text}\') }}') - - let logEntry = null - const inspector = await LogInspector(driver) - await inspector.onConsoleEntry(function (log) { - logEntry = log - }) - - await driver.get('https://www.selenium.dev/selenium/blank') - - assert.equal(logEntry.text, '{preload_script_console_text}') - }) - - it('can add preload script to sandbox', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - await manager.addPreloadScript('() => { window.bar = 2; }', undefined, 'sandbox') - - await driver.get('https://www.selenium.dev/selenium/blank') - - let result_in_sandbox = await manager.evaluateFunctionInBrowsingContext( - id, - 'window.bar', - true, - null, - 'sandbox', - ) - - assert.equal(result_in_sandbox.result.type, 'number') - assert.equal(result_in_sandbox.result.value, 2) - }) - - it('can remove preload script', async function () { - const id = await driver.getWindowHandle() - const manager = await ScriptManager(id, driver) - - const scriptId = await manager.addPreloadScript('() => {{ console.log(\'{preload_script_console_text}\') }}') - - let logEntry = null - const inspector = await LogInspector(driver) - await inspector.onConsoleEntry(function (log) { - logEntry = log - }) - - await manager.removePreloadScript(scriptId) - - await driver.get('https://www.selenium.dev/selenium/blank') - - assert.equal(logEntry, null) - }) - }) -}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/script_events.spec.js b/examples/javascript/test/bidirectional/script_events.spec.js deleted file mode 100644 index 3d3411387ce9..000000000000 --- a/examples/javascript/test/bidirectional/script_events.spec.js +++ /dev/null @@ -1,93 +0,0 @@ -const {suite} = require('selenium-webdriver/testing') -const assert = require("assert") -const firefox = require('selenium-webdriver/firefox') -const {ScriptManager, BrowsingContext} = require("selenium-webdriver") -const {ArgumentValue} = require("selenium-webdriver/bidi/argumentValue") -const {RealmType} = require("selenium-webdriver/bidi/realmInfo") -const {LocalValue, ChannelValue} = require("selenium-webdriver/bidi/protocolValue") -const {EvaluateResultType} = require("selenium-webdriver/bidi/evaluateResult"); - -suite(function (env) { - describe('Script events', function () { - let driver - - beforeEach(async function () { - driver = await env - .builder() - .setFirefoxOptions(new firefox.Options().enableBidi()) - .build() - }) - - afterEach(async function () { - await driver.quit() - }) - - it('can listen to channel message', async function () { - const manager = await ScriptManager(undefined, driver) - - let message = null - - await manager.onMessage((m) => { - message = m - }) - - let argumentValues = [] - let value = new ArgumentValue(LocalValue.createChannelValue(new ChannelValue('channel_name'))) - argumentValues.push(value) - - const result = await manager.callFunctionInBrowsingContext( - await driver.getWindowHandle(), - '(channel) => channel("foo")', - false, - argumentValues, - ) - assert.equal(result.resultType, EvaluateResultType.SUCCESS) - assert.notEqual(message, null) - assert.equal(message.channel, 'channel_name') - assert.equal(message.data.type, 'string') - assert.equal(message.data.value, 'foo') - }) - - it('can listen to realm created message', async function () { - const manager = await ScriptManager(undefined, driver) - - let realmInfo = null - - await manager.onRealmCreated((result) => { - realmInfo = result - }) - - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await browsingContext.navigate('https://www.selenium.dev/selenium/web/blank', 'complete') - - assert.notEqual(realmInfo, null) - assert.notEqual(realmInfo.realmId, null) - assert.equal(realmInfo.realmType, RealmType.WINDOW) - }) - - xit('can listen to realm destroyed message', async function () { - const manager = await ScriptManager(undefined, driver) - - let realmInfo = null - - await manager.onRealmDestroyed((result) => { - realmInfo = result - }) - - const id = await driver.getWindowHandle() - const browsingContext = await BrowsingContext(driver, { - browsingContextId: id, - }) - - await browsingContext.close() - - assert.notEqual(realmInfo, null) - assert.notEqual(realmInfo.realmId, null) - assert.equal(realmInfo.realmType, RealmType.WINDOW) - }) - }) -}, {browsers: ['firefox']}) diff --git a/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py b/examples/python/tests/bidi/chrome_devtools/test_logging.py similarity index 71% rename from examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py rename to examples/python/tests/bidi/chrome_devtools/test_logging.py index b7e7a89b728a..b65f668f6572 100644 --- a/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py +++ b/examples/python/tests/bidi/chrome_devtools/test_logging.py @@ -4,18 +4,6 @@ from selenium.webdriver.common.log import Log -@pytest.mark.trio -async def test_mutation(driver): - async with driver.bidi_connection() as session: - log = Log(driver, session) - - async with log.mutation_events() as event: - driver.get('https://www.selenium.dev/selenium/web/dynamic.html') - driver.find_element(By.ID, "reveal").click() - - assert event["element"] == driver.find_element(By.ID, "revealed") - - @pytest.mark.trio async def test_console_log(driver): driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') diff --git a/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py b/examples/python/tests/bidi/chrome_devtools/test_network.py similarity index 99% rename from examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py rename to examples/python/tests/bidi/chrome_devtools/test_network.py index be0aac66d444..3f42ca97237b 100644 --- a/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py +++ b/examples/python/tests/bidi/chrome_devtools/test_network.py @@ -5,6 +5,21 @@ from selenium.webdriver.common.devtools.v124.network import Headers +@pytest.mark.trio +async def test_basic_auth(driver): + async with driver.bidi_connection() as connection: + await connection.session.execute(connection.devtools.network.enable()) + + credentials = base64.b64encode("admin:admin".encode()).decode() + auth = {'authorization': 'Basic ' + credentials} + + await connection.session.execute(connection.devtools.network.set_extra_http_headers(Headers(auth))) + + driver.get('https://the-internet.herokuapp.com/basic_auth') + + success = driver.find_element(by=By.TAG_NAME, value='p') + assert success.text == 'Congratulations! You must have the proper credentials.' + @pytest.mark.trio async def test_set_cookie(driver): async with driver.bidi_connection() as connection: @@ -22,7 +37,6 @@ async def test_set_cookie(driver): assert cheese["value"] == "gouda" - @pytest.mark.trio async def test_performance(driver): driver.get('https://www.selenium.dev/selenium/web/frameset.html') @@ -36,19 +50,3 @@ async def test_performance(driver): assert metrics["DevToolsCommandDuration"] > 0 assert metrics["Frames"] == 12 - - -@pytest.mark.trio -async def test_basic_auth(driver): - async with driver.bidi_connection() as connection: - await connection.session.execute(connection.devtools.network.enable()) - - credentials = base64.b64encode("admin:admin".encode()).decode() - auth = {'authorization': 'Basic ' + credentials} - - await connection.session.execute(connection.devtools.network.set_extra_http_headers(Headers(auth))) - - driver.get('https://the-internet.herokuapp.com/basic_auth') - - success = driver.find_element(by=By.TAG_NAME, value='p') - assert success.text == 'Congratulations! You must have the proper credentials.' diff --git a/examples/python/tests/bidi/chrome_devtools/test_script.py b/examples/python/tests/bidi/chrome_devtools/test_script.py new file mode 100644 index 000000000000..b765183e46b1 --- /dev/null +++ b/examples/python/tests/bidi/chrome_devtools/test_script.py @@ -0,0 +1,15 @@ +import pytest +from selenium.webdriver.common.by import By +from selenium.webdriver.common.log import Log + + +@pytest.mark.trio +async def test_mutation(driver): + async with driver.bidi_connection() as session: + log = Log(driver, session) + + async with log.mutation_events() as event: + driver.get('https://www.selenium.dev/selenium/web/dynamic.html') + driver.find_element(By.ID, "reveal").click() + + assert event["element"] == driver.find_element(By.ID, "revealed") diff --git a/examples/python/tests/bidi/test_log.py b/examples/python/tests/bidi/test_log.py new file mode 100644 index 000000000000..c2269ba28379 --- /dev/null +++ b/examples/python/tests/bidi/test_log.py @@ -0,0 +1,51 @@ +import pytest +from selenium.webdriver.common.by import By +from selenium.webdriver.support.wait import WebDriverWait + + +@pytest.mark.driver_type("bidi") +def test_add_console_log_handler(driver): + driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + log_entries = [] + + driver.script.add_console_message_handler(log_entries.append) + + driver.find_element(By.ID, "consoleLog").click() + WebDriverWait(driver, 5).until(lambda _: log_entries) + assert log_entries[0].text == "Hello, world!" + + +@pytest.mark.driver_type("bidi") +def test_remove_console_log_handler(driver): + driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + log_entries = [] + + id = driver.script.add_console_message_handler(log_entries.append) + driver.script.remove_console_message_handler(id) + + driver.find_element(By.ID, "consoleLog").click() + assert len(log_entries) == 0 + + +@pytest.mark.driver_type("bidi") +def test_add_js_exception_handler(driver): + driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + log_entries = [] + + driver.script.add_javascript_error_handler(log_entries.append) + + driver.find_element(By.ID, "jsException").click() + WebDriverWait(driver, 5).until(lambda _: log_entries) + assert log_entries[0].text == "Error: Not working" + + +@pytest.mark.driver_type("bidi") +def test_remove_js_exception_handler(driver): + driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + log_entries = [] + + id = driver.script.add_javascript_error_handler(log_entries.append) + driver.script.remove_javascript_error_handler(id) + + driver.find_element(By.ID, "consoleLog").click() + assert len(log_entries) == 0 diff --git a/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py b/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py deleted file mode 100644 index 85f3b295d439..000000000000 --- a/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py +++ /dev/null @@ -1,44 +0,0 @@ -import base64 - -from selenium.webdriver.common.by import By - - -def test_set_cookie(driver): - cookie = {'name': 'cheese', - 'value': 'gouda', - 'domain': 'www.selenium.dev', - 'secure': True} - - driver.execute_cdp_cmd('Network.setCookie', cookie) - - driver.get('https://www.selenium.dev') - cheese = driver.get_cookie(cookie['name']) - - assert cheese['value'] == 'gouda' - - -def test_performance(driver): - driver.get('https://www.selenium.dev/selenium/web/frameset.html') - - driver.execute_cdp_cmd('Performance.enable', {}) - - metric_list = driver.execute_cdp_cmd('Performance.getMetrics', {})["metrics"] - - metrics = {metric["name"]: metric["value"] for metric in metric_list} - - assert metrics["DevToolsCommandDuration"] > 0 - assert metrics["Frames"] == 12 - - -def test_basic_auth(driver): - driver.execute_cdp_cmd("Network.enable", {}) - - credentials = base64.b64encode("admin:admin".encode()).decode() - headers = {'headers': {'authorization': 'Basic ' + credentials}} - - driver.execute_cdp_cmd('Network.setExtraHTTPHeaders', headers) - - driver.get('https://the-internet.herokuapp.com/basic_auth') - - success = driver.find_element(by=By.TAG_NAME, value='p') - assert success.text == 'Congratulations! You must have the proper credentials.' diff --git a/examples/python/tests/bidirectional/webdriver_bidi/test_browsing_context.py b/examples/python/tests/bidirectional/webdriver_bidi/test_browsing_context.py deleted file mode 100644 index 53b695b6fc83..000000000000 --- a/examples/python/tests/bidirectional/webdriver_bidi/test_browsing_context.py +++ /dev/null @@ -1,2 +0,0 @@ -from selenium import webdriver - diff --git a/examples/python/tests/bidirectional/webdriver_bidi/test_log.py b/examples/python/tests/bidirectional/webdriver_bidi/test_log.py deleted file mode 100644 index 53b695b6fc83..000000000000 --- a/examples/python/tests/bidirectional/webdriver_bidi/test_log.py +++ /dev/null @@ -1,2 +0,0 @@ -from selenium import webdriver - diff --git a/examples/python/tests/conftest.py b/examples/python/tests/conftest.py index 9cb9a9ed56e0..6a58e04cf799 100644 --- a/examples/python/tests/conftest.py +++ b/examples/python/tests/conftest.py @@ -13,8 +13,18 @@ @pytest.fixture(scope='function') -def driver(): - driver = webdriver.Chrome() +def driver(request): + marker = request.node.get_closest_marker("driver_type") + driver_type = marker.args[0] if marker else None + + if driver_type == "bidi": + options = webdriver.ChromeOptions() + options.enable_bidi = True + driver = webdriver.Chrome(options=options) + elif driver_type == "firefox": + driver = webdriver.Firefox() + else: + driver = webdriver.Chrome() yield driver @@ -23,7 +33,7 @@ def driver(): @pytest.fixture(scope='function') def chromedriver_bin(): - service = webdriver.chrome.service.Service() + service = webdriver.ChromeService() options = webdriver.ChromeOptions() options.browser_version = 'stable' yield webdriver.common.driver_finder.DriverFinder(service=service, options=options).get_driver_path() @@ -31,7 +41,7 @@ def chromedriver_bin(): @pytest.fixture(scope='function') def chrome_bin(): - service = webdriver.chrome.service.Service() + service = webdriver.ChromeService() options = webdriver.ChromeOptions() options.browser_version = 'stable' yield webdriver.common.driver_finder.DriverFinder(service=service, options=options).get_browser_path() @@ -39,7 +49,7 @@ def chrome_bin(): @pytest.fixture(scope='function') def edge_bin(): - service = webdriver.edge.service.Service() + service = webdriver.EdgeService() options = webdriver.EdgeOptions() options.browser_version = 'stable' yield webdriver.common.driver_finder.DriverFinder(service=service, options=options).get_browser_path() @@ -47,7 +57,7 @@ def edge_bin(): @pytest.fixture(scope='function') def firefox_bin(): - service = webdriver.firefox.service.Service() + service = webdriver.FirefoxService() options = webdriver.FirefoxOptions() options.browser_version = 'stable' yield webdriver.common.driver_finder.DriverFinder(service=service, options=options).get_browser_path() diff --git a/examples/ruby/spec/bidi/chrome_devtools/logging_spec.rb b/examples/ruby/spec/bidi/chrome_devtools/logging_spec.rb new file mode 100644 index 000000000000..c92f924faccf --- /dev/null +++ b/examples/ruby/spec/bidi/chrome_devtools/logging_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Logging' do + let(:driver) { start_session } + + it 'listens for console logs' do + driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + + logs = [] + driver.on_log_event(:console) { |log| logs << log.args.first } + + driver.find_element(id: 'consoleLog').click + driver.find_element(id: 'consoleError').click + + Selenium::WebDriver::Wait.new.until { logs.size > 1 } + expect(logs).to include 'Hello, world!' + expect(logs).to include 'I am console error' + end + + it 'listens for js exception' do + driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + + exceptions = [] + driver.on_log_event(:exception) { |exception| exceptions << exception } + + driver.find_element(id: 'jsException').click + + Selenium::WebDriver::Wait.new.until { exceptions.any? } + expect(exceptions.first&.description).to include 'Error: Not working' + end +end diff --git a/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb b/examples/ruby/spec/bidi/chrome_devtools/network_spec.rb similarity index 57% rename from examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb rename to examples/ruby/spec/bidi/chrome_devtools/network_spec.rb index 3974cd0ae0fa..b0673c90717a 100644 --- a/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb +++ b/examples/ruby/spec/bidi/chrome_devtools/network_spec.rb @@ -2,62 +2,67 @@ require 'spec_helper' -RSpec.describe 'Chrome DevTools' do +RSpec.describe 'Network' do let(:driver) { start_session } - it 'sets cookie' do - driver.devtools.network.set_cookie(name: 'cheese', - value: 'gouda', - domain: 'www.selenium.dev', - secure: true) + it 'does basic authentication' do + driver.register(username: 'admin', + password: 'admin', + uri: /herokuapp/) - driver.get('https://www.selenium.dev') - cheese = driver.manage.cookie_named('cheese') + driver.get('https://the-internet.herokuapp.com/basic_auth') - expect(cheese[:value]).to eq 'gouda' + expect(driver.find_element(tag_name: 'p').text).to eq('Congratulations! You must have the proper credentials.') end - it 'gets performance metrics' do - driver.get('https://www.selenium.dev/selenium/web/frameset.html') - - driver.devtools.performance.enable - - metric_list = driver.devtools.performance.get_metrics.dig('result', 'metrics') - - metrics = metric_list.each_with_object({}) do |metric, hash| - hash[metric['name']] = metric['value'] + it 'records network response' do + content_type = [] + driver.intercept do |request, &continue| + continue.call(request) do |response| + content_type << response.headers['content-type'] + end end - expect(metrics['DevToolsCommandDuration']).to be > 0 - expect(metrics['Frames']).to eq 12 + driver.get('https://www.selenium.dev/selenium/web/blank.html') + expect(content_type.first).to eq('text/html; charset=utf-8') end - it 'does basic authentication' do - driver.devtools.network.enable - - credentials = Base64.strict_encode64('admin:admin') + it 'transforms network response' do + driver.intercept do |request, &continue| + continue.call(request) do |response| + response.body = 'Creamy, delicious cheese!' if request.url.include?('blank') + end + end - driver.devtools.network.set_extra_http_headers(headers: {authorization: "Basic #{credentials}"}) + driver.get('https://www.selenium.dev/selenium/web/blank.html') + expect(driver.find_element(tag_name: 'body').text).to eq('Creamy, delicious cheese!') + end - driver.get('https://the-internet.herokuapp.com/basic_auth') + it 'intercepts network request' do + driver.intercept do |request, &continue| + uri = URI(request.url) + request.url = uri.to_s.gsub('one', 'two') if uri.path&.end_with?('one.js') + continue.call(request) + end - expect(driver.find_element(tag_name: 'p').text).to eq('Congratulations! You must have the proper credentials.') + driver.get('https://www.selenium.dev/selenium/web/devToolsRequestInterceptionTest.html') + driver.find_element(tag_name: 'button').click + expect(driver.find_element(id: 'result').text).to eq('two') end - it 'listens for console logs' do - driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + it 'gets performance metrics' do + driver.get('https://www.selenium.dev/selenium/web/frameset.html') - driver.devtools.runtime.enable + driver.devtools.performance.enable - logs = [] - driver.devtools.runtime.on(:console_api_called) do |params| - logs << params['args'].first['value'] - end + metric_list = driver.devtools.performance.get_metrics.dig('result', 'metrics') - driver.find_element(id: 'consoleLog').click + metrics = metric_list.each_with_object({}) do |metric, hash| + hash[metric['name']] = metric['value'] + end - Selenium::WebDriver::Wait.new.until { logs.any? } - expect(logs).to include 'Hello, world!' + expect(metrics['DevToolsCommandDuration']).to be > 0 + expect(metrics['Frames']).to eq 12 end it 'waits for downloads', except: {platform: :windows} do @@ -75,4 +80,16 @@ expect { Selenium::WebDriver::Wait.new.until { @completed } }.not_to raise_exception end + + it 'sets cookie' do + driver.devtools.network.set_cookie(name: 'cheese', + value: 'gouda', + domain: 'www.selenium.dev', + secure: true) + + driver.get('https://www.selenium.dev') + cheese = driver.manage.cookie_named('cheese') + + expect(cheese[:value]).to eq 'gouda' + end end diff --git a/examples/ruby/spec/bidi/chrome_devtools/scripts_spec.rb b/examples/ruby/spec/bidi/chrome_devtools/scripts_spec.rb new file mode 100644 index 000000000000..1012f2afd665 --- /dev/null +++ b/examples/ruby/spec/bidi/chrome_devtools/scripts_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Scripts' do + let(:driver) { start_session } + + it 'pins script' do + driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + element = driver.find_element(id: 'id1') + + key = driver.pin_script('return arguments;') + arguments = driver.execute_script(key, 1, true, element) + + expect(arguments).to eq([1, true, element]) + end + + it 'gets mutated elements' do + driver.get 'https://www.selenium.dev/selenium/web/dynamic.html' + + mutations = [] + driver.on_log_event(:mutation) { |mutation| mutations << mutation.element } + + driver.find_element(id: 'reveal').click + Selenium::WebDriver::Wait.new(timeout: 30).until { mutations.any? } + + expect(mutations).to include(driver.find_element(id: 'revealed')) + end +end diff --git a/examples/ruby/spec/bidi/logging_spec.rb b/examples/ruby/spec/bidi/logging_spec.rb new file mode 100644 index 000000000000..b07b93342628 --- /dev/null +++ b/examples/ruby/spec/bidi/logging_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper' + +RSpec.describe 'Logging' do + let(:driver) { start_bidi_session } + let(:wait) { Selenium::WebDriver::Wait.new(timeout: 2) } + + it 'adds console message handler' do + driver.navigate.to 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html' + log_entries = [] + + driver.script.add_console_message_handler { |log| log_entries << log } + + driver.find_element(id: 'consoleLog').click + wait.until { log_entries.any? } + expect(log_entries.first&.text).to eq 'Hello, world!' + end + + it 'removes console message handler' do + driver.navigate.to 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html' + log_entries = [] + + id = driver.script.add_console_message_handler { |log| log_entries << log } + driver.script.remove_console_message_handler(id) + + driver.find_element(id: 'consoleLog').click + expect(log_entries).to be_empty + end + + it 'adds JavaScript error handler' do + driver.navigate.to 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html' + log_entries = [] + + driver.script.add_javascript_error_handler { |error| log_entries << error } + + driver.find_element(id: 'jsException').click + wait.until { log_entries.any? } + expect(log_entries.first&.text).to eq 'Error: Not working' + end + + it 'removes JavaScript error handler' do + driver.navigate.to 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html' + log_entries = [] + + id = driver.script.add_javascript_error_handler { |error| log_entries << error } + driver.script.remove_javascript_error_handler(id) + + driver.find_element(id: 'jsException').click + expect(log_entries).to be_empty + end +end diff --git a/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb b/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb deleted file mode 100644 index 68bc6b29ad8e..000000000000 --- a/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb +++ /dev/null @@ -1,100 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'BiDi API' do - let(:driver) { start_session } - - it 'does basic authentication' do - driver.register(username: 'admin', - password: 'admin', - uri: /herokuapp/) - - driver.get('https://the-internet.herokuapp.com/basic_auth') - - expect(driver.find_element(tag_name: 'p').text).to eq('Congratulations! You must have the proper credentials.') - end - - it 'pins script' do - driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') - element = driver.find_element(id: 'id1') - - key = driver.pin_script('return arguments;') - arguments = driver.execute_script(key, 1, true, element) - - expect(arguments).to eq([1, true, element]) - end - - it 'gets mutated elements' do - driver.get 'https://www.selenium.dev/selenium/web/dynamic.html' - - mutations = [] - driver.on_log_event(:mutation) { |mutation| mutations << mutation.element } - - driver.find_element(id: 'reveal').click - Selenium::WebDriver::Wait.new(timeout: 30).until { mutations.any? } - - expect(mutations).to include(driver.find_element(id: 'revealed')) - end - - it 'listens for console logs' do - driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') - - logs = [] - driver.on_log_event(:console) { |log| logs << log.args.first } - - driver.find_element(id: 'consoleLog').click - driver.find_element(id: 'consoleError').click - - Selenium::WebDriver::Wait.new.until { logs.size > 1 } - expect(logs).to include 'Hello, world!' - expect(logs).to include 'I am console error' - end - - it 'listens for js exception' do - driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') - - exceptions = [] - driver.on_log_event(:exception) { |exception| exceptions << exception } - - driver.find_element(id: 'jsException').click - - Selenium::WebDriver::Wait.new.until { exceptions.any? } - expect(exceptions.first&.description).to include 'Error: Not working' - end - - it 'records network response' do - content_type = [] - driver.intercept do |request, &continue| - continue.call(request) do |response| - content_type << response.headers['content-type'] - end - end - - driver.get('https://www.selenium.dev/selenium/web/blank.html') - expect(content_type.first).to eq('text/html; charset=utf-8') - end - - it 'transforms network response' do - driver.intercept do |request, &continue| - continue.call(request) do |response| - response.body = 'Creamy, delicious cheese!' if request.url.include?('blank') - end - end - - driver.get('https://www.selenium.dev/selenium/web/blank.html') - expect(driver.find_element(tag_name: 'body').text).to eq('Creamy, delicious cheese!') - end - - it 'intercepts network request' do - driver.intercept do |request, &continue| - uri = URI(request.url) - request.url = uri.to_s.gsub('one', 'two') if uri.path&.end_with?('one.js') - continue.call(request) - end - - driver.get('https://www.selenium.dev/selenium/web/devToolsRequestInterceptionTest.html') - driver.find_element(tag_name: 'button').click - expect(driver.find_element(id: 'result').text).to eq('two') - end -end diff --git a/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb b/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb deleted file mode 100644 index 543f8c81fe43..000000000000 --- a/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Execute CDP' do - let(:driver) { start_session } - - it 'sets cookie' do - cookie = {name: 'cheese', - value: 'gouda', - domain: 'www.selenium.dev', - secure: true} - - driver.execute_cdp('Network.setCookie', **cookie) - - driver.get('https://www.selenium.dev') - cheese = driver.manage.cookie_named(cookie[:name]) - - expect(cheese[:value]).to eq 'gouda' - end - - it 'gets performance metrics' do - driver.get('https://www.selenium.dev/selenium/web/frameset.html') - - driver.execute_cdp('Performance.enable') - - metric_list = driver.execute_cdp('Performance.getMetrics')['metrics'] - - metrics = metric_list.each_with_object({}) do |metric, hash| - hash[metric['name']] = metric['value'] - end - - expect(metrics['DevToolsCommandDuration']).to be > 0 - expect(metrics['Frames']).to eq 12 - end - - it 'sets basic authentication' do - driver.execute_cdp('Network.enable') - - credentials = Base64.strict_encode64('admin:admin') - headers = {authorization: "Basic #{credentials}"} - - driver.execute_cdp('Network.setExtraHTTPHeaders', headers: headers) - - driver.get('https://the-internet.herokuapp.com/basic_auth') - - expect(driver.find_element(tag_name: 'p').text).to eq('Congratulations! You must have the proper credentials.') - end -end diff --git a/examples/ruby/spec/bidirectional/webdriver_bidi/browsing_context_spec.rb b/examples/ruby/spec/bidirectional/webdriver_bidi/browsing_context_spec.rb deleted file mode 100644 index 17500df33484..000000000000 --- a/examples/ruby/spec/bidirectional/webdriver_bidi/browsing_context_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Browsing Context' do - it 'opens a window without browsing context' - it 'opens a window with browsing context' - it 'opens a tab without browsing context' - it 'opens a tab with browsing context' - it 'uses existing window' - it 'navigates to url with readiness state' - it 'navigates to url without readiness state' - it 'gets browsing context tree with depth' - it 'gets browsing context tree without depth' - it 'gets all browsing contexts' - it 'closes a tab' - it 'closes a window' -end diff --git a/examples/ruby/spec/bidirectional/webdriver_bidi/log_spec.rb b/examples/ruby/spec/bidirectional/webdriver_bidi/log_spec.rb deleted file mode 100644 index cde9854b1e4e..000000000000 --- a/examples/ruby/spec/bidirectional/webdriver_bidi/log_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Log Inspector' do - it 'listens to console log' - it 'gets JS exceptions' - it 'gets JS logs' -end diff --git a/examples/ruby/spec/spec_helper.rb b/examples/ruby/spec/spec_helper.rb index 902e708d8c6c..20273e7019c5 100644 --- a/examples/ruby/spec/spec_helper.rb +++ b/examples/ruby/spec/spec_helper.rb @@ -31,6 +31,11 @@ def start_session @driver = Selenium::WebDriver.for :chrome end + def start_bidi_session + options = Selenium::WebDriver::Chrome::Options.new(web_socket_url: true) + @driver = Selenium::WebDriver.for :chrome, options: options + end + def start_firefox options = Selenium::WebDriver::Options.firefox(timeouts: {implicit: 1500}) @driver = Selenium::WebDriver.for :firefox, options: options From 15060fb53980b45201fb02a9d947d63a57f3f3cd Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 24 Jun 2024 15:50:35 -0500 Subject: [PATCH 04/11] [examples] update Ruby BiDi code --- examples/ruby/spec/bidi/cdp/cdp_spec.rb | 20 +++++++++++++++ .../{chrome_devtools => cdp}/logging_spec.rb | 0 .../{chrome_devtools => cdp}/network_spec.rb | 25 +++++++++---------- .../scripts_spec.rb => cdp/script_spec.rb} | 2 +- 4 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 examples/ruby/spec/bidi/cdp/cdp_spec.rb rename examples/ruby/spec/bidi/{chrome_devtools => cdp}/logging_spec.rb (100%) rename examples/ruby/spec/bidi/{chrome_devtools => cdp}/network_spec.rb (99%) rename examples/ruby/spec/bidi/{chrome_devtools/scripts_spec.rb => cdp/script_spec.rb} (96%) diff --git a/examples/ruby/spec/bidi/cdp/cdp_spec.rb b/examples/ruby/spec/bidi/cdp/cdp_spec.rb new file mode 100644 index 000000000000..fa2d82f14767 --- /dev/null +++ b/examples/ruby/spec/bidi/cdp/cdp_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Logging' do + let(:driver) { start_session } + + it 'sets cookie' do + driver.execute_cdp('Network.setCookie', + name: 'cheese', + value: 'gouda', + domain: 'www.selenium.dev', + secure: true) + + driver.get('https://www.selenium.dev') + cheese = driver.manage.cookie_named('cheese') + + expect(cheese[:value]).to eq 'gouda' + end +end diff --git a/examples/ruby/spec/bidi/chrome_devtools/logging_spec.rb b/examples/ruby/spec/bidi/cdp/logging_spec.rb similarity index 100% rename from examples/ruby/spec/bidi/chrome_devtools/logging_spec.rb rename to examples/ruby/spec/bidi/cdp/logging_spec.rb diff --git a/examples/ruby/spec/bidi/chrome_devtools/network_spec.rb b/examples/ruby/spec/bidi/cdp/network_spec.rb similarity index 99% rename from examples/ruby/spec/bidi/chrome_devtools/network_spec.rb rename to examples/ruby/spec/bidi/cdp/network_spec.rb index b0673c90717a..c9a818917702 100644 --- a/examples/ruby/spec/bidi/chrome_devtools/network_spec.rb +++ b/examples/ruby/spec/bidi/cdp/network_spec.rb @@ -54,7 +54,6 @@ driver.get('https://www.selenium.dev/selenium/web/frameset.html') driver.devtools.performance.enable - metric_list = driver.devtools.performance.get_metrics.dig('result', 'metrics') metrics = metric_list.each_with_object({}) do |metric, hash| @@ -65,6 +64,18 @@ expect(metrics['Frames']).to eq 12 end + it 'sets cookie' do + driver.devtools.network.set_cookie(name: 'cheese', + value: 'gouda', + domain: 'www.selenium.dev', + secure: true) + + driver.get('https://www.selenium.dev') + cheese = driver.manage.cookie_named('cheese') + + expect(cheese[:value]).to eq 'gouda' + end + it 'waits for downloads', except: {platform: :windows} do driver.get('https://www.selenium.dev/selenium/web/downloads/download.html') @@ -80,16 +91,4 @@ expect { Selenium::WebDriver::Wait.new.until { @completed } }.not_to raise_exception end - - it 'sets cookie' do - driver.devtools.network.set_cookie(name: 'cheese', - value: 'gouda', - domain: 'www.selenium.dev', - secure: true) - - driver.get('https://www.selenium.dev') - cheese = driver.manage.cookie_named('cheese') - - expect(cheese[:value]).to eq 'gouda' - end end diff --git a/examples/ruby/spec/bidi/chrome_devtools/scripts_spec.rb b/examples/ruby/spec/bidi/cdp/script_spec.rb similarity index 96% rename from examples/ruby/spec/bidi/chrome_devtools/scripts_spec.rb rename to examples/ruby/spec/bidi/cdp/script_spec.rb index 1012f2afd665..77575404cd6e 100644 --- a/examples/ruby/spec/bidi/chrome_devtools/scripts_spec.rb +++ b/examples/ruby/spec/bidi/cdp/script_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Scripts' do +RSpec.describe 'Script' do let(:driver) { start_session } it 'pins script' do From bd868a3f3310af37bb279b2eae12b5942acb2624 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 24 Jun 2024 15:59:21 -0500 Subject: [PATCH 05/11] [examples] update Python examples --- examples/python/tests/bidi/cdp/test_cdp.py | 12 ++++++++++++ .../bidi/{chrome_devtools => cdp}/test_logging.py | 0 .../bidi/{chrome_devtools => cdp}/test_network.py | 0 .../bidi/{chrome_devtools => cdp}/test_script.py | 0 .../tests/bidi/{test_log.py => test_logging.py} | 0 5 files changed, 12 insertions(+) create mode 100644 examples/python/tests/bidi/cdp/test_cdp.py rename examples/python/tests/bidi/{chrome_devtools => cdp}/test_logging.py (100%) rename examples/python/tests/bidi/{chrome_devtools => cdp}/test_network.py (100%) rename examples/python/tests/bidi/{chrome_devtools => cdp}/test_script.py (100%) rename examples/python/tests/bidi/{test_log.py => test_logging.py} (100%) diff --git a/examples/python/tests/bidi/cdp/test_cdp.py b/examples/python/tests/bidi/cdp/test_cdp.py new file mode 100644 index 000000000000..97664812f8fd --- /dev/null +++ b/examples/python/tests/bidi/cdp/test_cdp.py @@ -0,0 +1,12 @@ +def test_set_cookie(driver): + cookie = {'name': 'cheese', + 'value': 'gouda', + 'domain': 'www.selenium.dev', + 'secure': True} + + driver.execute_cdp_cmd('Network.setCookie', cookie) + + driver.get('https://www.selenium.dev') + cheese = driver.get_cookie(cookie['name']) + + assert cheese['value'] == 'gouda' diff --git a/examples/python/tests/bidi/chrome_devtools/test_logging.py b/examples/python/tests/bidi/cdp/test_logging.py similarity index 100% rename from examples/python/tests/bidi/chrome_devtools/test_logging.py rename to examples/python/tests/bidi/cdp/test_logging.py diff --git a/examples/python/tests/bidi/chrome_devtools/test_network.py b/examples/python/tests/bidi/cdp/test_network.py similarity index 100% rename from examples/python/tests/bidi/chrome_devtools/test_network.py rename to examples/python/tests/bidi/cdp/test_network.py diff --git a/examples/python/tests/bidi/chrome_devtools/test_script.py b/examples/python/tests/bidi/cdp/test_script.py similarity index 100% rename from examples/python/tests/bidi/chrome_devtools/test_script.py rename to examples/python/tests/bidi/cdp/test_script.py diff --git a/examples/python/tests/bidi/test_log.py b/examples/python/tests/bidi/test_logging.py similarity index 100% rename from examples/python/tests/bidi/test_log.py rename to examples/python/tests/bidi/test_logging.py From 4efd49deb809d1b7c8c222304bf769c5a484c9d4 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 24 Jun 2024 16:15:29 -0500 Subject: [PATCH 06/11] update code examples --- .../dotnet/SeleniumDocs/BiDi/CDP/CDPTest.cs | 29 +++++++++++++++++++ .../{ChromeDevtools => CDP}/LoggingTest.cs | 2 +- .../{ChromeDevtools => CDP}/NetworkTest.cs | 2 +- .../{ChromeDevtools => CDP}/ScriptTest.cs | 2 +- .../dotnet/SeleniumDocs/SeleniumDocs.csproj | 4 +-- .../LogTest.java => LoggingTest.java} | 4 +-- .../{chrome_devtools => cdp}/CdpApiTest.java | 0 .../CdpEndpointTest.java | 0 .../{chrome_devtools => cdp}/LogTest.java | 0 .../{chrome_devtools => cdp}/NetworkTest.java | 0 .../{chrome_devtools => cdp}/ScriptTest.java | 0 examples/python/requirements.txt | 2 +- .../cdp/{test_logging.py => test_logs.py} | 8 ++--- .../python/tests/bidi/cdp/test_network.py | 29 +++++++++---------- examples/python/tests/bidi/cdp/test_script.py | 4 +-- 15 files changed, 53 insertions(+), 33 deletions(-) create mode 100644 examples/dotnet/SeleniumDocs/BiDi/CDP/CDPTest.cs rename examples/dotnet/SeleniumDocs/BiDi/{ChromeDevtools => CDP}/LoggingTest.cs (97%) rename examples/dotnet/SeleniumDocs/BiDi/{ChromeDevtools => CDP}/NetworkTest.cs (99%) rename examples/dotnet/SeleniumDocs/BiDi/{ChromeDevtools => CDP}/ScriptTest.cs (97%) rename examples/java/src/test/java/dev/selenium/bidi/{webdriver_bidi/LogTest.java => LoggingTest.java} (98%) rename examples/java/src/test/java/dev/selenium/bidi/{chrome_devtools => cdp}/CdpApiTest.java (100%) rename examples/java/src/test/java/dev/selenium/bidi/{chrome_devtools => cdp}/CdpEndpointTest.java (100%) rename examples/java/src/test/java/dev/selenium/bidi/{chrome_devtools => cdp}/LogTest.java (100%) rename examples/java/src/test/java/dev/selenium/bidi/{chrome_devtools => cdp}/NetworkTest.java (100%) rename examples/java/src/test/java/dev/selenium/bidi/{chrome_devtools => cdp}/ScriptTest.java (100%) rename examples/python/tests/bidi/cdp/{test_logging.py => test_logs.py} (80%) diff --git a/examples/dotnet/SeleniumDocs/BiDi/CDP/CDPTest.cs b/examples/dotnet/SeleniumDocs/BiDi/CDP/CDPTest.cs new file mode 100644 index 000000000000..3188d183d748 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/CDP/CDPTest.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium; +using OpenQA.Selenium.Chrome; + +namespace SeleniumDocs.BiDi.CDP +{ + [TestClass] + public class CDPTest : BaseChromeTest + { + [TestMethod] + public void SetCookie() + { + var cookie = new Dictionary + { + { "name", "cheese" }, + { "value", "gouda" }, + { "domain", "www.selenium.dev" }, + { "secure", true } + }; + ((ChromeDriver)driver).ExecuteCdpCommand("Network.setCookie", cookie); + + driver.Url = "https://www.selenium.dev"; + Cookie cheese = driver.Manage().Cookies.GetCookieNamed("cheese"); + Assert.AreEqual("gouda", cheese.Value); + + } + } +} \ No newline at end of file diff --git a/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/LoggingTest.cs b/examples/dotnet/SeleniumDocs/BiDi/CDP/LoggingTest.cs similarity index 97% rename from examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/LoggingTest.cs rename to examples/dotnet/SeleniumDocs/BiDi/CDP/LoggingTest.cs index 4b26d7362ae9..7f3a09a90c73 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/LoggingTest.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/CDP/LoggingTest.cs @@ -7,7 +7,7 @@ using OpenQA.Selenium; using OpenQA.Selenium.Support.UI; -namespace SeleniumDocs.Bidirectional.ChromeDevTools +namespace SeleniumDocs.BiDi.CDP { [TestClass] public class LoggingTest : BaseChromeTest diff --git a/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/NetworkTest.cs b/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs similarity index 99% rename from examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/NetworkTest.cs rename to examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs index 7d3a7a3954f8..0d0018f2a4a9 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/NetworkTest.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs @@ -8,7 +8,7 @@ using OpenQA.Selenium.DevTools.V126.Performance; -namespace SeleniumDocs.BiDi.ChromeDevTools +namespace SeleniumDocs.BiDi.CDP { [TestClass] public class NetworkTest : BaseTest diff --git a/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/ScriptTest.cs b/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs similarity index 97% rename from examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/ScriptTest.cs rename to examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs index eae07106060c..4eac62fa4898 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/ChromeDevtools/ScriptTest.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs @@ -7,7 +7,7 @@ using OpenQA.Selenium; using OpenQA.Selenium.Support.UI; -namespace SeleniumDocs.Bidirectional.ChromeDevTools +namespace SeleniumDocs.BiDi.CDP { [TestClass] public class ScriptTest : BaseChromeTest diff --git a/examples/dotnet/SeleniumDocs/SeleniumDocs.csproj b/examples/dotnet/SeleniumDocs/SeleniumDocs.csproj index 0857990c926f..58df2de895e2 100644 --- a/examples/dotnet/SeleniumDocs/SeleniumDocs.csproj +++ b/examples/dotnet/SeleniumDocs/SeleniumDocs.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/examples/java/src/test/java/dev/selenium/bidi/webdriver_bidi/LogTest.java b/examples/java/src/test/java/dev/selenium/bidi/LoggingTest.java similarity index 98% rename from examples/java/src/test/java/dev/selenium/bidi/webdriver_bidi/LogTest.java rename to examples/java/src/test/java/dev/selenium/bidi/LoggingTest.java index 1abd3f15505d..1fd2c7b20456 100644 --- a/examples/java/src/test/java/dev/selenium/bidi/webdriver_bidi/LogTest.java +++ b/examples/java/src/test/java/dev/selenium/bidi/LoggingTest.java @@ -1,4 +1,4 @@ -package dev.selenium.bidirectional.webdriver_bidi; +package dev.selenium.bidi; import dev.selenium.BaseTest; @@ -18,7 +18,7 @@ import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.support.ui.WebDriverWait; -class LogTest extends BaseTest { +class LoggingTest extends BaseTest { @BeforeEach public void setup() { diff --git a/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/CdpApiTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpApiTest.java similarity index 100% rename from examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/CdpApiTest.java rename to examples/java/src/test/java/dev/selenium/bidi/cdp/CdpApiTest.java diff --git a/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/CdpEndpointTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpEndpointTest.java similarity index 100% rename from examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/CdpEndpointTest.java rename to examples/java/src/test/java/dev/selenium/bidi/cdp/CdpEndpointTest.java diff --git a/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/LogTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/LogTest.java similarity index 100% rename from examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/LogTest.java rename to examples/java/src/test/java/dev/selenium/bidi/cdp/LogTest.java diff --git a/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/NetworkTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java similarity index 100% rename from examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/NetworkTest.java rename to examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java diff --git a/examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/ScriptTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/ScriptTest.java similarity index 100% rename from examples/java/src/test/java/dev/selenium/bidi/chrome_devtools/ScriptTest.java rename to examples/java/src/test/java/dev/selenium/bidi/cdp/ScriptTest.java diff --git a/examples/python/requirements.txt b/examples/python/requirements.txt index afb42daf8cfa..2b291462bc86 100644 --- a/examples/python/requirements.txt +++ b/examples/python/requirements.txt @@ -1,4 +1,4 @@ -selenium==4.21.0 +selenium==4.22.0 pytest trio pytest-trio diff --git a/examples/python/tests/bidi/cdp/test_logging.py b/examples/python/tests/bidi/cdp/test_logs.py similarity index 80% rename from examples/python/tests/bidi/cdp/test_logging.py rename to examples/python/tests/bidi/cdp/test_logs.py index b65f668f6572..573ead1e578a 100644 --- a/examples/python/tests/bidi/cdp/test_logging.py +++ b/examples/python/tests/bidi/cdp/test_logs.py @@ -9,9 +9,7 @@ async def test_console_log(driver): driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') async with driver.bidi_connection() as session: - log = Log(driver, session) - - async with log.add_listener(Console.ALL) as messages: + async with Log(driver, session).add_listener(Console.ALL) as messages: driver.find_element(by=By.ID, value='consoleLog').click() assert messages["message"] == "Hello, world!" @@ -22,9 +20,7 @@ async def test_js_error(driver): driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') async with driver.bidi_connection() as session: - log = Log(driver, session) - - async with log.add_js_error_listener() as messages: + async with Log(driver, session).add_js_error_listener() as messages: driver.find_element(by=By.ID, value='jsException').click() assert "Error: Not working" in messages.exception_details.exception.description diff --git a/examples/python/tests/bidi/cdp/test_network.py b/examples/python/tests/bidi/cdp/test_network.py index 3f42ca97237b..99eada8e4f57 100644 --- a/examples/python/tests/bidi/cdp/test_network.py +++ b/examples/python/tests/bidi/cdp/test_network.py @@ -12,7 +12,6 @@ async def test_basic_auth(driver): credentials = base64.b64encode("admin:admin".encode()).decode() auth = {'authorization': 'Basic ' + credentials} - await connection.session.execute(connection.devtools.network.set_extra_http_headers(Headers(auth))) driver.get('https://the-internet.herokuapp.com/basic_auth') @@ -20,6 +19,19 @@ async def test_basic_auth(driver): success = driver.find_element(by=By.TAG_NAME, value='p') assert success.text == 'Congratulations! You must have the proper credentials.' +@pytest.mark.trio +async def test_performance(driver): + driver.get('https://www.selenium.dev/selenium/web/frameset.html') + + async with driver.bidi_connection() as connection: + await connection.session.execute(connection.devtools.performance.enable()) + metric_list = await connection.session.execute(connection.devtools.performance.get_metrics()) + + metrics = {metric.name: metric.value for metric in metric_list} + + assert metrics["DevToolsCommandDuration"] > 0 + assert metrics["Frames"] == 12 + @pytest.mark.trio async def test_set_cookie(driver): async with driver.bidi_connection() as connection: @@ -29,24 +41,9 @@ async def test_set_cookie(driver): domain="www.selenium.dev", secure=True ) - await connection.session.execute(execution) driver.get("https://www.selenium.dev") cheese = driver.get_cookie("cheese") assert cheese["value"] == "gouda" - -@pytest.mark.trio -async def test_performance(driver): - driver.get('https://www.selenium.dev/selenium/web/frameset.html') - - async with driver.bidi_connection() as connection: - await connection.session.execute(connection.devtools.performance.enable()) - - metric_list = await connection.session.execute(connection.devtools.performance.get_metrics()) - - metrics = {metric.name: metric.value for metric in metric_list} - - assert metrics["DevToolsCommandDuration"] > 0 - assert metrics["Frames"] == 12 diff --git a/examples/python/tests/bidi/cdp/test_script.py b/examples/python/tests/bidi/cdp/test_script.py index b765183e46b1..c547de1d25da 100644 --- a/examples/python/tests/bidi/cdp/test_script.py +++ b/examples/python/tests/bidi/cdp/test_script.py @@ -6,9 +6,7 @@ @pytest.mark.trio async def test_mutation(driver): async with driver.bidi_connection() as session: - log = Log(driver, session) - - async with log.mutation_events() as event: + async with Log(driver, session).mutation_events() as event: driver.get('https://www.selenium.dev/selenium/web/dynamic.html') driver.find_element(By.ID, "reveal").click() From b68d0b86d6b90d5326929781748e6e0dc4d6c77f Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 24 Jun 2024 16:57:12 -0500 Subject: [PATCH 07/11] more example updates --- .../SeleniumDocs/BiDi/CDP/LoggingTest.cs | 5 +- .../SeleniumDocs/BiDi/CDP/NetworkTest.cs | 56 ++++--- .../SeleniumDocs/BiDi/CDP/ScriptTest.cs | 4 +- .../java/dev/selenium/bidi/LoggingTest.java | 142 ------------------ .../dev/selenium/bidi/cdp/CdpApiTest.java | 39 +---- .../selenium/bidi/cdp/CdpEndpointTest.java | 74 --------- .../java/dev/selenium/bidi/cdp/CdpTest.java | 33 ++++ .../cdp/{LogTest.java => LoggingTest.java} | 19 +-- .../dev/selenium/bidi/cdp/NetworkTest.java | 92 ++++++++++-- .../dev/selenium/bidi/cdp/ScriptTest.java | 17 +-- 10 files changed, 155 insertions(+), 326 deletions(-) delete mode 100644 examples/java/src/test/java/dev/selenium/bidi/LoggingTest.java delete mode 100644 examples/java/src/test/java/dev/selenium/bidi/cdp/CdpEndpointTest.java create mode 100644 examples/java/src/test/java/dev/selenium/bidi/cdp/CdpTest.java rename examples/java/src/test/java/dev/selenium/bidi/cdp/{LogTest.java => LoggingTest.java} (70%) diff --git a/examples/dotnet/SeleniumDocs/BiDi/CDP/LoggingTest.cs b/examples/dotnet/SeleniumDocs/BiDi/CDP/LoggingTest.cs index 7f3a09a90c73..c7f912be43da 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/CDP/LoggingTest.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/CDP/LoggingTest.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.IdentityModel.Tokens; @@ -23,8 +22,8 @@ public async Task ConsoleLogs() { messages.Add(e.MessageContent); }; - await monitor.StartEventMonitoring(); + driver.FindElement(By.Id("consoleLog")).Click(); driver.FindElement(By.Id("consoleError")).Click(); new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(_ => messages.Count > 1); @@ -45,8 +44,8 @@ public async Task JsErrors() { messages.Add(e.Message); }; - await monitor.StartEventMonitoring(); + driver.FindElement(By.Id("jsException")).Click(); new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(_ => !messages.IsNullOrEmpty()); monitor.StopEventMonitoring(); diff --git a/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs b/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs index 0d0018f2a4a9..03226fcaf9a4 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs @@ -27,11 +27,10 @@ public async Task BasicAuthentication() UriMatcher = uri => uri.AbsoluteUri.Contains("herokuapp"), Credentials = new PasswordCredentials("admin", "admin") }; - var networkInterceptor = driver.Manage().Network; networkInterceptor.AddAuthenticationHandler(handler); - await networkInterceptor.StartMonitoring(); + driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/basic_auth"); await networkInterceptor.StopMonitoring(); @@ -49,8 +48,8 @@ public async Task RecordNetworkResponse() { contentType.Add(e.ResponseHeaders["content-type"]); }; - await networkInterceptor.StartMonitoring(); + driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/blank.html"); await networkInterceptor.StopMonitoring(); @@ -69,11 +68,10 @@ public async Task TransformNetworkResponse() Body = "Creamy, delicious cheese!" } }; - INetwork networkInterceptor = driver.Manage().Network; networkInterceptor.AddResponseHandler(handler); - await networkInterceptor.StartMonitoring(); + driver.Navigate().GoToUrl("https://www.selenium.dev"); await networkInterceptor.StopMonitoring(); @@ -94,11 +92,10 @@ public async Task TransformNetworkRequest() return request; } }; - INetwork networkInterceptor = driver.Manage().Network; networkInterceptor.AddRequestHandler(handler); - await networkInterceptor.StartMonitoring(); + driver.Url = "https://www.selenium.dev/selenium/web/devToolsRequestInterceptionTest.html"; driver.FindElement(By.TagName("button")).Click(); await networkInterceptor.StopMonitoring(); @@ -106,28 +103,6 @@ public async Task TransformNetworkRequest() Assert.AreEqual("two", driver.FindElement(By.Id("result")).Text); } - [TestMethod] - public async Task SetCookie() - { - var session = ((IDevTools)driver).GetDevToolsSession(); - var domains = session.GetVersionSpecificDomains(); - await domains.Network.Enable(new OpenQA.Selenium.DevTools.V126.Network.EnableCommandSettings()); - - var cookieCommandSettings = new SetCookieCommandSettings - { - Name = "cheese", - Value = "gouda", - Domain = "www.selenium.dev", - Secure = true - }; - - await domains.Network.SetCookie(cookieCommandSettings); - - driver.Url = "https://www.selenium.dev"; - OpenQA.Selenium.Cookie cheese = driver.Manage().Cookies.GetCookieNamed("cheese"); - Assert.AreEqual("gouda", cheese.Value); - } - [TestMethod] public async Task PerformanceMetrics() { @@ -135,8 +110,8 @@ public async Task PerformanceMetrics() var session = ((IDevTools)driver).GetDevToolsSession(); var domains = session.GetVersionSpecificDomains(); - await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V126.Performance.EnableCommandSettings()); + await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V126.Performance.EnableCommandSettings()); var metricsResponse = await session.SendCommand( new GetMetricsCommandSettings() @@ -151,5 +126,26 @@ await session.SendCommand( Assert.AreEqual(12, metrics["Frames"]); } + [TestMethod] + public async Task SetCookie() + { + var session = ((IDevTools)driver).GetDevToolsSession(); + var domains = session.GetVersionSpecificDomains(); + await domains.Network.Enable(new OpenQA.Selenium.DevTools.V126.Network.EnableCommandSettings()); + + var cookieCommandSettings = new SetCookieCommandSettings + { + Name = "cheese", + Value = "gouda", + Domain = "www.selenium.dev", + Secure = true + }; + await domains.Network.SetCookie(cookieCommandSettings); + + driver.Url = "https://www.selenium.dev"; + OpenQA.Selenium.Cookie cheese = driver.Manage().Cookies.GetCookieNamed("cheese"); + Assert.AreEqual("gouda", cheese.Value); + } + } } \ No newline at end of file diff --git a/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs b/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs index 4eac62fa4898..b3b92ee2cd35 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs @@ -19,7 +19,6 @@ public async Task PinScript() var element = driver.FindElement(By.Id("id1")); var key = await new JavaScriptEngine(driver).PinScript("return arguments;"); - var arguments = ((WebDriver)driver).ExecuteScript(key, 1, true, element); var expected = new List @@ -35,15 +34,14 @@ public async Task PinScript() public async Task MutatedElements() { driver.Url = "https://www.selenium.dev/selenium/web/dynamic.html"; - var mutations = new List(); + using IJavaScriptEngine monitor = new JavaScriptEngine(driver); monitor.DomMutated += (_, e) => { var locator = By.CssSelector($"*[data-__webdriver_id='{e.AttributeData.TargetId}']"); mutations.Add(driver.FindElement(locator)); }; - await monitor.StartEventMonitoring(); await monitor.EnableDomMutationMonitoring(); diff --git a/examples/java/src/test/java/dev/selenium/bidi/LoggingTest.java b/examples/java/src/test/java/dev/selenium/bidi/LoggingTest.java deleted file mode 100644 index 1fd2c7b20456..000000000000 --- a/examples/java/src/test/java/dev/selenium/bidi/LoggingTest.java +++ /dev/null @@ -1,142 +0,0 @@ -package dev.selenium.bidi; - -import dev.selenium.BaseTest; - -import java.time.Duration; -import java.util.concurrent.*; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.bidi.module.LogInspector; -import org.openqa.selenium.bidi.log.ConsoleLogEntry; -import org.openqa.selenium.bidi.log.JavascriptLogEntry; -import org.openqa.selenium.bidi.log.LogLevel; -import org.openqa.selenium.bidi.log.StackTrace; -import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.firefox.FirefoxOptions; -import org.openqa.selenium.support.ui.WebDriverWait; - -class LoggingTest extends BaseTest { - - @BeforeEach - public void setup() { - FirefoxOptions options = new FirefoxOptions(); - options.setCapability("webSocketUrl", true); - driver = new FirefoxDriver(options); - } - - @Test - public void jsErrors() { - CopyOnWriteArrayList logs = new CopyOnWriteArrayList<>(); - - try (LogInspector logInspector = new LogInspector(driver)) { - logInspector.onConsoleEntry(logs::add); - } - - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - driver.findElement(By.id("consoleLog")).click(); - - new WebDriverWait(driver, Duration.ofSeconds(5)).until(_d -> !logs.isEmpty()); - Assertions.assertEquals("Hello, world!", logs.get(0).getText()); - } - - @Test - void testListenToConsoleLog() throws ExecutionException, InterruptedException, TimeoutException { - try (LogInspector logInspector = new LogInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - logInspector.onConsoleEntry(future::complete); - - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - driver.findElement(By.id("consoleLog")).click(); - - ConsoleLogEntry logEntry = future.get(5, TimeUnit.SECONDS); - - Assertions.assertEquals("Hello, world!", logEntry.getText()); - Assertions.assertNull(logEntry.getRealm()); - Assertions.assertEquals(1, logEntry.getArgs().size()); - Assertions.assertEquals("console", logEntry.getType()); - Assertions.assertEquals("log", logEntry.getMethod()); - Assertions.assertNull(logEntry.getStackTrace()); - } - } - - @Test - void testListenToJavascriptLog() - throws ExecutionException, InterruptedException, TimeoutException { - try (LogInspector logInspector = new LogInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - logInspector.onJavaScriptLog(future::complete); - - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - driver.findElement(By.id("jsException")).click(); - - JavascriptLogEntry logEntry = future.get(5, TimeUnit.SECONDS); - - Assertions.assertEquals("Error: Not working", logEntry.getText()); - Assertions.assertEquals("javascript", logEntry.getType()); - Assertions.assertEquals(LogLevel.ERROR, logEntry.getLevel()); - } - } - - @Test - void testListenToJavascriptErrorLog() - throws ExecutionException, InterruptedException, TimeoutException { - try (LogInspector logInspector = new LogInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - logInspector.onJavaScriptException(future::complete); - - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - driver.findElement(By.id("jsException")).click(); - - JavascriptLogEntry logEntry = future.get(5, TimeUnit.SECONDS); - - Assertions.assertEquals("Error: Not working", logEntry.getText()); - Assertions.assertEquals("javascript", logEntry.getType()); - } - } - - @Test - void testRetrieveStacktraceForALog() - throws ExecutionException, InterruptedException, TimeoutException { - try (LogInspector logInspector = new LogInspector(driver)) { - CompletableFuture future = new CompletableFuture<>(); - logInspector.onJavaScriptException(future::complete); - - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - driver.findElement(By.id("logWithStacktrace")).click(); - - JavascriptLogEntry logEntry = future.get(5, TimeUnit.SECONDS); - - StackTrace stackTrace = logEntry.getStackTrace(); - Assertions.assertNotNull(stackTrace); - Assertions.assertEquals(4, stackTrace.getCallFrames().size()); - } - } - - @Test - void testListenToLogsWithMultipleConsumers() - throws ExecutionException, InterruptedException, TimeoutException { - try (LogInspector logInspector = new LogInspector(driver)) { - CompletableFuture completableFuture1 = new CompletableFuture<>(); - logInspector.onJavaScriptLog(completableFuture1::complete); - - CompletableFuture completableFuture2 = new CompletableFuture<>(); - logInspector.onJavaScriptLog(completableFuture2::complete); - - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - driver.findElement(By.id("jsException")).click(); - - JavascriptLogEntry logEntry = completableFuture1.get(5, TimeUnit.SECONDS); - - Assertions.assertEquals("Error: Not working", logEntry.getText()); - Assertions.assertEquals("javascript", logEntry.getType()); - - logEntry = completableFuture2.get(5, TimeUnit.SECONDS); - - Assertions.assertEquals("Error: Not working", logEntry.getText()); - Assertions.assertEquals("javascript", logEntry.getType()); - } - } -} diff --git a/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpApiTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpApiTest.java index 0f9d56950f74..1b501ea2a185 100644 --- a/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpApiTest.java +++ b/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpApiTest.java @@ -1,4 +1,4 @@ -package dev.selenium.bidirectional.chrome_devtools; +package dev.selenium.bidi.cdp; import com.google.common.collect.ImmutableMap; import dev.selenium.BaseTest; @@ -42,26 +42,6 @@ public void createSession() { wait = new WebDriverWait(driver, Duration.ofSeconds(10)); } - @Test - @Disabled("4.15 broke the casting") - public void performanceMetrics() { - driver.get("https://www.selenium.dev/selenium/web/frameset.html"); - - devTools = ((HasDevTools) driver).getDevTools(); - devTools.createSession(); - devTools.send(Performance.enable(Optional.empty())); - - List metricList = devTools.send(Performance.getMetrics()); - - Map metrics = new HashMap<>(); - for (Metric metric : metricList) { - metrics.put(metric.getName(), metric.getValue()); - } - - Assertions.assertTrue(metrics.get("DevToolsCommandDuration").doubleValue() > 0); - Assertions.assertEquals(12, metrics.get("Frames").intValue()); - } - @Test public void basicAuth() { devTools = ((HasDevTools) driver).getDevTools(); @@ -80,23 +60,6 @@ public void basicAuth() { driver.findElement(By.tagName("p")).getText()); } - @Test - public void jsErrors() { - driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - - DevTools devTools = ((HasDevTools) driver).getDevTools(); - devTools.createSession(); - devTools.send(Runtime.enable()); - - CopyOnWriteArrayList errors = new CopyOnWriteArrayList<>(); - devTools.getDomains().events().addJavascriptExceptionListener(errors::add); - - driver.findElement(By.id("jsException")).click(); - - wait.until(_d -> !errors.isEmpty()); - Assertions.assertTrue(errors.get(0).getMessage().contains("Error: Not working")); - } - @Test public void waitForDownload() { driver.get("https://www.selenium.dev/selenium/web/downloads/download.html"); diff --git a/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpEndpointTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpEndpointTest.java deleted file mode 100644 index c8845e727d4d..000000000000 --- a/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpEndpointTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package dev.selenium.bidirectional.chrome_devtools; - -import com.google.common.collect.ImmutableMap; -import dev.selenium.BaseTest; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.Cookie; -import org.openqa.selenium.chrome.ChromeDriver; -import org.openqa.selenium.chromium.HasCdp; - -import java.util.Base64; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class CdpEndpointTest extends BaseTest { - @BeforeEach - public void createSession() { - driver = new ChromeDriver(); - } - - @Test - public void setCookie() { - Map cookie = new HashMap<>(); - cookie.put("name", "cheese"); - cookie.put("value", "gouda"); - cookie.put("domain", "www.selenium.dev"); - cookie.put("secure", true); - - ((HasCdp) driver).executeCdpCommand("Network.setCookie", cookie); - - driver.get("https://www.selenium.dev"); - Cookie cheese = driver.manage().getCookieNamed("cheese"); - Assertions.assertEquals("gouda", cheese.getValue()); - } - - @Test - public void performanceMetrics() { - driver.get("https://www.selenium.dev/selenium/web/frameset.html"); - - ((HasCdp) driver).executeCdpCommand("Performance.enable", new HashMap<>()); - - Map response = - ((HasCdp) driver).executeCdpCommand("Performance.getMetrics", new HashMap<>()); - List> metricList = (List>) response.get("metrics"); - - Map metrics = new HashMap<>(); - for (Map metric : metricList) { - metrics.put((String) metric.get("name"), (Number) metric.get("value")); - } - - Assertions.assertTrue(metrics.get("DevToolsCommandDuration").doubleValue() > 0); - Assertions.assertEquals(12, metrics.get("Frames").intValue()); - } - - @Test - public void basicAuth() { - ((HasCdp) driver).executeCdpCommand("Network.enable", new HashMap<>()); - - String encodedAuth = Base64.getEncoder().encodeToString("admin:admin".getBytes()); - Map headers = - ImmutableMap.of("headers", ImmutableMap.of("authorization", "Basic " + encodedAuth)); - - ((HasCdp) driver).executeCdpCommand("Network.setExtraHTTPHeaders", headers); - - driver.get("https://the-internet.herokuapp.com/basic_auth"); - - Assertions.assertEquals( - "Congratulations! You must have the proper credentials.", - driver.findElement(By.tagName("p")).getText()); - } -} diff --git a/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpTest.java new file mode 100644 index 000000000000..f83c18832d95 --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpTest.java @@ -0,0 +1,33 @@ +package dev.selenium.bidi.cdp; + +import dev.selenium.BaseTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.Cookie; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chromium.HasCdp; + +import java.util.HashMap; +import java.util.Map; + +public class CdpTest extends BaseTest { + @BeforeEach + public void createSession() { + driver = new ChromeDriver(); + } + + @Test + public void setCookie() { + Map cookie = new HashMap<>(); + cookie.put("name", "cheese"); + cookie.put("value", "gouda"); + cookie.put("domain", "www.selenium.dev"); + cookie.put("secure", true); + ((HasCdp) driver).executeCdpCommand("Network.setCookie", cookie); + + driver.get("https://www.selenium.dev"); + Cookie cheese = driver.manage().getCookieNamed("cheese"); + Assertions.assertEquals("gouda", cheese.getValue()); + } +} diff --git a/examples/java/src/test/java/dev/selenium/bidi/cdp/LogTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/LoggingTest.java similarity index 70% rename from examples/java/src/test/java/dev/selenium/bidi/cdp/LogTest.java rename to examples/java/src/test/java/dev/selenium/bidi/cdp/LoggingTest.java index 635a1e7afa4e..01a0cfa09333 100644 --- a/examples/java/src/test/java/dev/selenium/bidi/cdp/LogTest.java +++ b/examples/java/src/test/java/dev/selenium/bidi/cdp/LoggingTest.java @@ -1,29 +1,21 @@ -package dev.selenium.bidirectional.chrome_devtools; +package dev.selenium.bidi.cdp; import static org.openqa.selenium.devtools.events.CdpEventTypes.consoleEvent; -import static org.openqa.selenium.devtools.events.CdpEventTypes.domMutation; -import com.google.common.net.MediaType; import dev.selenium.BaseTest; -import java.net.*; + import java.time.Duration; -import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Predicate; -import java.util.function.Supplier; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.openqa.selenium.*; import org.openqa.selenium.chrome.ChromeDriver; -import org.openqa.selenium.devtools.NetworkInterceptor; import org.openqa.selenium.logging.HasLogEvents; -import org.openqa.selenium.remote.http.*; import org.openqa.selenium.support.ui.WebDriverWait; -public class BidiApiTest extends BaseTest { +public class LoggingTest extends BaseTest { @BeforeEach public void createSession() { @@ -34,8 +26,8 @@ public void createSession() { @Test public void consoleLogs() { driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); - CopyOnWriteArrayList messages = new CopyOnWriteArrayList<>(); + ((HasLogEvents) driver).onLogEvent(consoleEvent(e -> messages.add(e.getMessages().get(0)))); driver.findElement(By.id("consoleLog")).click(); @@ -45,5 +37,4 @@ public void consoleLogs() { Assertions.assertTrue(messages.contains("Hello, world!")); Assertions.assertTrue(messages.contains("I am console error")); } - } diff --git a/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java index 826fd5ddec26..f97b84709044 100644 --- a/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java +++ b/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java @@ -1,29 +1,34 @@ -package dev.selenium.bidirectional.chrome_devtools; - -import static org.openqa.selenium.devtools.events.CdpEventTypes.consoleEvent; -import static org.openqa.selenium.devtools.events.CdpEventTypes.domMutation; +package dev.selenium.bidi.cdp; import com.google.common.net.MediaType; import dev.selenium.BaseTest; import java.net.*; import java.time.Duration; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Predicate; import java.util.function.Supplier; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.openqa.selenium.*; import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.devtools.DevTools; +import org.openqa.selenium.devtools.HasDevTools; import org.openqa.selenium.devtools.NetworkInterceptor; -import org.openqa.selenium.logging.HasLogEvents; +import org.openqa.selenium.devtools.v124.browser.Browser; +import org.openqa.selenium.devtools.v124.network.Network; +import org.openqa.selenium.devtools.v124.performance.Performance; +import org.openqa.selenium.devtools.v124.performance.model.Metric; import org.openqa.selenium.remote.http.*; import org.openqa.selenium.support.ui.WebDriverWait; -public class BidiApiTest extends BaseTest { +public class NetworkTest extends BaseTest { @BeforeEach public void createSession() { @@ -35,7 +40,6 @@ public void createSession() { public void basicAuthentication() { Predicate uriPredicate = uri -> uri.toString().contains("herokuapp.com"); Supplier authentication = UsernameAndPassword.of("admin", "admin"); - ((HasAuthentication) driver).register(uriPredicate, authentication); driver.get("https://the-internet.herokuapp.com/basic_auth"); @@ -79,7 +83,6 @@ public void transformResponses() { .setStatus(200) .addHeader("Content-Type", MediaType.HTML_UTF_8.toString()) .setContent(Contents.utf8String("Creamy, delicious cheese!"))))) { - driver.get("https://www.selenium.dev/selenium/web/blank.html"); } @@ -88,7 +91,6 @@ public void transformResponses() { } @Test - @Disabled("Not working yet") public void interceptRequests() { AtomicBoolean completed = new AtomicBoolean(false); @@ -112,4 +114,74 @@ public void interceptRequests() { Assertions.assertEquals("two", driver.findElement(By.id("result")).getText()); } + + @Test + public void performanceMetrics() { + driver.get("https://www.selenium.dev/selenium/web/frameset.html"); + + DevTools devTools = ((HasDevTools) driver).getDevTools(); + devTools.createSession(); + + devTools.send(Performance.enable(Optional.empty())); + List metricList = devTools.send(Performance.getMetrics()); + + Map metrics = new HashMap<>(); + for (Metric metric : metricList) { + metrics.put(metric.getName(), metric.getValue()); + } + + Assertions.assertTrue(metrics.get("DevToolsCommandDuration").doubleValue() > 0); + Assertions.assertEquals(12, metrics.get("Frames").intValue()); + } + + @Test + public void setCookie() { + DevTools devTools = ((HasDevTools) driver).getDevTools(); + devTools.createSession(); + + devTools.send( + Network.setCookie( + "cheese", + "gouda", + Optional.empty(), + Optional.of("www.selenium.dev"), + Optional.empty(), + Optional.of(true), + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.empty())); + + driver.get("https://www.selenium.dev"); + Cookie cheese = driver.manage().getCookieNamed("cheese"); + Assertions.assertEquals("gouda", cheese.getValue()); + } + + @Test + public void waitForDownload() { + driver.get("https://www.selenium.dev/selenium/web/downloads/download.html"); + + DevTools devTools = ((HasDevTools) driver).getDevTools(); + devTools.createSession(); + + devTools.send( + Browser.setDownloadBehavior( + Browser.SetDownloadBehaviorBehavior.ALLOWANDNAME, + Optional.empty(), + Optional.of(""), + Optional.of(true))); + + AtomicBoolean completed = new AtomicBoolean(false); + devTools.addListener( + Browser.downloadProgress(), + e -> completed.set(Objects.equals(e.getState().toString(), "completed"))); + + driver.findElement(By.id("file-2")).click(); + + Assertions.assertDoesNotThrow(() -> wait.until(_d -> completed)); + } } diff --git a/examples/java/src/test/java/dev/selenium/bidi/cdp/ScriptTest.java b/examples/java/src/test/java/dev/selenium/bidi/cdp/ScriptTest.java index 421dbbc1b5c5..dd6436f4f327 100644 --- a/examples/java/src/test/java/dev/selenium/bidi/cdp/ScriptTest.java +++ b/examples/java/src/test/java/dev/selenium/bidi/cdp/ScriptTest.java @@ -1,29 +1,22 @@ -package dev.selenium.bidirectional.chrome_devtools; +package dev.selenium.bidi.cdp; -import static org.openqa.selenium.devtools.events.CdpEventTypes.consoleEvent; import static org.openqa.selenium.devtools.events.CdpEventTypes.domMutation; -import com.google.common.net.MediaType; import dev.selenium.BaseTest; -import java.net.*; + import java.time.Duration; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Predicate; -import java.util.function.Supplier; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.openqa.selenium.*; import org.openqa.selenium.chrome.ChromeDriver; -import org.openqa.selenium.devtools.NetworkInterceptor; import org.openqa.selenium.logging.HasLogEvents; -import org.openqa.selenium.remote.http.*; import org.openqa.selenium.support.ui.WebDriverWait; -public class BidiApiTest extends BaseTest { +public class ScriptTest extends BaseTest { @BeforeEach public void createSession() { @@ -46,8 +39,8 @@ public void pinScript() { @Test public void mutatedElements() { driver.get("https://www.selenium.dev/selenium/web/dynamic.html"); - CopyOnWriteArrayList mutations = new CopyOnWriteArrayList<>(); + ((HasLogEvents) driver).onLogEvent(domMutation(e -> mutations.add(e.getElement()))); driver.findElement(By.id("reveal")).click(); From b130f8ed5fd7a2065e791b882462da804bbdc821 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 24 Jun 2024 19:44:51 -0500 Subject: [PATCH 08/11] update all BiDi documentation --- .../documentation/webdriver/bidi/_index.en.md | 41 ++ .../webdriver/bidi/cdp/_index.en.md | 73 +++ .../webdriver/bidi/cdp/logging.en.md | 59 ++ .../webdriver/bidi/cdp/network.en.md | 187 ++++++ .../webdriver/bidi/cdp/script.en.md | 59 ++ .../webdriver/bidi/logging.en.md | 118 ++++ .../webdriver/bidi/network.en.md | 21 + .../documentation/webdriver/bidi/script.en.md | 21 + .../webdriver/bidirectional/_index.en.md | 34 - .../webdriver/bidirectional/_index.ja.md | 43 -- .../webdriver/bidirectional/_index.pt-br.md | 43 -- .../webdriver/bidirectional/_index.zh-cn.md | 34 - .../chrome_devtools/_index.en.md | 47 -- .../chrome_devtools/_index.ja.md | 47 -- .../chrome_devtools/_index.pt-br.md | 47 -- .../chrome_devtools/_index.zh-cn.md | 47 -- .../chrome_devtools/bidi_api.en.md | 359 ----------- .../chrome_devtools/bidi_api.ja.md | 361 ----------- .../chrome_devtools/bidi_api.pt-br.md | 350 ---------- .../chrome_devtools/bidi_api.zh-cn.md | 359 ----------- .../chrome_devtools/cdp_api.en.md | 208 ------ .../chrome_devtools/cdp_api.ja.md | 208 ------ .../chrome_devtools/cdp_api.pt-br.md | 208 ------ .../chrome_devtools/cdp_api.zh-cn.md | 208 ------ .../chrome_devtools/cdp_endpoint.en.md | 108 ---- .../chrome_devtools/cdp_endpoint.ja.md | 108 ---- .../chrome_devtools/cdp_endpoint.pt-br.md | 108 ---- .../chrome_devtools/cdp_endpoint.zh-cn.md | 108 ---- .../bidirectional/webdriver_bidi/_index.en.md | 18 - .../bidirectional/webdriver_bidi/_index.ja.md | 25 - .../webdriver_bidi/_index.pt-br.md | 25 - .../webdriver_bidi/_index.zh-cn.md | 16 - .../webdriver_bidi/browsing_context.en.md | 598 ----------------- .../webdriver_bidi/browsing_context.ja.md | 604 ------------------ .../webdriver_bidi/browsing_context.pt-br.md | 604 ------------------ .../webdriver_bidi/browsing_context.zh-cn.md | 604 ------------------ .../bidirectional/webdriver_bidi/input.en.md | 48 -- .../bidirectional/webdriver_bidi/input.ja.md | 57 -- .../webdriver_bidi/input.pt-br.md | 57 -- .../webdriver_bidi/input.zh-cn.md | 57 -- .../bidirectional/webdriver_bidi/log.en.md | 70 -- .../bidirectional/webdriver_bidi/log.ja.md | 76 --- .../bidirectional/webdriver_bidi/log.pt-br.md | 76 --- .../bidirectional/webdriver_bidi/log.zh-cn.md | 77 --- .../webdriver_bidi/network.en.md | 205 ------ .../webdriver_bidi/network.ja.md | 213 ------ .../webdriver_bidi/network.pt-br.md | 214 ------- .../webdriver_bidi/network.zh-cn.md | 213 ------ .../bidirectional/webdriver_bidi/script.en.md | 339 ---------- .../bidirectional/webdriver_bidi/script.ja.md | 347 ---------- .../webdriver_bidi/script.pt-br.md | 347 ---------- .../webdriver_bidi/script.zh-cn.md | 347 ---------- 52 files changed, 579 insertions(+), 8272 deletions(-) create mode 100644 website_and_docs/content/documentation/webdriver/bidi/_index.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/cdp/_index.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/cdp/logging.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/cdp/network.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/cdp/script.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/logging.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/network.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/script.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/_index.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/_index.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/_index.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/_index.zh-cn.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.zh-cn.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.zh-cn.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.zh-cn.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.zh-cn.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.zh-cn.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.zh-cn.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.zh-cn.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.zh-cn.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.zh-cn.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.en.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.ja.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.pt-br.md delete mode 100644 website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.zh-cn.md diff --git a/website_and_docs/content/documentation/webdriver/bidi/_index.en.md b/website_and_docs/content/documentation/webdriver/bidi/_index.en.md new file mode 100644 index 000000000000..a37413b7fc1a --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/_index.en.md @@ -0,0 +1,41 @@ +--- +title: "BiDirectional functionality" +linkTitle: "BiDi" +weight: 16 +aliases: [ +"/documentation/en/webdriver/bidi_apis/", +"/documentation/webdriver/bidi_apis/", +"/documentation/webdriver/bidirectional/bidi_api_remotewebdriver", +"/documentation/webdriver/bidirectional/webdriver_bidi", +"/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context", +"/documentation/webdriver/bidirectional/webdriver_bidi/input" +] +--- + +BiDirectional means that communication is happening in two directions simultaneously. +The traditional WebDriver model involves strict request/response commands which only allows for communication to +happen in one direction at any given time. In most cases this is what you want; it ensures that the browser is +doing the expected things in the right order, but there are a number of interesting things that can be done with +asynchronous interactions. + +This functionality is currently available in a limited fashion with the [Chrome DevTools Protocol] (CDP), +but to address some of its drawbacks, the Selenium team, along with the major +browser vendors, have worked to create the new [WebDriver BiDi Protocol](https://w3c.github.io/webdriver-bidi/). +This specification aims to create a stable, cross-browser API that leverages bidirectional +communication for enhanced browser automation and testing functionality, +including streaming events from the user agent to the controlling software via WebSockets. +Users will be able to listen for and record or manipulate events as they happen during the course of a Selenium session. + +To use WebDriver BiDi, you must [enable it in Options](http://www.example.com) + +Note that Selenium is updating its entire implementation from WebDriver Classic to WebDriver BiDi (while +maintaining backwards compatibility as much as possible), but this section of documentation focuses on the new +functionality that bidirectional communication allows. +The low-level BiDi domains will be accessible in the code to the end user, but the goal is to provide +high-level APIs that are straightforward methods of real-world use cases. As such, the low-level +components will not be documented, and this section will focus only on the user-friendly +features that we encourage users to take advantage of. + +If there is additional functionality you'd like to see, please raise a +[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). + diff --git a/website_and_docs/content/documentation/webdriver/bidi/cdp/_index.en.md b/website_and_docs/content/documentation/webdriver/bidi/cdp/_index.en.md new file mode 100644 index 000000000000..198e6d8c95f2 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/cdp/_index.en.md @@ -0,0 +1,73 @@ +--- +title: "Chrome DevTools Protocol" +linkTitle: "CDP" +weight: 10 +description: > + Examples of working with Chrome DevTools Protocol in Selenium. + CDP support is temporary until WebDriver BiDi has been implemented. +aliases: [ +"/documentation/en/support_packages/chrome_devtools/", +"/documentation/support_packages/chrome_devtools/", +"/documentation/webdriver/bidirectional/chrome_devtools/", +"documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint/", +"documentation/webdriver/bidirectional/chrome_devtools/bidi_api/", +"documentation/webdriver/bidirectional/chrome_devtools/cdp_api/", +] +--- + +Many browsers provide "DevTools" -- a set of tools that are integrated with the browser that +developers can use to debug web apps and explore the performance of their pages. Google Chrome's +DevTools make use of a protocol called the Chrome DevTools Protocol (or "CDP" for short). +As the name suggests, this is not designed for testing, nor to have a stable API, so functionality +is highly dependent on the version of the browser. + +Selenium is working to implement a standards-based, cross-browser, stable alternative to CDP called +[WebDriver BiDi]. Until the support for this new protocol has finished, Selenium plans to provide access +to CDP features where applicable. + +### Using Chrome DevTools Protocol with Selenium + +Chrome and Edge have a method to send basic CDP commands. +This does not work for features that require bidirectional communication, and you need to know what domains to enable when +and the exact names and types of domains/methods/parameters. + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/CdpTest.java#L22-L27" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_cdp.py#L2-L7" >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/CDPTest.cs#L14-L21" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/cdp_spec.rb#L9-L13" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-code >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} + + +To make working with CDP easier, and to provide access to the more advanced features, Selenium bindings +automatically generate classes and methods for the most common domains. +CDP methods and implementations can change from version to version, though, so you want to keep the +version of Chrome and the version of DevTools matching. Selenium supports the 3 most +recent versions of Chrome at any given time, +and tries to time releases to ensure that access to the latest versions are available. + +This limitation provides additional challenges for several bindings, where dynamically +generated CDP support requires users to regularly update their code to reference the proper version of CDP. +In some cases an idealized implementation has been created that should work for any version of CDP without the +user needing to change their code, but that is not always available. + +Examples of how to use CDP in your Selenium tests can be found on the following pages, but +we want to call out a couple commonly cited examples that are of limited practical value. +* **Geo Location** — almost all sites use the IP address to determine physical location, +so setting an emulated geolocation rarely has the desired effect. +* **Overriding Device Metrics** — Chrome provides a great API for setting [Mobile Emulation](https://chromedriver.chromium.org/mobile-emulation) +in the Options classes, which is generally superior to attempting to do this with CDP. diff --git a/website_and_docs/content/documentation/webdriver/bidi/cdp/logging.en.md b/website_and_docs/content/documentation/webdriver/bidi/cdp/logging.en.md new file mode 100644 index 000000000000..e2583b945e73 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/cdp/logging.en.md @@ -0,0 +1,59 @@ +--- +title: "Chrome DevTools Logging Features" +linkTitle: "Logging" +weight: 2 +description: > + Logging features using CDP. +--- + +{{% pageinfo color="warning" %}} +While Selenium 4 provides direct access to the Chrome DevTools Protocol, these +methods will eventually be removed when WebDriver BiDi implemented. +{{% /pageinfo %}} + + +## Console Logs + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/LoggingTest.java#L31" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_logs.py#L11-12" >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/LoggingTest.cs#L19-L25" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/logging_spec.rb#L12" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} + +## JavaScript Exceptions + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_logs.py#L22-L23" >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/LoggingTest.cs#L41-L47" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/logging_spec.rb#L26" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/cdp/network.en.md b/website_and_docs/content/documentation/webdriver/bidi/cdp/network.en.md new file mode 100644 index 000000000000..d69061acc79e --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/cdp/network.en.md @@ -0,0 +1,187 @@ +--- +title: "Chrome DevTools Network Features" +linkTitle: "Network" +weight: 4 +description: > + Network features using CDP. +--- + +{{% pageinfo color="warning" %}} +While Selenium 4 provides direct access to the Chrome DevTools Protocol, these +methods will eventually be removed when WebDriver BiDi implemented. +{{% /pageinfo %}} + + +## Basic authentication + +Some applications make use of browser authentication to secure pages. +It used to be common to handle them in the URL, but browsers stopped supporting this. +With this code you can insert the credentials into the header when necessary + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L41-L43" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_network.py#L13-15" >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L25-L32" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L9-L11" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{< /tabpane >}} + + +## Network Interception + +Both requests and responses can be recorded or transformed. + +#### Response information + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L56-L65" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L46-L51" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L20-L24" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} + +#### Response transformation + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L75-L85" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L62-L73" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L31-L35" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} + + +#### Request interception + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L97-L110" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L85-L97" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L42-L46" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} + + +## Performance Metrics + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L125-L126" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_logging.py#L26-L28" >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L114-L118" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L56-L57" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} + + +## Setting Cookies + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L142-L157" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_logging.py#L37-L44" >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L136-L143" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L68-L71" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} + + +## Waiting for Downloads + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L171-L176" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/network_spec.rb#L82-L88" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/cdp/script.en.md b/website_and_docs/content/documentation/webdriver/bidi/cdp/script.en.md new file mode 100644 index 000000000000..6b82792f71df --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/cdp/script.en.md @@ -0,0 +1,59 @@ +--- +title: "Chrome DevTools Script Features" +linkTitle: "Script" +weight: 6 +description: > + Script features using CDP. +--- + +{{% pageinfo color="warning" %}} +While Selenium 4 provides direct access to the Chrome DevTools Protocol, these +methods will eventually be removed when WebDriver BiDi implemented. +{{% /pageinfo %}} + +## Script Pinning + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/ScriptTest.java#L32-L34" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs#L21-L22" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/script_spec.rb#L12-L13" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} + + +## DOM Mutation Handlers + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L44" >}} +{{% /tab %}} +{{% tab header="Python" %}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_script.py#L8-L9" >}} +{{% /tab %}} +{{% tab header="CSharp" %}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/ScriptTest.cs#L39-L46" >}} +{{% /tab %}} +{{% tab header="Ruby" %}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/cdp/script_spec.rb#L22" >}} +{{% /tab %}} +{{% tab header="JavaScript" %}} +{{< badge-implementation >}} +{{% /tab %}} +{{% tab header="Kotlin" %}} +{{< badge-code >}} +{{% /tab %}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/logging.en.md b/website_and_docs/content/documentation/webdriver/bidi/logging.en.md new file mode 100644 index 000000000000..257e5f9aab4a --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/logging.en.md @@ -0,0 +1,118 @@ +--- +title: "WebDriver BiDi Logging Features" +linkTitle: "Logging" +weight: 1 +description: > + These features are related to logging. Because "logging" can refer to so many + different things, these methods are made available via a "script" namespace. +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/log", + "/documentation/webdriver/bidirectional/webdriver_bidi/log" +] +--- + +Remember that to use WebDriver BiDi, you must [enable it in Options](http://www.example.com) + +## Console Message Handlers + +Record or take actions on `console.log` events. + +### Add Handler + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Python" >}} +{{< gh-codeblock path="/examples/python/tests/bidi/test_logging.py#L11" >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L11" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< /tabpane >}} + +### Remove Handler + +You need to store the ID returned when adding the handler to delete it. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Python" >}} +{{< gh-codeblock path="/examples/python/tests/bidi/test_logging.py#L23-24" >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L22-L23" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< /tabpane >}} + +## JavaScript Exception Handlers + +Record or take actions on JavaScript exception events. + +### Add Handler + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Python" >}} +{{< gh-codeblock path="/examples/python/tests/bidi/test_logging.py#L35" >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L33" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< /tabpane >}} + +### Remove Handler + +You need to store the ID returned when adding the handler to delete it. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Python" >}} +{{< gh-codeblock path="/examples/python/tests/bidi/test_logging.py#L47-48" >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< gh-codeblock path="/examples/ruby/spec/bidi/logging_spec.rb#L44-L45" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/network.en.md b/website_and_docs/content/documentation/webdriver/bidi/network.en.md new file mode 100644 index 000000000000..248ad86b9c82 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/network.en.md @@ -0,0 +1,21 @@ +--- +title: "WebDriver BiDi Network Features" +linkTitle: "Network" +weight: 1 +description: > + These features are related to networking, and are made available via a "network" namespace. +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/network", + "/documentation/webdriver/bidirectional/webdriver_bidi/network" +] +--- + +The implementation of these features is being tracked here: [#13993](https://github.com/SeleniumHQ/selenium/issues/13993) + +Remember that to use WebDriver BiDi, you must [enable it in Options](http://www.example.com) + +## Authentication Handlers + +## Request Handlers + +## Response Handlers diff --git a/website_and_docs/content/documentation/webdriver/bidi/script.en.md b/website_and_docs/content/documentation/webdriver/bidi/script.en.md new file mode 100644 index 000000000000..2ce8c4c15032 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/script.en.md @@ -0,0 +1,21 @@ +--- +title: "WebDriver BiDi Script Features" +linkTitle: "Script" +weight: 1 +description: > + These features are related to scripts, and are made available via a "script" namespace. +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/script", + "/documentation/webdriver/bidirectional/webdriver_bidi/script" +] +--- + +The implementation of these features is being tracked here: [#13992](https://github.com/SeleniumHQ/selenium/issues/13992) + +Remember that to use WebDriver BiDi, you must [enable it in Options](http://www.example.com) + +## Script Pinning + +## Execute Script + +## DOM Mutation Handlers diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/_index.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/_index.en.md deleted file mode 100644 index 2582c19467ee..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/_index.en.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: "BiDirectional functionality" -linkTitle: "BiDirectional" -weight: 16 -aliases: [ -"/documentation/en/webdriver/bidi_apis/", -"/documentation/webdriver/bidi_apis/", -"/documentation/webdriver/bidirectional/bidi_api_remotewebdriver" -] ---- - -Selenium is working with browser vendors to create the -[WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) -as a means to provide a stable, cross-browser API that uses the bidirectional -functionality useful for both browser automation generally and testing specifically. -Before now, users seeking this functionality have had to rely on CDP (Chrome DevTools Protocol) -with all of its frustrations and limitations. - -The traditional WebDriver model of strict request/response commands will be supplemented -with the ability to stream events from the user agent to the controlling software via WebSockets, -better matching the evented nature of the browser DOM. - -As it is not a good idea to tie your tests to a specific version of any browser, the -Selenium project recommends using WebDriver BiDi wherever possible. - -While the specification is in works, the browser vendors are parallely implementing -the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/). -Refer [web-platform-tests dashboard](https://wpt.fyi/results/webdriver/tests/bidi?label=experimental&label=master&aligned&view=subtest) -to see how far along the browser vendors are. -Selenium is trying to keep up with the browser vendors and has started implementing W3C BiDi APIs. -The goal is to ensure APIs are W3C compliant and uniform among the different language bindings. - -However, until the specification and corresponding Selenium implementation is complete there are many useful things that -CDP offers. Selenium offers some useful helper classes that use CDP. \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/_index.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/_index.ja.md deleted file mode 100644 index 39b4dfdadd99..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/_index.ja.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: "BiDirectional Functionality" -linkTitle: "BiDirectional" -weight: 16 -aliases: [ -"/documentation/ja/webdriver/bidi_apis/", -"/ja/documentation/webdriver/bidi_apis/", -"/ja/documentation/webdriver/bidirectional/bidi_api_remotewebdriver" -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from English to Japanese. - Do you speak Japanese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -Selenium is working with browser vendors to create the -[WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) -as a means to provide a stable, cross-browser API that uses the bidirectional -functionality useful for both browser automation generally and testing specifically. -Before now, users seeking this functionality have had to rely on -with all of its frustrations and limitations. - -The traditional WebDriver model of strict request/response commands will be supplemented -with the ability to stream events from the user agent to the controlling software via WebSockets, -better matching the evented nature of the browser DOM. - -As it is not a good idea to tie your tests to a specific version of any browser, the -Selenium project recommends using WebDriver BiDi wherever possible. - -While the specification is in works, the browser vendors are parallely implementing -the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/). -Refer [web-platform-tests dashboard](https://wpt.fyi/results/webdriver/tests/bidi?label=experimental&label=master&aligned&view=subtest) -to see how far along the browser vendors are. -Selenium is trying to keep up with the browser vendors and has started implementing W3C BiDi APIs. -The goal is to ensure APIs are W3C compliant and uniform among the different language bindings. - -However, until the specification and corresponding Selenium implementation is complete there are many useful things that -CDP offers. Selenium offers some useful helper classes that use CDP. \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/_index.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/_index.pt-br.md deleted file mode 100644 index 218ad8df93a3..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/_index.pt-br.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: "BiDirectional Functionality" -linkTitle: "BiDirectional" -weight: 16 -aliases: [ -"/documentation/pt-br/webdriver/bidi_apis/", -"/pt-br/documentation/webdriver/bidi_apis/", -"/pt-br/documentation/webdriver/bidirectional/bidi_api_remotewebdriver" -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Portuguese. Do you speak Portuguese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -Selenium is working with browser vendors to create the -[WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) -as a means to provide a stable, cross-browser API that uses the bidirectional -functionality useful for both browser automation generally and testing specifically. -Before now, users seeking this functionality have had to rely on -with all of its frustrations and limitations. - -The traditional WebDriver model of strict request/response commands will be supplemented -with the ability to stream events from the user agent to the controlling software via WebSockets, -better matching the evented nature of the browser DOM. - -As it is not a good idea to tie your tests to a specific version of any browser, the -Selenium project recommends using WebDriver BiDi wherever possible. - -While the specification is in works, the browser vendors are parallely implementing -the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/). -Refer [web-platform-tests dashboard](https://wpt.fyi/results/webdriver/tests/bidi?label=experimental&label=master&aligned&view=subtest) -to see how far along the browser vendors are. -Selenium is trying to keep up with the browser vendors and has started implementing W3C BiDi APIs. -The goal is to ensure APIs are W3C compliant and uniform among the different language bindings. - -However, until the specification and corresponding Selenium implementation is complete there are many useful things that -CDP offers. Selenium offers some useful helper classes that use CDP. \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/_index.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/_index.zh-cn.md deleted file mode 100644 index 731e9555de00..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/_index.zh-cn.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: "双向协议" -linkTitle: "双向协议" -weight: 16 -aliases: [ -"/documentation/zh-cn/webdriver/bidi_apis/", -"/zh-cn/documentation/webdriver/bidi_apis/", -"/zh-cn/documentation/webdriver/bidirectional/bidi_api_remotewebdriver" -] ---- - -Selenium正在与浏览器供应商合作创建 -[WebDriver双向协议](https://w3c.github.io/webdriver-bidi/) , -作为一种提供稳定的跨浏览器API的方法, -该API使用双向协议处理 -各种浏览器的通用自动化以及特定测试的需求. -在此之前, 寻求此功能的用户 -必须忍受当前实现的全部问题和局限. - - -严格限制请求响应命令的传统WebDriver模型, -将从user agent转变为基于WebSockets的软件控制, -通过这样完善流事件的能力, -以便更好地匹配浏览器DOM的事件性质. - -While the specification is in works, the browser vendors are parallely implementing -the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/). -Refer [web-platform-tests dashboard](https://wpt.fyi/results/webdriver/tests/bidi?label=experimental&label=master&aligned&view=subtest) -to see how far along the browser vendors are. -Selenium is trying to keep up with the browser vendors and has started implementing W3C BiDi APIs. -The goal is to ensure APIs are W3C compliant and uniform among the different language bindings. - -However, until the specification and corresponding Selenium implementation is complete there are many useful things that -CDP offers. Selenium offers some useful helper classes that use CDP. \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.en.md deleted file mode 100644 index 6965c884fc70..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.en.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -title: "Chrome DevTools" -linkTitle: "Chrome DevTools" -weight: 2 -aliases: [ -"/documentation/en/support_packages/chrome_devtools/", -"/documentation/support_packages/chrome_devtools/" -] ---- - -Many browsers provide "DevTools" -- a set of tools that are integrated with the browser that -developers can use to debug web apps and explore the performance of their pages. Google Chrome's -DevTools make use of a protocol called the Chrome DevTools Protocol (or "CDP" for short). -As the name suggests, this is not designed for testing, nor to have a stable API, so functionality -is highly dependent on the version of the browser. - -The [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) is the next generation of the -W3C WebDriver protocol and aims to provide a stable API implemented by all browsers, but it's not yet complete. -Until it is, Selenium provides access to -the CDP for those browsers that implement it (such as Google Chrome, or Microsoft Edge, and -Firefox), allowing you to enhance your tests in interesting ways. Some examples of what you can -do with it are given below. - -### Ways to Use Chrome DevTools With Selenium -There are three different ways to access Chrome DevTools in Selenium. If you look for other examples online, -you will likely see each of these mixed and matched. - -* The [CDP Endpoint]({{< ref "cdp_endpoint.md" >}}) was the first option available to users. -It only works for the most simple things (setting state, getting basic information), and you -have to know the "magic strings" for the domain and methods and key value pairs. -For basic requirements, this might be simpler than the other options. These methods are only temporarily supported. -* The [CDP API]({{< ref "cdp_api.md" >}}) is an improvement on just using the endpoint because you can set -do things asynchronously. Instead of a String and a Map, you can access the supported classes, -methods and parameters in the code. These methods are also only temporarily supported. -* The [BiDi API]({{< ref "bidi_api.md" >}}) option should be used whenever possible because it -abstracts away the implementation details entirely and will work with either CDP or WebDriver-BiDi -when Selenium moves away from CDP. - -### Examples With Limited Value - -There are a number of commonly cited examples for using CDP that are of limited practical value. -* **Geo Location** — almost all sites use the IP address to determine physical location, -so setting an emulated geolocation rarely has the desired effect. -* **Overriding Device Metrics** — Chrome provides a great API for setting [Mobile Emulation](https://chromedriver.chromium.org/mobile-emulation) -in the Options classes, which is generally superior to attempting to do this with CDP. - -Check out the examples in these documents for ways to do additional useful things: diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.ja.md deleted file mode 100644 index 17b043d19b0f..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.ja.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -title: "Chrome DevTools" -linkTitle: "Chrome DevTools" -weight: 2 -aliases: [ -"/documentation/ja/support_packages/chrome_devtools/", -"/ja/documentation/support_packages/chrome_devtools/" -] ---- - -Many browsers provide "DevTools" -- a set of tools that are integrated with the browser that -developers can use to debug web apps and explore the performance of their pages. Google Chrome's -DevTools make use of a protocol called the Chrome DevTools Protocol (or "CDP" for short). -As the name suggests, this is not designed for testing, nor to have a stable API, so functionality -is highly dependent on the version of the browser. - -The [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) is the next generation of the -W3C WebDriver protocol and aims to provide a stable API implemented by all browsers, but it's not yet complete. -Until it is, Selenium provides access to -the CDP for those browsers that implement it (such as Google Chrome, or Microsoft Edge, and -Firefox), allowing you to enhance your tests in interesting ways. Some examples of what you can -do with it are given below. - -### Ways to Use Chrome DevTools With Selenium -There are three different ways to access Chrome DevTools in Selenium. If you look for other examples online, -you will likely see each of these mixed and matched. - -* The [CDP Endpoint]({{< ref "cdp_endpoint.md" >}}) was the first option available to users. -It only works for the most simple things (setting state, getting basic information), and you -have to know the "magic strings" for the domain and methods and key value pairs. -For basic requirements, this might be simpler than the other options. These methods are only temporarily supported. -* The [CDP API]({{< ref "cdp_api.md" >}}) is an improvement on just using the endpoint because you can set -do things asynchronously. Instead of a String and a Map, you can access the supported classes, -methods and parameters in the code. These methods are also only temporarily supported. -* The [BiDi API]({{< ref "bidi_api.md" >}}) option should be used whenever possible because it -abstracts away the implementation details entirely and will work with either CDP or WebDriver-BiDi -when Selenium moves away from CDP. - -### Examples With Limited Value - -There are a number of commonly cited examples for using CDP that are of limited practical value. -* **Geo Location** — almost all sites use the IP address to determine physical location, -so setting an emulated geolocation rarely has the desired effect. -* **Overriding Device Metrics** — Chrome provides a great API for setting [Mobile Emulation](https://chromedriver.chromium.org/mobile-emulation) -in the Options classes, which is generally superior to attempting to do this with CDP. - -Check out the examples in these documents for ways to do additional useful things: diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.pt-br.md deleted file mode 100644 index d9256c366fe6..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.pt-br.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -title: "Chrome DevTools" -linkTitle: "Chrome DevTools" -weight: 2 -aliases: [ -"/documentation/pt-br/support_packages/chrome_devtools/", -"/pt-br/documentation/support_packages/chrome_devtools/" -] ---- - -Many browsers provide "DevTools" -- a set of tools that are integrated with the browser that -developers can use to debug web apps and explore the performance of their pages. Google Chrome's -DevTools make use of a protocol called the Chrome DevTools Protocol (or "CDP" for short). -As the name suggests, this is not designed for testing, nor to have a stable API, so functionality -is highly dependent on the version of the browser. - -The [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) is the next generation of the -W3C WebDriver protocol and aims to provide a stable API implemented by all browsers, but it's not yet complete. -Until it is, Selenium provides access to -the CDP for those browsers that implement it (such as Google Chrome, or Microsoft Edge, and -Firefox), allowing you to enhance your tests in interesting ways. Some examples of what you can -do with it are given below. - -### Ways to Use Chrome DevTools With Selenium -There are three different ways to access Chrome DevTools in Selenium. If you look for other examples online, -you will likely see each of these mixed and matched. - -* The [CDP Endpoint]({{< ref "cdp_endpoint.md" >}}) was the first option available to users. -It only works for the most simple things (setting state, getting basic information), and you -have to know the "magic strings" for the domain and methods and key value pairs. -For basic requirements, this might be simpler than the other options. These methods are only temporarily supported. -* The [CDP API]({{< ref "cdp_api.md" >}}) is an improvement on just using the endpoint because you can set -do things asynchronously. Instead of a String and a Map, you can access the supported classes, -methods and parameters in the code. These methods are also only temporarily supported. -* The [BiDi API]({{< ref "bidi_api.md" >}}) option should be used whenever possible because it -abstracts away the implementation details entirely and will work with either CDP or WebDriver-BiDi -when Selenium moves away from CDP. - -### Examples With Limited Value - -There are a number of commonly cited examples for using CDP that are of limited practical value. -* **Geo Location** — almost all sites use the IP address to determine physical location, -so setting an emulated geolocation rarely has the desired effect. -* **Overriding Device Metrics** — Chrome provides a great API for setting [Mobile Emulation](https://chromedriver.chromium.org/mobile-emulation) -in the Options classes, which is generally superior to attempting to do this with CDP. - -Check out the examples in these documents for ways to do additional useful things: diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.zh-cn.md deleted file mode 100644 index 0ad7b3c715f7..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/_index.zh-cn.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -title: "Chrome DevTools" -linkTitle: "Chrome DevTools" -weight: 2 -aliases: [ -"/documentation/zh-cn/support_packages/chrome_devtools/", -"/zh-cn/documentation/support_packages/chrome_devtools/" -] ---- - -Many browsers provide "DevTools" -- a set of tools that are integrated with the browser that -developers can use to debug web apps and explore the performance of their pages. Google Chrome's -DevTools make use of a protocol called the Chrome DevTools Protocol (or "CDP" for short). -As the name suggests, this is not designed for testing, nor to have a stable API, so functionality -is highly dependent on the version of the browser. - -The [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) is the next generation of the -W3C WebDriver protocol and aims to provide a stable API implemented by all browsers, but it's not yet complete. -Until it is, Selenium provides access to -the CDP for those browsers that implement it (such as Google Chrome, or Microsoft Edge, and -Firefox), allowing you to enhance your tests in interesting ways. Some examples of what you can -do with it are given below. - -### Ways to Use Chrome DevTools With Selenium -There are three different ways to access Chrome DevTools in Selenium. If you look for other examples online, -you will likely see each of these mixed and matched. - -* The [CDP Endpoint]({{< ref "cdp_endpoint.md" >}}) was the first option available to users. -It only works for the most simple things (setting state, getting basic information), and you -have to know the "magic strings" for the domain and methods and key value pairs. -For basic requirements, this might be simpler than the other options. These methods are only temporarily supported. -* The [CDP API]({{< ref "cdp_api.md" >}}) is an improvement on just using the endpoint because you can set -do things asynchronously. Instead of a String and a Map, you can access the supported classes, -methods and parameters in the code. These methods are also only temporarily supported. -* The [BiDi API]({{< ref "bidi_api.md" >}}) option should be used whenever possible because it -abstracts away the implementation details entirely and will work with either CDP or WebDriver-BiDi -when Selenium moves away from CDP. - -### Examples With Limited Value - -There are a number of commonly cited examples for using CDP that are of limited practical value. -* **Geo Location** — almost all sites use the IP address to determine physical location, -so setting an emulated geolocation rarely has the desired effect. -* **Overriding Device Metrics** — Chrome provides a great API for setting [Mobile Emulation](https://chromedriver.chromium.org/mobile-emulation) -in the Options classes, which is generally superior to attempting to do this with CDP. - -Check out the examples in these documents for ways to do additional useful things: diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.en.md deleted file mode 100644 index da625febd386..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.en.md +++ /dev/null @@ -1,359 +0,0 @@ ---- -title: "Chrome Devtools Protocol with BiDi API" -linkTitle: "BiDi API" -weight: 6 -description: > - These examples are currently implemented with CDP, but the same code should work when the functionality - is re-implemented with WebDriver-BiDi. ---- - -## Usage - -The following list of APIs will be growing as the Selenium -project works through supporting real world use cases. If there -is additional functionality you'd like to see, please raise a -[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). - -As these examples are re-implemented with the [WebDriver-Bidi](https://w3c.github.io/webdriver-bidi) protocol, they will -be moved to the [WebDriver Bidi]({{< ref "../webdriver_bidi/" >}}) pages. - -## Examples - -### Basic authentication - -Some applications make use of browser authentication to secure pages. -It used to be common to handle them in the URL, but browser stopped supporting this. -With BiDi, you can now provide the credentials when necessary - -Alternate implementations can be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -and [CDP API Basic Authentication]({{< ref "cdp_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L36-L39" >}} -{{% /tab %}} -{{% tab header="Python" %}} -An alternate implementation may be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L18-L27" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L9-L11" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const {Builder} = require('selenium-webdriver'); - -(async function example() { - try { - let driver = await new Builder() - .forBrowser('chrome') - .build(); - - const pageCdpConnection = await driver.createCDPConnection('page'); - await driver.register('username', 'password', pageCdpConnection); - await driver.get('https://the-internet.herokuapp.com/basic_auth'); - await driver.quit(); - }catch (e){ - console.log(e) - } -}()) -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -val uriPredicate = Predicate { uri: URI -> - uri.host.contains("your-domain.com") - } -(driver as HasAuthentication).register(uriPredicate, UsernameAndPassword.of("admin", "password")) -driver.get("https://your-domain.com/login") -``` -{{% /tab %}} -{{< /tabpane >}} - - -### Pin scripts - -This can be especially useful when executing on a remote server. For example, -whenever you check the visibility of an element, or whenever you use -the classic get attribute method, Selenium is sending the contents of a js file -to the script execution endpoint. These files are each about 50kB, which adds up. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L41-L43" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L22-L23" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - - -### Mutation observation - -Mutation Observation is the ability to capture events via -WebDriver BiDi when there are DOM mutations on a specific -element in the DOM. - -{{< tabpane text=true >}} - {{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L64-L65" >}} - {{% /tab %}} - {{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L9-L11" >}} - {{% /tab %}} - {{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L59-L68" >}} - {{% /tab %}} - {{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L31-L32" >}} - {{< /tab >}} - {{% tab header="JavaScript" %}} - {{< badge-examples >}} -```js -const {Builder, until} = require('selenium-webdriver'); -const assert = require("assert"); - -(async function example() { - try { - let driver = await new Builder() - .forBrowser('chrome') - .build(); - - const cdpConnection = await driver.createCDPConnection('page'); - await driver.logMutationEvents(cdpConnection, event => { - assert.deepStrictEqual(event['attribute_name'], 'style'); - assert.deepStrictEqual(event['current_value'], ""); - assert.deepStrictEqual(event['old_value'], "display:none;"); - }); - - await driver.get('dynamic.html'); - await driver.findElement({id: 'reveal'}).click(); - let revealed = driver.findElement({id: 'revealed'}); - await driver.wait(until.elementIsVisible(revealed), 5000); - await driver.quit(); - }catch (e){ - console.log(e) - } -}()) -``` -{{% /tab %}} - {{< tab header="Kotlin" >}} -{{< badge-code >}} - {{< /tab >}} -{{< /tabpane >}} - - -### Console logs and errors - -Listen to the `console.log` events and register callbacks to process the event. - -[CDP API Console logs]({{< ref "cdp_api#console-logs-and-errors" >}}) -and [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) implementation. `HasLogEvents` -will likely end up deprecated because it does not implement `Closeable`. -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L77-L78" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L23-L26" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L85-L92" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L43-L44" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const {Builder} = require('selenium-webdriver'); -(async () => { - try { - let driver = new Builder() - .forBrowser('chrome') - .build(); - - const cdpConnection = await driver.createCDPConnection('page'); - await driver.onLogEvent(cdpConnection, function (event) { - console.log(event['args'][0]['value']); - }); - await driver.executeScript('console.log("here")'); - await driver.quit(); - }catch (e){ - console.log(e); - } -})() -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -fun kotlinConsoleLogExample() { - val driver = ChromeDriver() - val devTools = driver.devTools - devTools.createSession() - - val logConsole = { c: ConsoleEvent -> print("Console log message is: " + c.messages)} - devTools.domains.events().addConsoleListener(logConsole) - - driver.get("https://www.google.com") - - val executor = driver as JavascriptExecutor - executor.executeScript("console.log('Hello World')") - - val input = driver.findElement(By.name("q")) - input.sendKeys("Selenium 4") - input.sendKeys(Keys.RETURN) - driver.quit() -} -``` -{{% /tab %}} -{{< /tabpane >}} - - -### JavaScript exceptions - -Listen to the JS Exceptions -and register callbacks to process the exception details. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) implementation -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L36-L39" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L107-L114" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L57-L58" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - - -### Network Interception - -Both requests and responses can be recorded or transformed. - -#### Response information - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L90-L101" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L125-L133" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L67-L72" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -#### Response transformation - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L111-L121" >}} -{{< /tab >}} -{{< tab header="Python" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L143-L156" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L79-L83" >}} -{{< /tab >}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const connection = await driver.createCDPConnection('page') -let url = fileServer.whereIs("/cheese") -let httpResponse = new HttpResponse(url) -httpResponse.addHeaders("Content-Type", "UTF-8") -httpResponse.body = "sausages" -await driver.onIntercept(connection, httpResponse, async function () { - let body = await driver.getPageSource() - assert.strictEqual(body.includes("sausages"), true, `Body contains: ${body}`) -}) -driver.get(url) -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -val driver = ChromeDriver() -val interceptor = new NetworkInterceptor( - driver, - Route.matching(req -> true) - .to(() -> req -> new HttpResponse() - .setStatus(200) - .addHeader("Content-Type", MediaType.HTML_UTF_8.toString()) - .setContent(utf8String("Creamy, delicious cheese!")))) - - driver.get(appServer.whereIs("/cheese")) - - String source = driver.getPageSource() -``` -{{% /tab %}} -{{< /tabpane >}} - -#### Request interception - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="Python" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L167-L181" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L90-L94" >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.ja.md deleted file mode 100644 index 659735eeaae2..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.ja.md +++ /dev/null @@ -1,361 +0,0 @@ ---- -title: "Chrome Devtools Protocol with BiDi API" -linkTitle: "BiDi API" -weight: 6 -description: > - These examples are currently implemented with CDP, but the same code should work when the functionality - is re-implemented with WebDriver-BiDi. ---- - -## Usage - -The following list of APIs will be growing as the Selenium -project works through supporting real world use cases. If there -is additional functionality you'd like to see, please raise a -[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). - -As these examples are re-implemented with the [WebDriver-Bidi](https://w3c.github.io/webdriver-bidi) protocol, they will -be moved to the [WebDriver Bidi]({{< ref "../webdriver_bidi/" >}}) pages. - -## Examples - -### Basic authentication - -Some applications make use of browser authentication to secure pages. -It used to be common to handle them in the URL, but browser stopped supporting this. -With BiDi, you can now provide the credentials when necessary - -Alternate implementations can be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -and [CDP API Basic Authentication]({{< ref "cdp_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L36-L39" >}} -{{% /tab %}} -{{% tab header="Python" %}} -An alternate implementation may be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L18-L27" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L9-L11" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} - -```js -const {Builder} = require('selenium-webdriver'); - -(async function example() { - try { - let driver = await new Builder() - .forBrowser('chrome') - .build(); - - const pageCdpConnection = await driver.createCDPConnection('page'); - await driver.register('username', 'password', pageCdpConnection); - await driver.get('https://the-internet.herokuapp.com/basic_auth'); - await driver.quit(); - }catch (e){ - console.log(e) - } -}()) -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} - -```java -val uriPredicate = Predicate { uri: URI -> - uri.host.contains("your-domain.com") - } -(driver as HasAuthentication).register(uriPredicate, UsernameAndPassword.of("admin", "password")) -driver.get("https://your-domain.com/login") -``` -{{% /tab %}} -{{< /tabpane >}} - - -### Pin scripts - -This can be especially useful when executing on a remote server. For example, -whenever you check the visibility of an element, or whenever you use -the classic get attribute method, Selenium is sending the contents of a js file -to the script execution endpoint. These files are each about 50kB, which adds up. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L41-L43" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L22-L23" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - - -### Mutation observation - -Mutation Observation is the ability to capture events via -WebDriver BiDi when there are DOM mutations on a specific -element in the DOM. - -{{< tabpane text=true >}} - {{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L64-L65" >}} - {{% /tab %}} - {{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L9-L11" >}} - {{% /tab %}} - {{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L59-L68" >}} - {{% /tab %}} - {{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L31-L32" >}} - {{< /tab >}} - {{% tab header="JavaScript" %}} - {{< badge-examples >}} -```js -const {Builder, until} = require('selenium-webdriver'); -const assert = require("assert"); - -(async function example() { - try { - let driver = await new Builder() - .forBrowser('chrome') - .build(); - - const cdpConnection = await driver.createCDPConnection('page'); - await driver.logMutationEvents(cdpConnection, event => { - assert.deepStrictEqual(event['attribute_name'], 'style'); - assert.deepStrictEqual(event['current_value'], ""); - assert.deepStrictEqual(event['old_value'], "display:none;"); - }); - - await driver.get('dynamic.html'); - await driver.findElement({id: 'reveal'}).click(); - let revealed = driver.findElement({id: 'revealed'}); - await driver.wait(until.elementIsVisible(revealed), 5000); - await driver.quit(); - }catch (e){ - console.log(e) - } -}()) -``` -{{% /tab %}} - {{< tab header="Kotlin" >}} -{{< badge-code >}} - {{< /tab >}} -{{< /tabpane >}} - - -### Console logs and errors - -Listen to the `console.log` events and register callbacks to process the event. - -[CDP API Console logs]({{< ref "cdp_api#console-logs-and-errors" >}}) -and [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) implementation. `HasLogEvents` -will likely end up deprecated because it does not implement `Closeable`. -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L77-L78" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L23-L26" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L85-L92" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L43-L44" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const {Builder} = require('selenium-webdriver'); -(async () => { - try { - let driver = new Builder() - .forBrowser('chrome') - .build(); - - const cdpConnection = await driver.createCDPConnection('page'); - await driver.onLogEvent(cdpConnection, function (event) { - console.log(event['args'][0]['value']); - }); - await driver.executeScript('console.log("here")'); - await driver.quit(); - }catch (e){ - console.log(e); - } -})() -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -fun kotlinConsoleLogExample() { - val driver = ChromeDriver() - val devTools = driver.devTools - devTools.createSession() - - val logConsole = { c: ConsoleEvent -> print("Console log message is: " + c.messages)} - devTools.domains.events().addConsoleListener(logConsole) - - driver.get("https://www.google.com") - - val executor = driver as JavascriptExecutor - executor.executeScript("console.log('Hello World')") - - val input = driver.findElement(By.name("q")) - input.sendKeys("Selenium 4") - input.sendKeys(Keys.RETURN) - driver.quit() -} -``` -{{% /tab %}} -{{< /tabpane >}} - - -### JavaScript exceptions - -Listen to the JS Exceptions -and register callbacks to process the exception details. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) implementation -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L36-L39" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L107-L114" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L57-L58" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - - -### Network Interception - -Both requests and responses can be recorded or transformed. - -#### Response information - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L90-L101" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L125-L133" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L67-L72" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -#### Response transformation - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L111-L121" >}} -{{< /tab >}} -{{< tab header="Python" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L143-L156" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L79-L83" >}} -{{< /tab >}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const connection = await driver.createCDPConnection('page') -let url = fileServer.whereIs("/cheese") -let httpResponse = new HttpResponse(url) -httpResponse.addHeaders("Content-Type", "UTF-8") -httpResponse.body = "sausages" -await driver.onIntercept(connection, httpResponse, async function () { - let body = await driver.getPageSource() - assert.strictEqual(body.includes("sausages"), true, `Body contains: ${body}`) -}) -driver.get(url) -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -val driver = ChromeDriver() -val interceptor = new NetworkInterceptor( - driver, - Route.matching(req -> true) - .to(() -> req -> new HttpResponse() - .setStatus(200) - .addHeader("Content-Type", MediaType.HTML_UTF_8.toString()) - .setContent(utf8String("Creamy, delicious cheese!")))) - - driver.get(appServer.whereIs("/cheese")) - - String source = driver.getPageSource() -``` -{{% /tab %}} -{{< /tabpane >}} - -#### Request interception - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="Python" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L167-L181" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L90-L94" >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.pt-br.md deleted file mode 100644 index b0174aef9bb8..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.pt-br.md +++ /dev/null @@ -1,350 +0,0 @@ ---- -title: "Chrome Devtools Protocol with BiDi API" -linkTitle: "BiDi API" -weight: 6 -description: > - These examples are currently implemented with CDP, but the same code should work when the functionality - is re-implemented with WebDriver-BiDi. ---- - -## Usage - -A seguinte lista de APIs crescerá à medida que o projeto Selenium se prepara -para suportar casos de uso do mundo real. Se houver funcionalidades adicionais que você gostaria de ver, por favor, levante uma [solicitação de recurso](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). - -As these examples are re-implemented with the [WebDriver-Bidi](https://w3c.github.io/webdriver-bidi) protocol, they will -be moved to the [WebDriver Bidi]({{< ref "../webdriver_bidi/" >}}) pages. - -## Examples - -### Basic authentication - -Alguns aplicativos fazem o uso da autenticação do navegador para proteger suas páginas. Com o Selenium, você pode automatizar a entrada de credenciais básicas de autenticação sempre que for necessário. - -Alternate implementations can be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -and [CDP API Basic Authentication]({{< ref "cdp_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L36-L39" >}} -{{% /tab %}} -{{% tab header="Python" %}} -An alternate implementation may be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L18-L27" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L9-L11" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const {Builder} = require('selenium-webdriver'); - -(async function example() { - try { - let driver = await new Builder() - .forBrowser('chrome') - .build(); - - const pageCdpConnection = await driver.createCDPConnection('page'); - await driver.register('username', 'password', pageCdpConnection); - await driver.get('https://the-internet.herokuapp.com/basic_auth'); - await driver.quit(); - }catch (e){ - console.log(e) - } -}()) -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -val uriPredicate = Predicate { uri: URI -> - uri.host.contains("your-domain.com") - } -(driver as HasAuthentication).register(uriPredicate, UsernameAndPassword.of("admin", "password")) -driver.get("https://your-domain.com/login") -``` -{{% /tab %}} -{{< /tabpane >}} - - -### Pin scripts -This can be especially useful when executing on a remote server. For example, -whenever you check the visibility of an element, or whenever you use -the classic get attribute method, Selenium is sending the contents of a js file -to the script execution endpoint. These files are each about 50kB, which adds up. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L41-L43" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L22-L23" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - - -### Mutation observation - -Mutation Observation(Observação de Mutação) é a capacidade de capturar eventos via WebDriver BiDi quando há mutações DOM em um elemento específico no DOM. - -{{< tabpane text=true >}} - {{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L64-L65" >}} - {{% /tab %}} - {{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L9-L11" >}} - {{% /tab %}} - {{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L59-L68" >}} - {{% /tab %}} - {{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L31-L32" >}} - {{< /tab >}} - {{% tab header="JavaScript" %}} - {{< badge-examples >}} -```js -const {Builder, until} = require('selenium-webdriver'); -const assert = require("assert"); - -(async function example() { - try { - let driver = await new Builder() - .forBrowser('chrome') - .build(); - - const cdpConnection = await driver.createCDPConnection('page'); - await driver.logMutationEvents(cdpConnection, event => { - assert.deepStrictEqual(event['attribute_name'], 'style'); - assert.deepStrictEqual(event['current_value'], ""); - assert.deepStrictEqual(event['old_value'], "display:none;"); - }); - - await driver.get('dynamic.html'); - await driver.findElement({id: 'reveal'}).click(); - let revealed = driver.findElement({id: 'revealed'}); - await driver.wait(until.elementIsVisible(revealed), 5000); - await driver.quit(); - }catch (e){ - console.log(e) - } -}()) -``` -{{% /tab %}} - {{< tab header="Kotlin" >}} -{{< badge-code >}} - {{< /tab >}} -{{< /tabpane >}} - - -### Console logs and errors -Vigie os eventos `console.log` e registre os callbacks(retornos de chamada) para processar o evento. - -[CDP API Console logs]({{< ref "cdp_api#console-logs-and-errors" >}}) -and [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) implementation. `HasLogEvents` -will likely end up deprecated because it does not implement `Closeable`. -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L77-L78" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L23-L26" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L85-L92" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L43-L44" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const {Builder} = require('selenium-webdriver'); -(async () => { - try { - let driver = new Builder() - .forBrowser('chrome') - .build(); - - const cdpConnection = await driver.createCDPConnection('page'); - await driver.onLogEvent(cdpConnection, function (event) { - console.log(event['args'][0]['value']); - }); - await driver.executeScript('console.log("here")'); - await driver.quit(); - }catch (e){ - console.log(e); - } -})() -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -fun kotlinConsoleLogExample() { - val driver = ChromeDriver() - val devTools = driver.devTools - devTools.createSession() - - val logConsole = { c: ConsoleEvent -> print("Console log message is: " + c.messages)} - devTools.domains.events().addConsoleListener(logConsole) - - driver.get("https://www.google.com") - - val executor = driver as JavascriptExecutor - executor.executeScript("console.log('Hello World')") - - val input = driver.findElement(By.name("q")) - input.sendKeys("Selenium 4") - input.sendKeys(Keys.RETURN) - driver.quit() -} -``` -{{% /tab %}} -{{< /tabpane >}} - -### JavaScript exceptions - -Vigie as exceções JS -e registre callbacks(retornos de chamada) para processar os detalhes da exceção. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) implementation -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L36-L39" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L107-L114" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L57-L58" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - - -### Interceptação de Rede - -Both requests and responses can be recorded or transformed. - -#### Response information - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L90-L101" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L125-L133" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L67-L72" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -#### Response transformation - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L111-L121" >}} -{{< /tab >}} -{{< tab header="Python" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L143-L156" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L79-L83" >}} -{{< /tab >}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const connection = await driver.createCDPConnection('page') -let url = fileServer.whereIs("/cheese") -let httpResponse = new HttpResponse(url) -httpResponse.addHeaders("Content-Type", "UTF-8") -httpResponse.body = "sausages" -await driver.onIntercept(connection, httpResponse, async function () { - let body = await driver.getPageSource() - assert.strictEqual(body.includes("sausages"), true, `Body contains: ${body}`) -}) -driver.get(url) -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -val driver = ChromeDriver() -val interceptor = new NetworkInterceptor( - driver, - Route.matching(req -> true) - .to(() -> req -> new HttpResponse() - .setStatus(200) - .addHeader("Content-Type", MediaType.HTML_UTF_8.toString()) - .setContent(utf8String("Creamy, delicious cheese!")))) - - driver.get(appServer.whereIs("/cheese")) - - String source = driver.getPageSource() -``` -{{% /tab %}} -{{< /tabpane >}} - -#### Request interception - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="Python" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L167-L181" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L90-L94" >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.zh-cn.md deleted file mode 100644 index da625febd386..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/bidi_api.zh-cn.md +++ /dev/null @@ -1,359 +0,0 @@ ---- -title: "Chrome Devtools Protocol with BiDi API" -linkTitle: "BiDi API" -weight: 6 -description: > - These examples are currently implemented with CDP, but the same code should work when the functionality - is re-implemented with WebDriver-BiDi. ---- - -## Usage - -The following list of APIs will be growing as the Selenium -project works through supporting real world use cases. If there -is additional functionality you'd like to see, please raise a -[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). - -As these examples are re-implemented with the [WebDriver-Bidi](https://w3c.github.io/webdriver-bidi) protocol, they will -be moved to the [WebDriver Bidi]({{< ref "../webdriver_bidi/" >}}) pages. - -## Examples - -### Basic authentication - -Some applications make use of browser authentication to secure pages. -It used to be common to handle them in the URL, but browser stopped supporting this. -With BiDi, you can now provide the credentials when necessary - -Alternate implementations can be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -and [CDP API Basic Authentication]({{< ref "cdp_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L36-L39" >}} -{{% /tab %}} -{{% tab header="Python" %}} -An alternate implementation may be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L18-L27" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L9-L11" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const {Builder} = require('selenium-webdriver'); - -(async function example() { - try { - let driver = await new Builder() - .forBrowser('chrome') - .build(); - - const pageCdpConnection = await driver.createCDPConnection('page'); - await driver.register('username', 'password', pageCdpConnection); - await driver.get('https://the-internet.herokuapp.com/basic_auth'); - await driver.quit(); - }catch (e){ - console.log(e) - } -}()) -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -val uriPredicate = Predicate { uri: URI -> - uri.host.contains("your-domain.com") - } -(driver as HasAuthentication).register(uriPredicate, UsernameAndPassword.of("admin", "password")) -driver.get("https://your-domain.com/login") -``` -{{% /tab %}} -{{< /tabpane >}} - - -### Pin scripts - -This can be especially useful when executing on a remote server. For example, -whenever you check the visibility of an element, or whenever you use -the classic get attribute method, Selenium is sending the contents of a js file -to the script execution endpoint. These files are each about 50kB, which adds up. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L41-L43" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L22-L23" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - - -### Mutation observation - -Mutation Observation is the ability to capture events via -WebDriver BiDi when there are DOM mutations on a specific -element in the DOM. - -{{< tabpane text=true >}} - {{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L64-L65" >}} - {{% /tab %}} - {{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L9-L11" >}} - {{% /tab %}} - {{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L59-L68" >}} - {{% /tab %}} - {{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L31-L32" >}} - {{< /tab >}} - {{% tab header="JavaScript" %}} - {{< badge-examples >}} -```js -const {Builder, until} = require('selenium-webdriver'); -const assert = require("assert"); - -(async function example() { - try { - let driver = await new Builder() - .forBrowser('chrome') - .build(); - - const cdpConnection = await driver.createCDPConnection('page'); - await driver.logMutationEvents(cdpConnection, event => { - assert.deepStrictEqual(event['attribute_name'], 'style'); - assert.deepStrictEqual(event['current_value'], ""); - assert.deepStrictEqual(event['old_value'], "display:none;"); - }); - - await driver.get('dynamic.html'); - await driver.findElement({id: 'reveal'}).click(); - let revealed = driver.findElement({id: 'revealed'}); - await driver.wait(until.elementIsVisible(revealed), 5000); - await driver.quit(); - }catch (e){ - console.log(e) - } -}()) -``` -{{% /tab %}} - {{< tab header="Kotlin" >}} -{{< badge-code >}} - {{< /tab >}} -{{< /tabpane >}} - - -### Console logs and errors - -Listen to the `console.log` events and register callbacks to process the event. - -[CDP API Console logs]({{< ref "cdp_api#console-logs-and-errors" >}}) -and [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) implementation. `HasLogEvents` -will likely end up deprecated because it does not implement `Closeable`. -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L77-L78" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L23-L26" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L85-L92" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L43-L44" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const {Builder} = require('selenium-webdriver'); -(async () => { - try { - let driver = new Builder() - .forBrowser('chrome') - .build(); - - const cdpConnection = await driver.createCDPConnection('page'); - await driver.onLogEvent(cdpConnection, function (event) { - console.log(event['args'][0]['value']); - }); - await driver.executeScript('console.log("here")'); - await driver.quit(); - }catch (e){ - console.log(e); - } -})() -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -fun kotlinConsoleLogExample() { - val driver = ChromeDriver() - val devTools = driver.devTools - devTools.createSession() - - val logConsole = { c: ConsoleEvent -> print("Console log message is: " + c.messages)} - devTools.domains.events().addConsoleListener(logConsole) - - driver.get("https://www.google.com") - - val executor = driver as JavascriptExecutor - executor.executeScript("console.log('Hello World')") - - val input = driver.findElement(By.name("q")) - input.sendKeys("Selenium 4") - input.sendKeys(Keys.RETURN) - driver.quit() -} -``` -{{% /tab %}} -{{< /tabpane >}} - - -### JavaScript exceptions - -Listen to the JS Exceptions -and register callbacks to process the exception details. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) implementation -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_bidi_api.py#L36-L39" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L107-L114" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L57-L58" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - - -### Network Interception - -Both requests and responses can be recorded or transformed. - -#### Response information - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L90-L101" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L125-L133" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L67-L72" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-implementation >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -#### Response transformation - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/BidiApiTest.java#L111-L121" >}} -{{< /tab >}} -{{< tab header="Python" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L143-L156" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L79-L83" >}} -{{< /tab >}} -{{% tab header="JavaScript" %}} -{{< badge-examples >}} -```js -const connection = await driver.createCDPConnection('page') -let url = fileServer.whereIs("/cheese") -let httpResponse = new HttpResponse(url) -httpResponse.addHeaders("Content-Type", "UTF-8") -httpResponse.body = "sausages" -await driver.onIntercept(connection, httpResponse, async function () { - let body = await driver.getPageSource() - assert.strictEqual(body.includes("sausages"), true, `Body contains: ${body}`) -}) -driver.get(url) -``` -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-examples >}} -```java -val driver = ChromeDriver() -val interceptor = new NetworkInterceptor( - driver, - Route.matching(req -> true) - .to(() -> req -> new HttpResponse() - .setStatus(200) - .addHeader("Content-Type", MediaType.HTML_UTF_8.toString()) - .setContent(utf8String("Creamy, delicious cheese!")))) - - driver.get(appServer.whereIs("/cheese")) - - String source = driver.getPageSource() -``` -{{% /tab %}} -{{< /tabpane >}} - -#### Request interception - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="Python" >}} -{{< badge-implementation >}} -{{< /tab >}} -{{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/BidiApiTest.cs#L167-L181" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/bidi_api_spec.rb#L90-L94" >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.en.md deleted file mode 100644 index 54cb54f6c961..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.en.md +++ /dev/null @@ -1,208 +0,0 @@ ---- -title: "Chrome DevTools Protocol API" -linkTitle: "CDP API" -weight: 4 -description: > - Each of the Selenium bindings dynamically generates classes and methods for the various CDP domains and features; - these are tied to specific versions of Chrome. ---- - -{{% pageinfo color="warning" %}} -While Selenium 4 provides direct access to the Chrome DevTools Protocol (CDP), these -methods will eventually be removed. It is recommended to use the [WebDriver Bidi APIs]({{< ref "bidi_api.md" >}}) -methods where possible to ensure future compatibility. -{{% /pageinfo %}} - -## Usage - -If your use case has been implemented by [WebDriver Bidi]({{< ref "../webdriver_bidi/" >}}) or -the [BiDi API]({{< ref "bidi_api.md" >}}), you should use those implementations instead of this one. -Generally you should prefer this approach over executing with the [CDP Endpoint]({{< ref "cdp_endpoint.md" >}}), -especially in Ruby. - - -## Examples - -### Set Cookie - -An alternate implementation can be found at [CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Because Java requires using all the parameters example, the Map approach used in -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be more simple. -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L47-L65" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L10-L18" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L25-L37" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L9-L12" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Performance Metrics - -An alternate implementation can be found at [CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L77-L81" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L30-L33" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L49-L56" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L23-L25" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Basic authentication - -Alternate implementations can be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -and [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L94-L101" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L43-L49" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L70-L83" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L36-L40" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Console logs - -Because reading console logs requires setting an event listener, -this cannot be done with a CDP Endpoint implementation -Alternate implementations can be found at -[BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) -and [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) implementation -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L114-L121" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Use the [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Use the [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L50-L55" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### JavaScript exceptions - -Similar to console logs, but this listens for actual javascript exceptions not just logged errors -Alternate implementations can be found at -[BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) -and [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) implementation -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L133-L138" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Download complete - -Wait for a download to finish before continuing. -Because getting download status requires setting a listener, this cannot be done with a CDP Endpoint implementation. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L150-L162" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L66-L72" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.ja.md deleted file mode 100644 index 54cb54f6c961..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.ja.md +++ /dev/null @@ -1,208 +0,0 @@ ---- -title: "Chrome DevTools Protocol API" -linkTitle: "CDP API" -weight: 4 -description: > - Each of the Selenium bindings dynamically generates classes and methods for the various CDP domains and features; - these are tied to specific versions of Chrome. ---- - -{{% pageinfo color="warning" %}} -While Selenium 4 provides direct access to the Chrome DevTools Protocol (CDP), these -methods will eventually be removed. It is recommended to use the [WebDriver Bidi APIs]({{< ref "bidi_api.md" >}}) -methods where possible to ensure future compatibility. -{{% /pageinfo %}} - -## Usage - -If your use case has been implemented by [WebDriver Bidi]({{< ref "../webdriver_bidi/" >}}) or -the [BiDi API]({{< ref "bidi_api.md" >}}), you should use those implementations instead of this one. -Generally you should prefer this approach over executing with the [CDP Endpoint]({{< ref "cdp_endpoint.md" >}}), -especially in Ruby. - - -## Examples - -### Set Cookie - -An alternate implementation can be found at [CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Because Java requires using all the parameters example, the Map approach used in -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be more simple. -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L47-L65" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L10-L18" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L25-L37" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L9-L12" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Performance Metrics - -An alternate implementation can be found at [CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L77-L81" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L30-L33" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L49-L56" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L23-L25" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Basic authentication - -Alternate implementations can be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -and [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L94-L101" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L43-L49" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L70-L83" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L36-L40" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Console logs - -Because reading console logs requires setting an event listener, -this cannot be done with a CDP Endpoint implementation -Alternate implementations can be found at -[BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) -and [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) implementation -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L114-L121" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Use the [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Use the [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L50-L55" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### JavaScript exceptions - -Similar to console logs, but this listens for actual javascript exceptions not just logged errors -Alternate implementations can be found at -[BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) -and [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) implementation -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L133-L138" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Download complete - -Wait for a download to finish before continuing. -Because getting download status requires setting a listener, this cannot be done with a CDP Endpoint implementation. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L150-L162" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L66-L72" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.pt-br.md deleted file mode 100644 index 54cb54f6c961..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.pt-br.md +++ /dev/null @@ -1,208 +0,0 @@ ---- -title: "Chrome DevTools Protocol API" -linkTitle: "CDP API" -weight: 4 -description: > - Each of the Selenium bindings dynamically generates classes and methods for the various CDP domains and features; - these are tied to specific versions of Chrome. ---- - -{{% pageinfo color="warning" %}} -While Selenium 4 provides direct access to the Chrome DevTools Protocol (CDP), these -methods will eventually be removed. It is recommended to use the [WebDriver Bidi APIs]({{< ref "bidi_api.md" >}}) -methods where possible to ensure future compatibility. -{{% /pageinfo %}} - -## Usage - -If your use case has been implemented by [WebDriver Bidi]({{< ref "../webdriver_bidi/" >}}) or -the [BiDi API]({{< ref "bidi_api.md" >}}), you should use those implementations instead of this one. -Generally you should prefer this approach over executing with the [CDP Endpoint]({{< ref "cdp_endpoint.md" >}}), -especially in Ruby. - - -## Examples - -### Set Cookie - -An alternate implementation can be found at [CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Because Java requires using all the parameters example, the Map approach used in -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be more simple. -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L47-L65" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L10-L18" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L25-L37" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L9-L12" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Performance Metrics - -An alternate implementation can be found at [CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L77-L81" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L30-L33" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L49-L56" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L23-L25" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Basic authentication - -Alternate implementations can be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -and [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L94-L101" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L43-L49" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L70-L83" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L36-L40" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Console logs - -Because reading console logs requires setting an event listener, -this cannot be done with a CDP Endpoint implementation -Alternate implementations can be found at -[BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) -and [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) implementation -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L114-L121" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Use the [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Use the [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L50-L55" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### JavaScript exceptions - -Similar to console logs, but this listens for actual javascript exceptions not just logged errors -Alternate implementations can be found at -[BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) -and [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) implementation -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L133-L138" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Download complete - -Wait for a download to finish before continuing. -Because getting download status requires setting a listener, this cannot be done with a CDP Endpoint implementation. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L150-L162" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L66-L72" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.zh-cn.md deleted file mode 100644 index 54cb54f6c961..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_api.zh-cn.md +++ /dev/null @@ -1,208 +0,0 @@ ---- -title: "Chrome DevTools Protocol API" -linkTitle: "CDP API" -weight: 4 -description: > - Each of the Selenium bindings dynamically generates classes and methods for the various CDP domains and features; - these are tied to specific versions of Chrome. ---- - -{{% pageinfo color="warning" %}} -While Selenium 4 provides direct access to the Chrome DevTools Protocol (CDP), these -methods will eventually be removed. It is recommended to use the [WebDriver Bidi APIs]({{< ref "bidi_api.md" >}}) -methods where possible to ensure future compatibility. -{{% /pageinfo %}} - -## Usage - -If your use case has been implemented by [WebDriver Bidi]({{< ref "../webdriver_bidi/" >}}) or -the [BiDi API]({{< ref "bidi_api.md" >}}), you should use those implementations instead of this one. -Generally you should prefer this approach over executing with the [CDP Endpoint]({{< ref "cdp_endpoint.md" >}}), -especially in Ruby. - - -## Examples - -### Set Cookie - -An alternate implementation can be found at [CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Because Java requires using all the parameters example, the Map approach used in -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be more simple. -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L47-L65" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L10-L18" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Set Cookie]({{< ref "cdp_endpoint#set-cookie" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L25-L37" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L9-L12" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Performance Metrics - -An alternate implementation can be found at [CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L77-L81" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L30-L33" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Performance Metrics]({{< ref "cdp_endpoint#performance-metrics" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L49-L56" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L23-L25" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Basic authentication - -Alternate implementations can be found at -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) -and [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L94-L101" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Because Python requires using async methods for this example, the synchronous approach found in -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) might be easier. -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_api.py#L43-L49" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Due to the added complexity in .NET of obtaining the domains and executing with awaits, the -[CDP Endpoint Basic Authentication]({{< ref "cdp_endpoint#basic-authentication" >}}) might be easier. -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpApiTest.cs#L70-L83" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L36-L40" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Console logs - -Because reading console logs requires setting an event listener, -this cannot be done with a CDP Endpoint implementation -Alternate implementations can be found at -[BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) -and [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi Console logs]({{< ref "../webdriver_bidi/log#console-logs" >}}) implementation -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L114-L121" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Use the [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Use the [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Console logs and errors]({{< ref "bidi_api#console-logs-and-errors" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L50-L55" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### JavaScript exceptions - -Similar to console logs, but this listens for actual javascript exceptions not just logged errors -Alternate implementations can be found at -[BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) -and [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -Use the [WebDriver BiDi JavaScript exceptions]({{< ref "../webdriver_bidi/log#javascript-exceptions" >}}) implementation -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L133-L138" >}} -{{% /tab %}} -{{% tab header="Python" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -Use the [BiDi API JavaScript exceptions]({{< ref "bidi_api#javascript-exceptions" >}}) implementation -{{< badge-code >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Download complete - -Wait for a download to finish before continuing. -Because getting download status requires setting a listener, this cannot be done with a CDP Endpoint implementation. - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpApiTest.java#L150-L162" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_api_spec.rb#L66-L72" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.en.md deleted file mode 100644 index b388d2ccdbb7..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.en.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -title: "Chrome DevTools Protocol Endpoint" -linkTitle: "CDP Endpoint" -weight: 2 -description: > - Google provides a `/cdp/execute` endpoint that can be accessed directly. Each Selenium binding provides a method that - allows you to pass the CDP domain as a String, and the required parameters as a simple Map. ---- - -{{% pageinfo color="warning" %}} -These methods will eventually be removed. It is recommended to use the [WebDriver-BiDi]({{< ref "../webdriver_bidi/" >}}) or [WebDriver Bidi APIs]({{< ref "bidi_api.md" >}}) -methods where possible to ensure future compatibility. -{{% /pageinfo %}} - - -## Usage - -Generally you should prefer the use of the [CDP API]({{< ref "cdp_api.md" >}}) over this approach, -but sometimes the syntax is cleaner or significantly more simple. - -Limitations include: -* It only works for use cases that are limited to setting or getting information; -any actual asynchronous interactions require another implementation -* You have to know the exactly correct "magic strings" for domains and keys -* It is possible that an update to Chrome will change the required parameters - -## Examples - -### Set Cookie - -An alternate implementation can be found at [CDP API Set Cookie]({{< ref "cdp_api#set-cookie" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L26-32" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L7-L12" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L25-L33" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [CDP API Set Cookie]({{< ref "cdp_api#set-cookie" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L9-L14" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Performance Metrics - -An alternate implementation can be found at [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L43-L46" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L23-L25" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L46-L49" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L25-L27" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Basic authentication - -Alternate implementations can be found at [CDP API Basic Authentication]({{< ref "cdp_api#basic-authentication" >}}) -and [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L60-L66" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L34-L39" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L65-L73" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L38-L43" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.ja.md deleted file mode 100644 index b388d2ccdbb7..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.ja.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -title: "Chrome DevTools Protocol Endpoint" -linkTitle: "CDP Endpoint" -weight: 2 -description: > - Google provides a `/cdp/execute` endpoint that can be accessed directly. Each Selenium binding provides a method that - allows you to pass the CDP domain as a String, and the required parameters as a simple Map. ---- - -{{% pageinfo color="warning" %}} -These methods will eventually be removed. It is recommended to use the [WebDriver-BiDi]({{< ref "../webdriver_bidi/" >}}) or [WebDriver Bidi APIs]({{< ref "bidi_api.md" >}}) -methods where possible to ensure future compatibility. -{{% /pageinfo %}} - - -## Usage - -Generally you should prefer the use of the [CDP API]({{< ref "cdp_api.md" >}}) over this approach, -but sometimes the syntax is cleaner or significantly more simple. - -Limitations include: -* It only works for use cases that are limited to setting or getting information; -any actual asynchronous interactions require another implementation -* You have to know the exactly correct "magic strings" for domains and keys -* It is possible that an update to Chrome will change the required parameters - -## Examples - -### Set Cookie - -An alternate implementation can be found at [CDP API Set Cookie]({{< ref "cdp_api#set-cookie" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L26-32" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L7-L12" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L25-L33" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [CDP API Set Cookie]({{< ref "cdp_api#set-cookie" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L9-L14" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Performance Metrics - -An alternate implementation can be found at [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L43-L46" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L23-L25" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L46-L49" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L25-L27" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Basic authentication - -Alternate implementations can be found at [CDP API Basic Authentication]({{< ref "cdp_api#basic-authentication" >}}) -and [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L60-L66" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L34-L39" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L65-L73" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L38-L43" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.pt-br.md deleted file mode 100644 index b388d2ccdbb7..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.pt-br.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -title: "Chrome DevTools Protocol Endpoint" -linkTitle: "CDP Endpoint" -weight: 2 -description: > - Google provides a `/cdp/execute` endpoint that can be accessed directly. Each Selenium binding provides a method that - allows you to pass the CDP domain as a String, and the required parameters as a simple Map. ---- - -{{% pageinfo color="warning" %}} -These methods will eventually be removed. It is recommended to use the [WebDriver-BiDi]({{< ref "../webdriver_bidi/" >}}) or [WebDriver Bidi APIs]({{< ref "bidi_api.md" >}}) -methods where possible to ensure future compatibility. -{{% /pageinfo %}} - - -## Usage - -Generally you should prefer the use of the [CDP API]({{< ref "cdp_api.md" >}}) over this approach, -but sometimes the syntax is cleaner or significantly more simple. - -Limitations include: -* It only works for use cases that are limited to setting or getting information; -any actual asynchronous interactions require another implementation -* You have to know the exactly correct "magic strings" for domains and keys -* It is possible that an update to Chrome will change the required parameters - -## Examples - -### Set Cookie - -An alternate implementation can be found at [CDP API Set Cookie]({{< ref "cdp_api#set-cookie" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L26-32" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L7-L12" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L25-L33" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [CDP API Set Cookie]({{< ref "cdp_api#set-cookie" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L9-L14" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Performance Metrics - -An alternate implementation can be found at [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L43-L46" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L23-L25" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L46-L49" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L25-L27" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Basic authentication - -Alternate implementations can be found at [CDP API Basic Authentication]({{< ref "cdp_api#basic-authentication" >}}) -and [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L60-L66" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L34-L39" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L65-L73" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L38-L43" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.zh-cn.md deleted file mode 100644 index b388d2ccdbb7..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/chrome_devtools/cdp_endpoint.zh-cn.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -title: "Chrome DevTools Protocol Endpoint" -linkTitle: "CDP Endpoint" -weight: 2 -description: > - Google provides a `/cdp/execute` endpoint that can be accessed directly. Each Selenium binding provides a method that - allows you to pass the CDP domain as a String, and the required parameters as a simple Map. ---- - -{{% pageinfo color="warning" %}} -These methods will eventually be removed. It is recommended to use the [WebDriver-BiDi]({{< ref "../webdriver_bidi/" >}}) or [WebDriver Bidi APIs]({{< ref "bidi_api.md" >}}) -methods where possible to ensure future compatibility. -{{% /pageinfo %}} - - -## Usage - -Generally you should prefer the use of the [CDP API]({{< ref "cdp_api.md" >}}) over this approach, -but sometimes the syntax is cleaner or significantly more simple. - -Limitations include: -* It only works for use cases that are limited to setting or getting information; -any actual asynchronous interactions require another implementation -* You have to know the exactly correct "magic strings" for domains and keys -* It is possible that an update to Chrome will change the required parameters - -## Examples - -### Set Cookie - -An alternate implementation can be found at [CDP API Set Cookie]({{< ref "cdp_api#set-cookie" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L26-32" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L7-L12" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L25-L33" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [CDP API Set Cookie]({{< ref "cdp_api#set-cookie" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L9-L14" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Performance Metrics - -An alternate implementation can be found at [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L43-L46" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L23-L25" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L46-L49" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [CDP API Performance Metrics]({{< ref "cdp_api#performance-metrics" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L25-L27" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} - -### Basic authentication - -Alternate implementations can be found at [CDP API Basic Authentication]({{< ref "cdp_api#basic-authentication" >}}) -and [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) - -{{< tabpane text=true >}} -{{% tab header="Java" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/chrome_devtools/CdpEndpointTest.java#L60-L66" >}} -{{% /tab %}} -{{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidirectional/chrome_devtools/test_cdp_endpoint.py#L34-L39" >}} -{{% /tab %}} -{{% tab header="CSharp" %}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Bidirectional/ChromeDevtools/CdpEndpointTest.cs#L65-L73" >}} -{{% /tab %}} -{{% tab header="Ruby" %}} -The [BiDi API Basic Authentication]({{< ref "bidi_api#basic-authentication" >}}) implementation should be preferred -{{< gh-codeblock path="/examples/ruby/spec/bidirectional/chrome_devtools/cdp_endpoint_spec.rb#L38-L43" >}} -{{% /tab %}} -{{% tab header="JavaScript" %}} -{{< badge-code >}} -{{% /tab %}} -{{% tab header="Kotlin" %}} -{{< badge-code >}} -{{% /tab %}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.en.md deleted file mode 100644 index 09f9e815d024..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.en.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: "BiDirectional API (W3C compliant)" -linkTitle: "WebDriver-BiDi" -weight: 16 -aliases: [ -"/documentation/en/webdriver/bidirectional/bidirectional_w3c", -"/documentation/en/webdriver/bidi_apis/bidi_w3c", -"/documentation/webdriver/bidi_apis/bidi_w3c" -] ---- - -The following list of APIs will be growing as the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) grows -and browser vendors implement the same. -Additionally, Selenium will try to support real-world use cases that internally use a combination of W3C BiDi protocol APIs. - -If there is additional functionality you'd like to see, please raise a -[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). - diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.ja.md deleted file mode 100644 index dde7e33f7a77..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.ja.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "BiDirectional API (W3C compliant)" -linkTitle: "BiDi API (W3C compliant)" -weight: 16 -aliases: [ -"/documentation/ja/webdriver/bidi_apis/bidi_w3c", -"/ja/documentation/webdriver/bidi_apis/bidi_w3c" -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from English to Japanese. - Do you speak Japanese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -The following list of APIs will be growing as the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) grows -and browser vendors implement the same. -Additionally, Selenium will try to support real-world use cases that internally use a combination of W3C BiDi protocol APIs. - -If there is additional functionality you'd like to see, please raise a -[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.pt-br.md deleted file mode 100644 index afedb63de712..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.pt-br.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "BiDirectional API (W3C compliant)" -linkTitle: "BiDi API (W3C compliant)" -weight: 16 -aliases: [ -"/documentation/pt-br/webdriver/bidi_apis/bidi_w3c", -"/pt-br/documentation/webdriver/bidi_apis/bidi_w3c" -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Portuguese. Do you speak Portuguese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -The following list of APIs will be growing as the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) grows -and browser vendors implement the same. -Additionally, Selenium will try to support real-world use cases that internally use a combination of W3C BiDi protocol APIs. - -If there is additional functionality you'd like to see, please raise a -[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.zh-cn.md deleted file mode 100644 index 70e97c54bc5c..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/_index.zh-cn.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: "BiDirectional API (W3C compliant)" -linkTitle: "BiDi API (W3C compliant)" -weight: 16 -aliases: [ -"/documentation/zh-cn/webdriver/bidi_apis/bidi_w3c", -"/zh-cn/documentation/webdriver/bidi_apis/bidi_w3c" -] ---- - -The following list of APIs will be growing as the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) grows -and browser vendors implement the same. -Additionally, Selenium will try to support real-world use cases that internally use a combination of W3C BiDi protocol APIs. - -If there is additional functionality you'd like to see, please raise a -[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.en.md deleted file mode 100644 index 97e0ac72c185..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.en.md +++ /dev/null @@ -1,598 +0,0 @@ ---- -title: "Browsing Context" -linkTitle: "Browsing Context" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/browsing_context", -] ---- - -## Commands -This section contains the APIs related to browsing context commands. - -### Open a new window - -Creates a new browsing context in a new window. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L44-L47" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L35-L37" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Open a new tab - -Creates a new browsing context in a new tab. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L58-L61" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L50-L52" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Use existing window handle - -Creates a browsing context for the existing tab/window to run commands. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L37-L41" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L27-L30" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Open a window with a reference browsing context -A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). -The API allows to pass the reference browsing context, which is used to create a new window. The implementation is operating system specific. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L50-L55" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L42-L45" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Open a tab with a reference browsing context -A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). -The API allows to pass the reference browsing context, which is used to create a new tab. The implementation is operating system specific. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L64-L69" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L57-L60" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate to a URL - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L72-L80" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L69" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate to a URL with readiness state - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L83-L92" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L81-L84" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context tree - -Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L95-L108" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L92-L98" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context tree with depth - -Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context upto the depth value passed. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L111-L123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L105-L111" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get All Top level browsing contexts - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L126-L133" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.20.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L428-L433" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Close a tab/window - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L136-L153" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L117-L120" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Activate a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L157-L161" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L194-L206" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Reload a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L169-L173" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L353-L353" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Handle user prompt - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L220-L228" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L303" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L248-L252" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L364-L364" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Viewport Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L259-L268" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L167-L171" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Element Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L275-L280" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L186" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Set Viewport - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L304-L307" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L337" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Print page - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L317-L322" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L147-L159" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate back - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L330-L336" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L398-L398" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate forward - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L342-L352" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L422-L422" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Traverse history - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L359-L365" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L380-L380" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events -This section contains the APIs related to browsing context events. - -### Browsing Context Created Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L34-L41" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L24-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Dom Content loaded Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L54-L63" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L54-L63" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Browsing Context Loaded Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L81-88" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L71-L79" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigated Started Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L97-104" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Fragment Navigated Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L87-L98" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### User Prompt Opened Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### User Prompt Closed Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L150-163" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Browsing Context Destroyed Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L170-L181" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#106-L114" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.ja.md deleted file mode 100644 index 0062fd79087b..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.ja.md +++ /dev/null @@ -1,604 +0,0 @@ ---- -title: "Browsing Context" -linkTitle: "Browsing Context" -weight: 1 ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Japanese. Do you speak Japanese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -## Commands -This section contains the APIs related to browsing context commands. - -### Open a new window - -Creates a new browsing context in a new window. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L44-L47" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L35-L37" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Open a new tab - -Creates a new browsing context in a new tab. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L58-L61" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L50-L52" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Use existing window handle - -Creates a browsing context for the existing tab/window to run commands. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L37-L41" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L27-L30" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Open a window with a reference browsing context -A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). -The API allows to pass the reference browsing context, which is used to create a new window. The implementation is operating system specific. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L50-L55" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L42-L45" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Open a tab with a reference browsing context -A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). -The API allows to pass the reference browsing context, which is used to create a new tab. The implementation is operating system specific. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L64-L69" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L57-L60" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate to a URL - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L72-L80" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L69" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate to a URL with readiness state - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L83-L92" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L81-L84" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context tree - -Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L95-L108" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L92-L98" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context tree with depth - -Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context upto the depth value passed. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L111-L123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L105-L111" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get All Top level browsing contexts - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L126-L133" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.20.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L428-L433" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Close a tab/window - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L136-L153" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L117-L120" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Activate a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L157-L161" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L194-L206" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Reload a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L169-L173" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L353-L353" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Handle user prompt - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L220-L228" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L303" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L248-L252" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L364-L364" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Viewport Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L259-L268" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L167-L171" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Element Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L275-L280" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L186" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Set Viewport - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L304-L307" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L337" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Print page - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L317-L322" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L147-L159" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate back - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L330-L336" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L398-L398" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate forward - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L342-L352" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L422-L422" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Traverse history - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L359-L365" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L380-L380" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events -This section contains the APIs related to browsing context events. - -### Browsing Context Created Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L34-L41" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L24-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Dom Content loaded Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L54-L63" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L54-L63" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Browsing Context Loaded Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L81-88" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L71-L79" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigated Started Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L97-104" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Fragment Navigated Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L87-L98" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### User Prompt Opened Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### User Prompt Closed Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L150-163" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Browsing Context Destroyed Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L170-L181" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#106-L114" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.pt-br.md deleted file mode 100644 index 188703feb2b8..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.pt-br.md +++ /dev/null @@ -1,604 +0,0 @@ ---- -title: "Browsing Context" -linkTitle: "Browsing Context" -weight: 1 ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Portuguese. Do you speak Portuguese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -## Commands -This section contains the APIs related to browsing context commands. - -### Open a new window - -Creates a new browsing context in a new window. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L44-L47" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L35-L37" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Open a new tab - -Creates a new browsing context in a new tab. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L58-L61" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L50-L52" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Use existing window handle - -Creates a browsing context for the existing tab/window to run commands. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L37-L41" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L27-L30" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Open a window with a reference browsing context -A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). -The API allows to pass the reference browsing context, which is used to create a new window. The implementation is operating system specific. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L50-L55" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L42-L45" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Open a tab with a reference browsing context -A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). -The API allows to pass the reference browsing context, which is used to create a new tab. The implementation is operating system specific. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L64-L69" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L57-L60" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate to a URL - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L72-L80" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L69" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate to a URL with readiness state - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L83-L92" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L81-L84" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context tree - -Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L95-L108" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L92-L98" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context tree with depth - -Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context upto the depth value passed. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L111-L123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L105-L111" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get All Top level browsing contexts - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L126-L133" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.20.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L428-L433" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Close a tab/window - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L136-L153" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L117-L120" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Activate a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L157-L161" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L194-L206" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Reload a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L169-L173" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L353-L353" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Handle user prompt - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L220-L228" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L303" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L248-L252" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L364-L364" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Viewport Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L259-L268" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L167-L171" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Element Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L275-L280" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L186" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Set Viewport - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L304-L307" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L337" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Print page - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L317-L322" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L147-L159" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate back - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L330-L336" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L398-L398" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate forward - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L342-L352" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L422-L422" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Traverse history - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L359-L365" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L380-L380" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events -This section contains the APIs related to browsing context events. - -### Browsing Context Created Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L34-L41" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L24-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Dom Content loaded Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L54-L63" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L54-L63" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Browsing Context Loaded Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L81-88" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L71-L79" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigated Started Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L97-104" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Fragment Navigated Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L87-L98" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### User Prompt Opened Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### User Prompt Closed Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L150-163" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Browsing Context Destroyed Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L170-L181" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#106-L114" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.zh-cn.md deleted file mode 100644 index 865e27a20fab..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/browsing_context.zh-cn.md +++ /dev/null @@ -1,604 +0,0 @@ ---- -title: "Browsing Context" -linkTitle: "Browsing Context" -weight: 1 ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Chinese. Do you speak Chinese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -## Commands -This section contains the APIs related to browsing context commands. - -### Open a new window - -Creates a new browsing context in a new window. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L44-L47" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L35-L37" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Open a new tab - -Creates a new browsing context in a new tab. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L58-L61" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L50-L52" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Use existing window handle - -Creates a browsing context for the existing tab/window to run commands. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L37-L41" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L27-L30" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Open a window with a reference browsing context -A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). -The API allows to pass the reference browsing context, which is used to create a new window. The implementation is operating system specific. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L50-L55" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L42-L45" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Open a tab with a reference browsing context -A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). -The API allows to pass the reference browsing context, which is used to create a new tab. The implementation is operating system specific. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L64-L69" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L57-L60" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate to a URL - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L72-L80" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L69" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate to a URL with readiness state - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L83-L92" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L81-L84" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context tree - -Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L95-L108" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L92-L98" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context tree with depth - -Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context upto the depth value passed. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L111-L123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L105-L111" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get All Top level browsing contexts - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L126-L133" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.20.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L428-L433" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Close a tab/window - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L136-L153" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L117-L120" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Activate a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L157-L161" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L194-L206" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Reload a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L169-L173" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L353-L353" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Handle user prompt - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L220-L228" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L303" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.13.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L248-L252" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L364-L364" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Viewport Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L259-L268" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L167-L171" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Capture Element Screenshot - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L275-L280" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L186" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Set Viewport - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L304-L307" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L337" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - -### Print page - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.14.1" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L317-L322" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L147-L159" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate back - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L330-L336" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L398-L398" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigate forward - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L342-L352" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L422-L422" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Traverse history - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16.0" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L359-L365" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L380-L380" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events -This section contains the APIs related to browsing context events. - -### Browsing Context Created Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L34-L41" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L24-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Dom Content loaded Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L54-L63" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L54-L63" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Browsing Context Loaded Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L81-88" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9.2" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L71-L79" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Navigated Started Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L97-104" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Fragment Navigated Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.15.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L87-L98" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### User Prompt Opened Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### User Prompt Closed Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L150-163" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Browsing Context Destroyed Event - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L170-L181" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18.0" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#106-L114" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.en.md deleted file mode 100644 index 10992dd2d36e..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.en.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: "Input" -linkTitle: "Input" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/input", -] ---- - -This section contains the APIs related to input commands. - -## Perform Actions - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L41-L44" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L29-L31" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Release Actions - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L59-L65" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L57-57" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.ja.md deleted file mode 100644 index 069cedccb487..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.ja.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Browsing Context" -linkTitle: "Browsing Context" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/browsing_context", -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Japanese. Do you speak Japanese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -This section contains the APIs related to input commands. - -## Perform Actions - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L41-L44" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L29-L31" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Release Actions - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L59-L65" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L57-57" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.pt-br.md deleted file mode 100644 index 8618ef22526b..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.pt-br.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Browsing Context" -linkTitle: "Browsing Context" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/browsing_context", -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Portuguese. Do you speak Portuguese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -This section contains the APIs related to input commands. - -## Perform Actions - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L41-L44" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L29-L31" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Release Actions - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L59-L65" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L57-57" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.zh-cn.md deleted file mode 100644 index ce905e55d561..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/input.zh-cn.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Browsing Context" -linkTitle: "Browsing Context" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/browsing_context", -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Chinese. Do you speak Chinese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -This section contains the APIs related to input commands. - -## Perform Actions - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L41-L44" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L29-L31" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Release Actions - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L59-L65" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L57-57" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.en.md deleted file mode 100644 index 8ae3eb9e6d02..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.en.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: "Log" -linkTitle: "Log" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/log", -] ---- - -This section contains the APIs related to logging. - -## Console logs - -Listen to the `console.log` events and register callbacks to process the event. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L31-L38" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L23-37" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## JavaScript exceptions - -Listen to the JS Exceptions -and register callbacks to process the exception details. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L70-L77" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L44-54" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Listen to JS Logs - -Listen to all JS logs at all levels and register callbacks to process the log. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L52-L59" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.ja.md deleted file mode 100644 index 7b94be6de2f8..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.ja.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -title: "BiDirectional API (W3C compliant)" -linkTitle: "BiDi API (W3C compliant)" -weight: 12 ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Japanese. Do you speak Japanese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -This section contains the APIs related to logging. - -## Console logs - -Listen to the `console.log` events and register callbacks to process the event. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L31-L38" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L23-37" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## JavaScript exceptions - -Listen to the JS Exceptions -and register callbacks to process the exception details. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L70-L77" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L44-54" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Listen to JS Logs - -Listen to all JS logs at all levels and register callbacks to process the log. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L52-L59" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.pt-br.md deleted file mode 100644 index be0814eaa07a..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.pt-br.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -title: "BiDirectional API (W3C compliant)" -linkTitle: "BiDi API (W3C compliant)" -weight: 12 ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Portuguese. Do you speak Portuguese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -This section contains the APIs related to logging. - -## Console logs - -Listen to the `console.log` events and register callbacks to process the event. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L31-L38" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L23-37" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## JavaScript exceptions - -Listen to the JS Exceptions -and register callbacks to process the exception details. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L70-L77" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L44-54" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Listen to JS Logs - -Listen to all JS logs at all levels and register callbacks to process the log. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L52-L59" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.zh-cn.md deleted file mode 100644 index 240ac370a900..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/log.zh-cn.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: "BiDirectional API (W3C compliant)" -linkTitle: "BiDi API (W3C compliant)" -weight: 12 - ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Chinese. Do you speak Chinese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -This section contains the APIs related to logging. - -## Console logs - -Listen to the `console.log` events and register callbacks to process the event. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L31-L38" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L23-37" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## JavaScript exceptions - -Listen to the JS Exceptions -and register callbacks to process the exception details. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L70-L77" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.8" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L44-54" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Listen to JS Logs - -Listen to all JS logs at all levels and register callbacks to process the log. - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L52-L59" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.en.md deleted file mode 100644 index ec619ad8b956..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.en.md +++ /dev/null @@ -1,205 +0,0 @@ ---- -title: "Network" -linkTitle: "Network" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/network", -] ---- -## Commands - -This section contains the APIs related to network commands. - -### Add network intercept - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L36-L38" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L29-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Remove network intercept - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L46-L50" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L34-L35" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Continue request blocked at authRequired phase with credentials - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L57-L64" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L42-L46" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Continue request blocked at authRequired phase without credentials - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L74-L80" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L56-L60" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Cancel request blocked at authRequired phase - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L90-L96" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L71-L75" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Fail request - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L104-L108" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events - -This section contains the APIs related to network events. - -### Before Request Sent - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L30-L35" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L23-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Response Started - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L45-L51" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L83-L89" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Response Completed - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L62-L68" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L97-L103" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Auth Required - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L101-L106" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.ja.md deleted file mode 100644 index ba14e8ac4b6f..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.ja.md +++ /dev/null @@ -1,213 +0,0 @@ ---- -title: "Network" -linkTitle: "Network" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/network", -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Japanese. Do you speak Japanese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -# Commands - -This section contains the APIs related to network commands. - -### Add network intercept - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L36-L38" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L29-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Remove network intercept - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L46-L50" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L34-L35" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Continue request blocked at authRequired phase with credentials - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L57-L64" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L42-L46" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Continue request blocked at authRequired phase without credentials - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L74-L80" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L56-L60" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Cancel request blocked at authRequired phase - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L90-L96" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L71-L75" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Fail request - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L104-L108" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events - -This section contains the APIs related to network events. - -### Before Request Sent - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L30-L35" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L23-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Response Started - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L45-L51" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L83-L89" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Response Completed - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L62-L68" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L97-L103" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Auth Required - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L101-L106" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.pt-br.md deleted file mode 100644 index 91a6e8d346ff..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.pt-br.md +++ /dev/null @@ -1,214 +0,0 @@ ---- -title: "Network" -linkTitle: "Network" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/network", -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Portuguese. Do you speak Portuguese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -# Commands - -This section contains the APIs related to network commands. - -### Add network intercept - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L36-L38" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L29-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Remove network intercept - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L46-L50" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L34-L35" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Continue request blocked at authRequired phase with credentials - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L57-L64" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L42-L46" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Continue request blocked at authRequired phase without credentials - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L74-L80" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L56-L60" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Cancel request blocked at authRequired phase - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L90-L96" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L71-L75" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Fail request - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L104-L108" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events - -This section contains the APIs related to network events. - -### Before Request Sent - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L30-L35" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L23-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Response Started - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L45-L51" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L83-L89" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Response Completed - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L62-L68" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L97-L103" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Auth Required - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L101-L106" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.zh-cn.md deleted file mode 100644 index 1bdf2cdf7135..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/network.zh-cn.md +++ /dev/null @@ -1,213 +0,0 @@ ---- -title: "Network" -linkTitle: "Network" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/network", -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Chinese. Do you speak Chinese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - -## Commands - -This section contains the APIs related to network commands. - -### Add network intercept - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L36-L38" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L29-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Remove network intercept - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L46-L50" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L34-L35" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Continue request blocked at authRequired phase with credentials - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L57-L64" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L42-L46" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Continue request blocked at authRequired phase without credentials - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L74-L80" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L56-L60" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Cancel request blocked at authRequired phase - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L90-L96" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L71-L75" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Fail request - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L104-L108" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events - -This section contains the APIs related to network events. - -### Before Request Sent - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L30-L35" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L23-L29" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Response Started - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L45-L51" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L83-L89" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Response Completed - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L62-L68" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L97-L103" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Auth Required - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.17" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L101-L106" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.en.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.en.md deleted file mode 100644 index f49919513e7f..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.en.md +++ /dev/null @@ -1,339 +0,0 @@ ---- -title: "Script" -linkTitle: "Script" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/script", -] ---- - -## Commands -This section contains the APIs related to script commands. - -### Call function in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L52-L75" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L32-L53" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Call function in a sandbox - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L201-L210" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L202-L204" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Call function in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L219-L229" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L222-L227" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L239-L242" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L237-L239" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a sandbox - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L280-L283" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L279-L283" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L293-L299" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L292-L299" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Disown handles in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L322-L322" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L330-L330" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Disown handles in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L375-L375" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L372-L372" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get all realms - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L391-L392" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L383-L385" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get realm by type - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L401-402" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L393-L395" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context realms - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L411-412" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L403-L405" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context realms by type - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L422-423" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L416-L416" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Preload a script - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L463-463" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L424-L426" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Remove a preloaded script - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L486-486" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L471-L471" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events -This section contains the APIs related to script events. - -### Message - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L37-L51" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L26-L43" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Realm Created - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L58-L68" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L52-L65" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Realm Destroyed - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L75-L85" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.19" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L73-L86" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - - diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.ja.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.ja.md deleted file mode 100644 index 6e599f05818c..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.ja.md +++ /dev/null @@ -1,347 +0,0 @@ ---- -title: "Script" -linkTitle: "Script" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/script", -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Japanese. Do you speak Japanese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - - -## Commands -This section contains the APIs related to script commands. - -### Call function in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L52-L75" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L32-L53" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Call function in a sandbox - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L201-L210" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L202-L204" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Call function in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L219-L229" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L222-L227" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L239-L242" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L237-L239" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a sandbox - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L280-L283" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L279-L283" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L293-L299" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L292-L299" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Disown handles in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L322-L322" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L330-L330" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Disown handles in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L375-L375" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L372-L372" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get all realms - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L391-L392" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L383-L385" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get realm by type - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L401-402" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L393-L395" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context realms - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L411-412" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L403-L405" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context realms by type - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L422-423" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L416-L416" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Preload a script - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L463-463" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L424-L426" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Remove a preloaded script - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L486-486" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L471-L471" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events -This section contains the APIs related to script events. - -### Message - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L37-L51" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L26-L43" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Realm Created - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L58-L68" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L52-L65" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Realm Destroyed - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L75-L85" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.19" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L73-L86" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.pt-br.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.pt-br.md deleted file mode 100644 index 8d2aa29c98d5..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.pt-br.md +++ /dev/null @@ -1,347 +0,0 @@ ---- -title: "Script" -linkTitle: "Script" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/script", -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Portuguese. Do you speak Portuguese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - - -## Commands -This section contains the APIs related to script commands. - -### Call function in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L52-L75" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L32-L53" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Call function in a sandbox - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L201-L210" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L202-L204" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Call function in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L219-L229" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L222-L227" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L239-L242" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L237-L239" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a sandbox - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L280-L283" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L279-L283" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L293-L299" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L292-L299" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Disown handles in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L322-L322" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L330-L330" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Disown handles in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L375-L375" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L372-L372" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get all realms - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L391-L392" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L383-L385" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get realm by type - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L401-402" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L393-L395" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context realms - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L411-412" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L403-L405" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context realms by type - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L422-423" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L416-L416" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Preload a script - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L463-463" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L424-L426" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Remove a preloaded script - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L486-486" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L471-L471" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events -This section contains the APIs related to script events. - -### Message - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L37-L51" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L26-L43" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Realm Created - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L58-L68" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L52-L65" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Realm Destroyed - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L75-L85" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.19" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L73-L86" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.zh-cn.md deleted file mode 100644 index 82dfefda80d8..000000000000 --- a/website_and_docs/content/documentation/webdriver/bidirectional/webdriver_bidi/script.zh-cn.md +++ /dev/null @@ -1,347 +0,0 @@ ---- -title: "Script" -linkTitle: "Script" -weight: 1 -aliases: [ - "/documentation/en/webdriver/bidirectional/bidirectional_w3c/script", -] ---- - -{{% pageinfo color="warning" %}} -

    - - Page being translated from - English to Chinese. Do you speak Chinese? Help us to translate - it by sending us pull requests! -

    -{{% /pageinfo %}} - - -## Commands -This section contains the APIs related to script commands. - -### Call function in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L52-L75" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L32-L53" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Call function in a sandbox - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L201-L210" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L202-L204" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Call function in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L219-L229" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L222-L227" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L239-L242" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L237-L239" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a sandbox - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L280-L283" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L279-L283" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Evaluate script in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L293-L299" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L292-L299" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Disown handles in a browsing context - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L322-L322" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L330-L330" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Disown handles in a realm - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L375-L375" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L372-L372" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get all realms - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L391-L392" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L383-L385" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get realm by type - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L401-402" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L393-L395" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context realms - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L411-412" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L403-L405" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Get browsing context realms by type - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L422-423" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.9" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L416-L416" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Preload a script - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L463-463" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L424-L426" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Remove a preloaded script - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.15" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L486-486" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.10" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L471-L471" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -## Events -This section contains the APIs related to script events. - -### Message - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L37-L51" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L26-L43" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Realm Created - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L58-L68" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.18" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L52-L65" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} - -### Realm Destroyed - -{{< tabpane text=true >}} -{{< tab header="Java" >}} -{{< badge-version version="4.16" >}} -{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L75-L85" >}} -{{< /tab >}} -{{< tab header="Ruby" >}} -{{< badge-code >}} -{{< /tab >}} -{{< tab header="JavaScript" >}} -{{< badge-version version="4.19" >}} -{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L73-L86" >}} -{{< /tab >}} -{{< tab header="Kotlin" >}} -{{< badge-code >}} -{{< /tab >}} -{{< /tabpane >}} From fbaabc6189b2994ffe8332f953f25844fdae5d6d Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 24 Jun 2024 19:45:07 -0500 Subject: [PATCH 09/11] update links to bidi documentation --- .../content/blog/2021/announcing-selenium-4.md | 6 +++--- .../content/blog/2024/selenium-4-22-released.md | 8 ++++---- .../content/documentation/webdriver/browsers/chrome.en.md | 2 +- .../content/documentation/webdriver/browsers/chrome.ja.md | 2 +- .../documentation/webdriver/browsers/chrome.pt-br.md | 2 +- .../documentation/webdriver/browsers/chrome.zh-cn.md | 2 +- .../content/documentation/webdriver/browsers/edge.en.md | 2 +- .../content/documentation/webdriver/browsers/edge.ja.md | 2 +- .../documentation/webdriver/browsers/edge.pt-br.md | 2 +- .../documentation/webdriver/browsers/edge.zh-cn.md | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/website_and_docs/content/blog/2021/announcing-selenium-4.md b/website_and_docs/content/blog/2021/announcing-selenium-4.md index 5648e02ba91e..9747b6f3f9ef 100644 --- a/website_and_docs/content/blog/2021/announcing-selenium-4.md +++ b/website_and_docs/content/blog/2021/announcing-selenium-4.md @@ -98,7 +98,7 @@ our users. **We hope you enjoy Selenium 4, and we can’t wait to see what you do with it!** -[auth]: /documentation/webdriver/bidirectional/chrome_devtools/bidi_api/#basic-authentication +[auth]: /documentation/webdriver/bidi/cdp/network/#basic-authentication [browserstack]: https://www.browserstack.com/ [chromium]: https://www.chromium.org/Home [docker]: https://hub.docker.com/u/selenium @@ -106,8 +106,8 @@ with it!** [firefox]: https://www.mozilla.org/en-GB/firefox/new/ [github]: https://github.com/SeleniumHQ/selenium/releases/tag/selenium-4.0.0 [grid]: /documentation/grid/ -[js errors]: /documentation/webdriver/bidirectional/chrome_devtools/bidi_api/#javascript-exceptions -[mutation]: /documentation/webdriver/bidirectional/chrome_devtools/bidi_api/#mutation-observation +[js errors]: /documentation/webdriver/bidi/cdp/bidi_api/#javascript-exceptions +[mutation]: /documentation/webdriver/bidi/cdp/bidi_api/#mutation-observation [otel]: https://opentelemetry.io [pr]: https://github.com/SeleniumHQ/selenium/pulls [relative locators]: /documentation/webdriver/locating_elements/#relative-locators diff --git a/website_and_docs/content/blog/2024/selenium-4-22-released.md b/website_and_docs/content/blog/2024/selenium-4-22-released.md index 10887bf3f48c..a4d7f5612e2b 100644 --- a/website_and_docs/content/blog/2024/selenium-4-22-released.md +++ b/website_and_docs/content/blog/2024/selenium-4-22-released.md @@ -20,7 +20,8 @@ Links to everything can be found on our [downloads page][downloads]. * The numbers only represent users who have Selenium Manager enabled and are using Selenium v4.17 or greater. * Python, Chrome and Windows all see the majority of use. * Chrome DevTools support is now: v124, v125, and v126 (Firefox still uses v85 for all versions) -* The first implementations of the final BiDi API have rolled out. +* The first implementations of the new [BiDi API](https://www.selenium.dev/documentation/webdriver/bidi/logging) +have rolled out in Ruby, Python and JavaScript #### Noteworthy changes per language @@ -101,12 +102,11 @@ Links to everything can be found on our [downloads page][downloads].
    {{< gh-user "https://api.github.com/users/alaahong" >}} {{< gh-user "https://api.github.com/users/aguspe" >}} -{{< gh-user "https://api.github.com/users/digitalvoice-nz -{{< gh-user "https://api.github.com/users/josh-pinwheelapi +{{< gh-user "https://api.github.com/users/digitalvoice-nz" >}} +{{< gh-user "https://api.github.com/users/josh-pinwheelapi" >}} {{< gh-user "https://api.github.com/users/pallavigitwork" >}} {{< gh-user "https://api.github.com/users/Pexpe" >}} {{< gh-user "https://api.github.com/users/sangcnguyen" >}} -" >}}
    diff --git a/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md b/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md index faced2ff9b09..1bae347db3d0 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md +++ b/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md @@ -463,4 +463,4 @@ You can simulate various network conditions. ### DevTools -See the [Chrome DevTools]({{< ref "../bidirectional/chrome_devtools/cdp_api.md" >}}) section for more information about using Chrome DevTools +See the [Chrome DevTools]({{< ref "../bidi/cdp/" >}}) section for more information about using Chrome DevTools diff --git a/website_and_docs/content/documentation/webdriver/browsers/chrome.ja.md b/website_and_docs/content/documentation/webdriver/browsers/chrome.ja.md index c5499b8f7f2b..ae73388a0d65 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/chrome.ja.md +++ b/website_and_docs/content/documentation/webdriver/browsers/chrome.ja.md @@ -469,4 +469,4 @@ please refer to the ### デベロッパー ツール -Chromeデベロッパーツールの使用に関する詳細については、[Chromeデベロッパー ツール]({{< ref "../bidirectional/chrome_devtools/cdp_api.md" >}})セクションを参照してください。 +Chromeデベロッパーツールの使用に関する詳細については、[Chromeデベロッパー ツール] セクションを参照してください。 diff --git a/website_and_docs/content/documentation/webdriver/browsers/chrome.pt-br.md b/website_and_docs/content/documentation/webdriver/browsers/chrome.pt-br.md index fc9f45ada9bb..29e7473eefae 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/chrome.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/browsers/chrome.pt-br.md @@ -466,4 +466,4 @@ please refer to the ### DevTools -Veja a secção [Chrome DevTools]({{< ref "../bidirectional/chrome_devtools/cdp_api.md" >}}) para mais informação em como usar Chrome DevTools +Veja a secção [Chrome DevTools] para mais informação em como usar Chrome DevTools diff --git a/website_and_docs/content/documentation/webdriver/browsers/chrome.zh-cn.md b/website_and_docs/content/documentation/webdriver/browsers/chrome.zh-cn.md index 4c64498c63bf..f5f70d6dc8a2 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/chrome.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/browsers/chrome.zh-cn.md @@ -465,4 +465,4 @@ please refer to the ### DevTools -See the [Chrome DevTools]({{< ref "../bidirectional/chrome_devtools/cdp_api.md" >}}) section for more information about using Chrome DevTools +See the [Chrome DevTools] section for more information about using Chrome DevTools diff --git a/website_and_docs/content/documentation/webdriver/browsers/edge.en.md b/website_and_docs/content/documentation/webdriver/browsers/edge.en.md index 3ee56293f887..5964af0fefb5 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/edge.en.md +++ b/website_and_docs/content/documentation/webdriver/browsers/edge.en.md @@ -463,4 +463,4 @@ You can simulate various network conditions. ### DevTools -See the [Chrome DevTools]({{< ref "../bidirectional/chrome_devtools/cdp_api.md" >}}) section for more information about using DevTools in Edge +See the [Chrome DevTools]({{< ref "../bidi/cdp/" >}}) section for more information about using DevTools in Edge diff --git a/website_and_docs/content/documentation/webdriver/browsers/edge.ja.md b/website_and_docs/content/documentation/webdriver/browsers/edge.ja.md index 207c0710c0a5..6a3afad92c2d 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/edge.ja.md +++ b/website_and_docs/content/documentation/webdriver/browsers/edge.ja.md @@ -465,4 +465,4 @@ You can simulate various network conditions. ### DevTools -See the [Chrome DevTools]({{< ref "../bidirectional/chrome_devtools/cdp_api.md" >}}) section for more information about using DevTools in Edge +See the [Chrome DevTools] section for more information about using DevTools in Edge diff --git a/website_and_docs/content/documentation/webdriver/browsers/edge.pt-br.md b/website_and_docs/content/documentation/webdriver/browsers/edge.pt-br.md index a7f2b1c0a64f..c28ba3067a6c 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/edge.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/browsers/edge.pt-br.md @@ -465,4 +465,4 @@ You can simulate various network conditions. ### DevTools -See the [Chrome DevTools]({{< ref "../bidirectional/chrome_devtools/cdp_api.md" >}}) section for more information about using DevTools in Edge +See the [Chrome DevTools] section for more information about using DevTools in Edge diff --git a/website_and_docs/content/documentation/webdriver/browsers/edge.zh-cn.md b/website_and_docs/content/documentation/webdriver/browsers/edge.zh-cn.md index 618ca4257f9e..b8966197efdc 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/edge.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/browsers/edge.zh-cn.md @@ -465,4 +465,4 @@ You can simulate various network conditions. ### DevTools -See the [Chrome DevTools]({{< ref "../bidirectional/chrome_devtools/cdp_api.md" >}}) section for more information about using DevTools in Edge +See the [Chrome DevTools] section for more information about using DevTools in Edge From b7690198601c83a9277f66652e34b5cfee06d8b7 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 24 Jun 2024 19:51:24 -0500 Subject: [PATCH 10/11] wrong github reference --- .../content/documentation/webdriver/bidi/cdp/network.en.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/bidi/cdp/network.en.md b/website_and_docs/content/documentation/webdriver/bidi/cdp/network.en.md index d69061acc79e..777c3c978709 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/cdp/network.en.md +++ b/website_and_docs/content/documentation/webdriver/bidi/cdp/network.en.md @@ -122,7 +122,7 @@ Both requests and responses can be recorded or transformed. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L125-L126" >}} {{% /tab %}} {{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_logging.py#L26-L28" >}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_network.py#L26-L28" >}} {{% /tab %}} {{% tab header="CSharp" %}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L114-L118" >}} @@ -146,7 +146,7 @@ Both requests and responses can be recorded or transformed. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidi/cdp/NetworkTest.java#L142-L157" >}} {{% /tab %}} {{% tab header="Python" %}} -{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_logging.py#L37-L44" >}} +{{< gh-codeblock path="/examples/python/tests/bidi/cdp/test_network.py#L37-L44" >}} {{% /tab %}} {{% tab header="CSharp" %}} {{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs#L136-L143" >}} From 738629d73b6cc2c918c00faf664e0fa1a26ad4cb Mon Sep 17 00:00:00 2001 From: titusfortner Date: Tue, 25 Jun 2024 07:58:41 -0500 Subject: [PATCH 11/11] restore java and javascript low level bidi examples --- .../webdriver_bidi/ActionsTest.java | 73 +++ .../BrowsingContextInspectorTest.java | 185 ++++++ .../webdriver_bidi/BrowsingContextTest.java | 368 +++++++++++ .../webdriver_bidi/LocateNodesTest.java | 221 +++++++ .../bidirectional/webdriver_bidi/LogTest.java | 142 ++++ .../webdriver_bidi/NetworkCommandsTest.java | 112 ++++ .../webdriver_bidi/NetworkEventsTest.java | 113 ++++ .../webdriver_bidi/ScriptEventsTest.java | 87 +++ .../webdriver_bidi/ScriptTest.java | 494 ++++++++++++++ .../test/bidirectional/bidi.spec.js | 52 ++ .../bidirectional/browsingContext.spec.js | 437 +++++++++++++ .../browsingContextInspector.spec.js | 122 ++++ .../bidirectional/emulateGeoLocation.spec.js | 33 + .../test/bidirectional/input.spec.js | 65 ++ .../test/bidirectional/locateNodes.spec.js | 245 +++++++ .../bidirectional/network_commands.spec.js | 82 +++ .../test/bidirectional/network_events.spec.js | 111 ++++ .../bidirectional/script_commands.spec.js | 478 ++++++++++++++ .../test/bidirectional/script_events.spec.js | 93 +++ .../webdriver/bidi/w3c/_index.en.md | 21 + .../webdriver/bidi/w3c/_index.ja.md | 25 + .../webdriver/bidi/w3c/_index.pt-br.md | 25 + .../webdriver/bidi/w3c/_index.zh-cn.md | 16 + .../webdriver/bidi/w3c/browsing_context.en.md | 598 +++++++++++++++++ .../webdriver/bidi/w3c/browsing_context.ja.md | 604 ++++++++++++++++++ .../bidi/w3c/browsing_context.pt-br.md | 604 ++++++++++++++++++ .../bidi/w3c/browsing_context.zh-cn.md | 604 ++++++++++++++++++ .../webdriver/bidi/w3c/input.en.md | 48 ++ .../webdriver/bidi/w3c/input.ja.md | 57 ++ .../webdriver/bidi/w3c/input.pt-br.md | 57 ++ .../webdriver/bidi/w3c/input.zh-cn.md | 57 ++ .../webdriver/bidi/w3c/log.en.md | 70 ++ .../webdriver/bidi/w3c/log.ja.md | 76 +++ .../webdriver/bidi/w3c/log.pt-br.md | 76 +++ .../webdriver/bidi/w3c/log.zh-cn.md | 77 +++ .../webdriver/bidi/w3c/network.en.md | 205 ++++++ .../webdriver/bidi/w3c/network.ja.md | 213 ++++++ .../webdriver/bidi/w3c/network.pt-br.md | 214 +++++++ .../webdriver/bidi/w3c/network.zh-cn.md | 213 ++++++ .../webdriver/bidi/w3c/script.en.md | 339 ++++++++++ .../webdriver/bidi/w3c/script.ja.md | 347 ++++++++++ .../webdriver/bidi/w3c/script.pt-br.md | 347 ++++++++++ .../webdriver/bidi/w3c/script.zh-cn.md | 347 ++++++++++ 43 files changed, 8753 insertions(+) create mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java create mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java create mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java create mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LocateNodesTest.java create mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java create mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java create mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java create mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java create mode 100644 examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java create mode 100644 examples/javascript/test/bidirectional/bidi.spec.js create mode 100644 examples/javascript/test/bidirectional/browsingContext.spec.js create mode 100644 examples/javascript/test/bidirectional/browsingContextInspector.spec.js create mode 100644 examples/javascript/test/bidirectional/emulateGeoLocation.spec.js create mode 100644 examples/javascript/test/bidirectional/input.spec.js create mode 100644 examples/javascript/test/bidirectional/locateNodes.spec.js create mode 100644 examples/javascript/test/bidirectional/network_commands.spec.js create mode 100644 examples/javascript/test/bidirectional/network_events.spec.js create mode 100644 examples/javascript/test/bidirectional/script_commands.spec.js create mode 100644 examples/javascript/test/bidirectional/script_events.spec.js create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/_index.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/_index.ja.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/_index.pt-br.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/_index.zh-cn.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/input.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/input.ja.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/input.pt-br.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/input.zh-cn.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/log.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/log.ja.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/log.pt-br.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/log.zh-cn.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/network.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/network.ja.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/network.pt-br.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/network.zh-cn.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/script.en.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/script.ja.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/script.pt-br.md create mode 100644 website_and_docs/content/documentation/webdriver/bidi/w3c/script.zh-cn.md diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java new file mode 100644 index 000000000000..ffc692a8fc9a --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java @@ -0,0 +1,73 @@ +package dev.selenium.bidirectional.webdriver_bidi; + +import dev.selenium.BaseTest; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.bidi.module.Input; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; +import org.openqa.selenium.interactions.Actions; + +class ActionsTest extends BaseTest { + private Input input; + + private String windowHandle; + + @BeforeEach + public void setup() { + FirefoxOptions options = new FirefoxOptions(); + options.setCapability("webSocketUrl", true); + driver = new FirefoxDriver(options); + windowHandle = driver.getWindowHandle(); + input = new Input(driver); + } + + @Test + void canPerformInputActions() { + driver.get("https://www.selenium.dev/selenium/web/formSelectionPage.html"); + + List options = driver.findElements(By.tagName("option")); + + Actions actions = new Actions(driver); + Actions selectThreeOptions = + actions.click(options.get(1)).keyDown(Keys.SHIFT).click(options.get(3)).keyUp(Keys.SHIFT); + + input.perform(windowHandle, selectThreeOptions.getSequences()); + + WebElement showButton = driver.findElement(By.name("showselected")); + showButton.click(); + + WebElement resultElement = driver.findElement(By.id("result")); + Assertions.assertTrue(resultElement.getText().contains("roquefort parmigiano cheddar")); + } + + @Test + void canPerformReleaseAction() { + driver.get("https://www.selenium.dev/selenium/web/bidi/release_action.html"); + + WebElement inputTextBox = driver.findElement(By.id("keys")); + + Actions sendLowercase = + new Actions(driver).keyDown(inputTextBox, "a").keyDown(inputTextBox, "b"); + + input.perform(windowHandle, sendLowercase.getSequences()); + ((JavascriptExecutor) driver).executeScript("resetEvents()"); + + input.release(windowHandle); + + List> events = + (List>) + ((JavascriptExecutor) driver).executeScript("return allEvents.events"); + Assertions.assertEquals("KeyB", events.get(0).get("code")); + Assertions.assertEquals("KeyA", events.get(1).get("code")); + } + } diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java new file mode 100644 index 000000000000..bd12d14e2b26 --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java @@ -0,0 +1,185 @@ +package dev.selenium.bidirectional.webdriver_bidi; + +import dev.selenium.BaseTest; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WindowType; +import org.openqa.selenium.bidi.module.BrowsingContextInspector; +import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; +import org.openqa.selenium.bidi.browsingcontext.BrowsingContextInfo; +import org.openqa.selenium.bidi.browsingcontext.NavigationInfo; +import org.openqa.selenium.bidi.browsingcontext.ReadinessState; +import org.openqa.selenium.bidi.browsingcontext.UserPromptClosed; +import org.openqa.selenium.bidi.browsingcontext.UserPromptOpened; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; + +class BrowsingContextInspectorTest extends BaseTest { + @BeforeEach + public void setup() { + FirefoxOptions options = new FirefoxOptions(); + options.setCapability("webSocketUrl", true); + driver = new FirefoxDriver(options); + } + + @Test + void canListenToWindowBrowsingContextCreatedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + + inspector.onBrowsingContextCreated(future::complete); + + String windowHandle = driver.switchTo().newWindow(WindowType.WINDOW).getWindowHandle(); + + BrowsingContextInfo browsingContextInfo = future.get(5, TimeUnit.SECONDS); + + Assertions.assertEquals(windowHandle, browsingContextInfo.getId()); + } + } + + @Test + void canListenToTabBrowsingContextCreatedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + inspector.onBrowsingContextCreated(future::complete); + + String windowHandle = driver.switchTo().newWindow(WindowType.TAB).getWindowHandle(); + + BrowsingContextInfo browsingContextInfo = future.get(5, TimeUnit.SECONDS); + + Assertions.assertEquals(windowHandle, browsingContextInfo.getId()); + } + } + + @Test + void canListenToDomContentLoadedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + inspector.onDomContentLoaded(future::complete); + + BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); + context.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", ReadinessState.COMPLETE); + + NavigationInfo navigationInfo = future.get(5, TimeUnit.SECONDS); + + Assertions.assertTrue(navigationInfo.getUrl().contains("bidi/logEntryAdded")); + } + } + + @Test + void canListenToBrowsingContextLoadedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + inspector.onBrowsingContextLoaded(future::complete); + + BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); + context.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", ReadinessState.COMPLETE); + + NavigationInfo navigationInfo = future.get(5, TimeUnit.SECONDS); + + Assertions.assertTrue(navigationInfo.getUrl().contains("bidi/logEntryAdded")); + } + } + + @Test + void canListenToNavigationStartedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + inspector.onNavigationStarted(future::complete); + + BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); + context.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", ReadinessState.COMPLETE); + + NavigationInfo navigationInfo = future.get(5, TimeUnit.SECONDS); + + Assertions.assertTrue(navigationInfo.getUrl().contains("bidi/logEntryAdded")); + } + } + + @Test + void canListenToFragmentNavigatedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + + BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); + context.navigate("https://www.selenium.dev/selenium/web/linked_image.html", ReadinessState.COMPLETE); + + inspector.onFragmentNavigated(future::complete); + + context.navigate("https://www.selenium.dev/selenium/web/linked_image.html#linkToAnchorOnThisPage", ReadinessState.COMPLETE); + + NavigationInfo navigationInfo = future.get(5, TimeUnit.SECONDS); + + Assertions.assertTrue(navigationInfo.getUrl().contains("linkToAnchorOnThisPage")); + } + } + + @Test + void canListenToUserPromptOpenedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + + BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); + inspector.onUserPromptOpened(future::complete); + + driver.get("https://www.selenium.dev/selenium/web/alerts.html"); + + driver.findElement(By.id("alert")).click(); + + UserPromptOpened userPromptOpened = future.get(5, TimeUnit.SECONDS); + Assertions.assertEquals(context.getId(), userPromptOpened.getBrowsingContextId()); + } + } + + @Test + void canListenToUserPromptClosedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + + BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); + inspector.onUserPromptClosed(future::complete); + + driver.get("https://www.selenium.dev/selenium/web/alerts.html"); + + driver.findElement(By.id("prompt")).click(); + + context.handleUserPrompt(true, "selenium"); + + UserPromptClosed userPromptClosed = future.get(5, TimeUnit.SECONDS); + Assertions.assertEquals(context.getId(), userPromptClosed.getBrowsingContextId()); + } + } + + @Test + void canListenToBrowsingContextDestroyedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (BrowsingContextInspector inspector = new BrowsingContextInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + + inspector.onBrowsingContextDestroyed(future::complete); + + String windowHandle = driver.switchTo().newWindow(WindowType.WINDOW).getWindowHandle(); + + driver.close(); + + BrowsingContextInfo browsingContextInfo = future.get(5, TimeUnit.SECONDS); + + Assertions.assertEquals(windowHandle, browsingContextInfo.getId()); + Assertions.assertTrue(browsingContextInfo.getUrl().contains("about:blank")); + } + } +} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java new file mode 100644 index 000000000000..55e82ed2c20e --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java @@ -0,0 +1,368 @@ +package dev.selenium.bidirectional.webdriver_bidi; + +import dev.selenium.BaseTest; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.Rectangle; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.WindowType; +import org.openqa.selenium.bidi.BiDiException; +import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; +import org.openqa.selenium.bidi.browsingcontext.BrowsingContextInfo; +import org.openqa.selenium.bidi.browsingcontext.NavigationResult; +import org.openqa.selenium.bidi.browsingcontext.ReadinessState; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; +import org.openqa.selenium.print.PrintOptions; +import org.openqa.selenium.remote.RemoteWebElement; + +import static org.openqa.selenium.support.ui.ExpectedConditions.titleIs; +import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated; + +class BrowsingContextTest extends BaseTest { + + @BeforeEach + public void setup() { + FirefoxOptions options = new FirefoxOptions(); + options.setCapability("webSocketUrl", true); + driver = new FirefoxDriver(options); + } + + @Test + void testCreateABrowsingContextForGivenId() { + String id = driver.getWindowHandle(); + BrowsingContext browsingContext = new BrowsingContext(driver, id); + Assertions.assertEquals(id, browsingContext.getId()); + } + + @Test + void testCreateAWindow() { + BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.WINDOW); + Assertions.assertNotNull(browsingContext.getId()); + } + + @Test + void testCreateAWindowWithAReferenceContext() { + BrowsingContext + browsingContext = + new BrowsingContext(driver, WindowType.WINDOW, driver.getWindowHandle()); + Assertions.assertNotNull(browsingContext.getId()); + } + + @Test + void testCreateATab() { + BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB); + Assertions.assertNotNull(browsingContext.getId()); + } + + @Test + void testCreateATabWithAReferenceContext() { + BrowsingContext + browsingContext = + new BrowsingContext(driver, WindowType.TAB, driver.getWindowHandle()); + Assertions.assertNotNull(browsingContext.getId()); + } + + @Test + void testNavigateToAUrl() { + BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB); + + NavigationResult info = browsingContext.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + + Assertions.assertNotNull(browsingContext.getId()); + Assertions.assertNotNull(info.getNavigationId()); + Assertions.assertTrue(info.getUrl().contains("/bidi/logEntryAdded.html")); + } + + @Test + void testNavigateToAUrlWithReadinessState() { + BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB); + + NavigationResult info = browsingContext.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", + ReadinessState.COMPLETE); + + Assertions.assertNotNull(browsingContext.getId()); + Assertions.assertNotNull(info.getNavigationId()); + Assertions.assertTrue(info.getUrl().contains("/bidi/logEntryAdded.html")); + } + + @Test + void testGetTreeWithAChild() { + String referenceContextId = driver.getWindowHandle(); + BrowsingContext parentWindow = new BrowsingContext(driver, referenceContextId); + + parentWindow.navigate("https://www.selenium.dev/selenium/web/iframes.html", ReadinessState.COMPLETE); + + List contextInfoList = parentWindow.getTree(); + + Assertions.assertEquals(1, contextInfoList.size()); + BrowsingContextInfo info = contextInfoList.get(0); + Assertions.assertEquals(1, info.getChildren().size()); + Assertions.assertEquals(referenceContextId, info.getId()); + Assertions.assertTrue(info.getChildren().get(0).getUrl().contains("formPage.html")); + } + + @Test + void testGetTreeWithDepth() { + String referenceContextId = driver.getWindowHandle(); + BrowsingContext parentWindow = new BrowsingContext(driver, referenceContextId); + + parentWindow.navigate("https://www.selenium.dev/selenium/web/iframes.html", ReadinessState.COMPLETE); + + List contextInfoList = parentWindow.getTree(0); + + Assertions.assertEquals(1, contextInfoList.size()); + BrowsingContextInfo info = contextInfoList.get(0); + Assertions.assertNull(info.getChildren()); // since depth is 0 + Assertions.assertEquals(referenceContextId, info.getId()); + } + + @Test + void testGetAllTopLevelContexts() { + BrowsingContext window1 = new BrowsingContext(driver, driver.getWindowHandle()); + BrowsingContext window2 = new BrowsingContext(driver, WindowType.WINDOW); + + List contextInfoList = window1.getTopLevelContexts(); + + Assertions.assertEquals(2, contextInfoList.size()); + } + + @Test + void testCloseAWindow() { + BrowsingContext window1 = new BrowsingContext(driver, WindowType.WINDOW); + BrowsingContext window2 = new BrowsingContext(driver, WindowType.WINDOW); + + window2.close(); + + Assertions.assertThrows(BiDiException.class, window2::getTree); + } + + @Test + void testCloseATab() { + BrowsingContext tab1 = new BrowsingContext(driver, WindowType.TAB); + BrowsingContext tab2 = new BrowsingContext(driver, WindowType.TAB); + + tab2.close(); + + Assertions.assertThrows(BiDiException.class, tab2::getTree); + } + + @Test + void testActivateABrowsingContext() { + BrowsingContext window1 = new BrowsingContext(driver, driver.getWindowHandle()); + BrowsingContext window2 = new BrowsingContext(driver, WindowType.WINDOW); + + window1.activate(); + + boolean isFocused = (boolean) ((JavascriptExecutor) driver).executeScript("return document.hasFocus();"); + + Assertions.assertTrue(isFocused); + } + + @Test + void testReloadABrowsingContext() { + BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB); + + browsingContext.navigate("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", ReadinessState.COMPLETE); + + NavigationResult reloadInfo = browsingContext.reload(ReadinessState.INTERACTIVE); + + Assertions.assertNotNull(reloadInfo.getNavigationId()); + Assertions.assertTrue(reloadInfo.getUrl().contains("/bidi/logEntryAdded.html")); + } + + @Test + void testHandleUserPrompt() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/alerts.html"); + + driver.findElement(By.id("alert")).click(); + + browsingContext.handleUserPrompt(); + + Assertions.assertTrue(driver.getPageSource().contains("Testing Alerts and Stuff")); + } + + @Test + void testAcceptUserPrompt() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/alerts.html"); + + driver.findElement(By.id("alert")).click(); + + browsingContext.handleUserPrompt("true"); + + Assertions.assertTrue(driver.getPageSource().contains("Testing Alerts and Stuff")); + } + + @Test + void testDismissUserPrompt() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/alerts.html"); + + driver.findElement(By.id("alert")).click(); + + browsingContext.handleUserPrompt("true"); + + Assertions.assertTrue(driver.getPageSource().contains("Testing Alerts and Stuff")); + } + + @Test + void testPassUserTextToUserPrompt() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/alerts.html"); + + driver.findElement(By.id("prompt-with-default")).click(); + + String userText = "Selenium automates browsers"; + browsingContext.handleUserPrompt(true, userText); + + Assertions.assertTrue(driver.getPageSource().contains(userText)); + } + + @Test + void testDismissUserPromptWithText() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/alerts.html"); + + driver.findElement(By.id("prompt-with-default")).click(); + + String userText = "Selenium automates browsers"; + browsingContext.handleUserPrompt(false, userText); + + Assertions.assertFalse(driver.getPageSource().contains(userText)); + } + + @Test + void textCaptureScreenshot() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/alerts.html"); + + String screenshot = browsingContext.captureScreenshot(); + + Assertions.assertTrue(screenshot.length() > 0); + } + + @Test + void textCaptureViewportScreenshot() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/coordinates_tests/simple_page.html"); + + WebElement element = driver.findElement(By.id("box")); + Rectangle elementRectangle = element.getRect(); + + String screenshot = + browsingContext.captureBoxScreenshot( + elementRectangle.getX(), elementRectangle.getY(), 5, 5); + + Assertions.assertTrue(screenshot.length() > 0); + } + + @Test + void textCaptureElementScreenshot() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/formPage.html"); + WebElement element = driver.findElement(By.id("checky")); + + String screenshot = browsingContext.captureElementScreenshot(((RemoteWebElement) element).getId()); + + Assertions.assertTrue(screenshot.length() > 0); + } + + @Test + void textSetViewport() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + driver.get("https://www.selenium.dev/selenium/web/formPage.html"); + + browsingContext.setViewport(250, 300); + + List newViewportSize = + (List) + ((JavascriptExecutor) driver) + .executeScript("return [window.innerWidth, window.innerHeight];"); + + Assertions.assertEquals(250, newViewportSize.get(0)); + Assertions.assertEquals(300, newViewportSize.get(1)); + } + + @Test + @Disabled("Supported by Firefox Nightly 124") + void textSetViewportWithDevicePixelRatio() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + driver.get("https://www.selenium.dev/selenium/web/formPage.html"); + + browsingContext.setViewport(250, 300, 5); + + Long newDevicePixelRatio = + (Long) ((JavascriptExecutor) driver).executeScript("return window.devicePixelRatio"); + + Assertions.assertEquals(5, newDevicePixelRatio); + } + + @Test + void testPrintPage() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/formPage.html"); + PrintOptions printOptions = new PrintOptions(); + + String printPage = browsingContext.print(printOptions); + + Assertions.assertTrue(printPage.length() > 0); + } + + @Test + @Disabled("Supported by Firefox Nightly 124") + void testNavigateBackInTheBrowserHistory() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + browsingContext.navigate("https://www.selenium.dev/selenium/web/formPage.html", ReadinessState.COMPLETE); + + wait.until(visibilityOfElementLocated(By.id("imageButton"))).submit(); + wait.until(titleIs("We Arrive Here")); + + browsingContext.back(); + Assertions.assertTrue(driver.getPageSource().contains("We Leave From Here")); + } + + @Test + @Disabled("Supported by Firefox Nightly 124") + void canNavigateForwardInTheBrowserHistory() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + browsingContext.navigate("https://www.selenium.dev/selenium/web/formPage.html", ReadinessState.COMPLETE); + + wait.until(visibilityOfElementLocated(By.id("imageButton"))).submit(); + wait.until(titleIs("We Arrive Here")); + + browsingContext.back(); + Assertions.assertTrue(driver.getPageSource().contains("We Leave From Here")); + + browsingContext.forward(); + wait.until(titleIs("We Arrive Here")); + } + + @Test + @Disabled("Supported by Firefox Nightly 124") + void canTraverseBrowserHistory() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + browsingContext.navigate("https://www.selenium.dev/selenium/web/formPage.html", ReadinessState.COMPLETE); + + wait.until(visibilityOfElementLocated(By.id("imageButton"))).submit(); + wait.until(titleIs("We Arrive Here")); + + browsingContext.traverseHistory(-1); + Assertions.assertTrue(driver.getPageSource().contains("We Leave From Here")); + } +} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LocateNodesTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LocateNodesTest.java new file mode 100644 index 000000000000..af0003daacbf --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LocateNodesTest.java @@ -0,0 +1,221 @@ +package dev.selenium.bidirectional.webdriver_bidi; + +import dev.selenium.BaseTest; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.bidi.module.Script; +import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; +import org.openqa.selenium.bidi.browsingcontext.LocateNodeParameters; +import org.openqa.selenium.bidi.browsingcontext.Locator; +import org.openqa.selenium.bidi.browsingcontext.ReadinessState; +import org.openqa.selenium.bidi.script.EvaluateResult; +import org.openqa.selenium.bidi.script.EvaluateResultSuccess; +import org.openqa.selenium.bidi.script.LocalValue; +import org.openqa.selenium.bidi.script.NodeProperties; +import org.openqa.selenium.bidi.script.RemoteReference; +import org.openqa.selenium.bidi.script.RemoteValue; +import org.openqa.selenium.bidi.script.ResultOwnership; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; + +class LocateNodesTest extends BaseTest { + + @BeforeEach + public void setup() { + FirefoxOptions options = new FirefoxOptions(); + options.setCapability("webSocketUrl", true); + driver = new FirefoxDriver(options); + } + + @Test + @Disabled + void testCreateABrowsingContextForGivenId() { + String id = driver.getWindowHandle(); + BrowsingContext browsingContext = new BrowsingContext(driver, id); + Assertions.assertEquals(id, browsingContext.getId()); + } + + @Test + @Disabled + void canLocateNodes() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); + + LocateNodeParameters parameters = new LocateNodeParameters(Locator.css("div")); + + List elements = browsingContext.locateNodes(parameters); + Assertions.assertEquals(13, elements.size()); + } + + @Test + @Disabled + void canLocateNodesWithJustLocator() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); + + List elements = browsingContext.locateNodes(Locator.css("div")); + Assertions.assertEquals(13, elements.size()); + } + + @Test + @Disabled + void canLocateNode() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); + + RemoteValue element = browsingContext.locateNode(Locator.css("div")); + Assertions.assertEquals("node", element.getType()); + } + + @Test + @Disabled + void canLocateNodesWithCSSLocator() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); + + LocateNodeParameters parameters = + new LocateNodeParameters(Locator.css("div.extraDiv, div.content")) + .setMaxNodeCount(1); + + List elements = browsingContext.locateNodes(parameters); + + RemoteValue value = elements.get(0); + NodeProperties properties = (NodeProperties) value.getValue().get(); + Assertions.assertEquals("div", properties.getLocalName().get()); + Assertions.assertEquals("content", properties.getAttributes().get().get("class")); + } + + @Test + @Disabled + void canLocateNodesWithXPathLocator() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); + + LocateNodeParameters parameters = + new LocateNodeParameters(Locator.xpath("/html/body/div[2]")).setMaxNodeCount(1); + + List elements = browsingContext.locateNodes(parameters); + + RemoteValue value = elements.get(0); + NodeProperties properties = (NodeProperties) value.getValue().get(); + Assertions.assertEquals("div", properties.getLocalName().get()); + Assertions.assertEquals("content", properties.getAttributes().get().get("class")); + } + + @Test + @Disabled + void canLocateNodesWithInnerText() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); + + LocateNodeParameters parameters = + new LocateNodeParameters(Locator.innerText("Spaced out")).setMaxNodeCount(1); + + List elements = browsingContext.locateNodes(parameters); + + RemoteValue value = elements.get(0); + Assertions.assertEquals("node", value.getType()); + } + + @Test + @Disabled + void canLocateNodesWithMaxNodeCount() { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + driver.get("https://www.selenium.dev/selenium/web/xhtmlTest.html"); + + LocateNodeParameters parameters = + new LocateNodeParameters(Locator.css("div")).setMaxNodeCount(4); + + List elements = browsingContext.locateNodes(parameters); + Assertions.assertEquals(4, elements.size()); + } + + @Test + @Disabled + void canLocateNodesGivenStartNodes() { + String handle = driver.getWindowHandle(); + BrowsingContext browsingContext = new BrowsingContext(driver, handle); + + driver.get("https://www.selenium.dev/selenium/web/formPage.html"); + + Script script = new Script(driver); + EvaluateResult result = + script.evaluateFunctionInBrowsingContext( + handle, + "document.querySelectorAll(\"form\")", + false, + Optional.of(ResultOwnership.ROOT)); + + EvaluateResultSuccess resultSuccess = (EvaluateResultSuccess) result; + List startNodes = new ArrayList<>(); + + RemoteValue remoteValue = resultSuccess.getResult(); + List remoteValues = (List) remoteValue.getValue().get(); + + remoteValues.forEach( + value -> + startNodes.add( + new RemoteReference(RemoteReference.Type.SHARED_ID, value.getSharedId().get()))); + + LocateNodeParameters parameters = + new LocateNodeParameters(Locator.css("input")) + .setStartNodes(startNodes) + .setMaxNodeCount(50); + + List elements = browsingContext.locateNodes(parameters); + Assertions.assertEquals(35, elements.size()); + } + + @Test + @Disabled + void canLocateNodesInAGivenSandbox() { + String sandbox = "sandbox"; + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + + browsingContext.navigate("https://www.selenium.dev/selenium/web/xhtmlTest.html", ReadinessState.COMPLETE); + + LocateNodeParameters parameters = + new LocateNodeParameters(Locator.css("div")) + .setSandbox(sandbox) + .setMaxNodeCount(1); + + List elements = browsingContext.locateNodes(parameters); + + String nodeId = elements.get(0).getSharedId().get(); + + List arguments = new ArrayList<>(); + + LocalValue value = LocalValue.mapValue(Map.of("sharedId", LocalValue.stringValue(nodeId))); + arguments.add(value); + + Script script = new Script(driver); + + // Since the node was present in the sandbox, the script run in the same sandbox should be able + // to retrieve it + EvaluateResult result = + script.callFunctionInBrowsingContext( + driver.getWindowHandle(), + sandbox, + "function(){ return arguments[0]; }", + true, + Optional.of(arguments), + Optional.empty(), + Optional.empty()); + + Map sharedIdMap = + (Map) ((EvaluateResultSuccess) result).getResult().getValue().get(); + + String sharedId = (String) ((RemoteValue) sharedIdMap.get("sharedId")).getValue().get(); + Assertions.assertEquals(nodeId, sharedId); + } +} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java new file mode 100644 index 000000000000..1abd3f15505d --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java @@ -0,0 +1,142 @@ +package dev.selenium.bidirectional.webdriver_bidi; + +import dev.selenium.BaseTest; + +import java.time.Duration; +import java.util.concurrent.*; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.bidi.module.LogInspector; +import org.openqa.selenium.bidi.log.ConsoleLogEntry; +import org.openqa.selenium.bidi.log.JavascriptLogEntry; +import org.openqa.selenium.bidi.log.LogLevel; +import org.openqa.selenium.bidi.log.StackTrace; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; +import org.openqa.selenium.support.ui.WebDriverWait; + +class LogTest extends BaseTest { + + @BeforeEach + public void setup() { + FirefoxOptions options = new FirefoxOptions(); + options.setCapability("webSocketUrl", true); + driver = new FirefoxDriver(options); + } + + @Test + public void jsErrors() { + CopyOnWriteArrayList logs = new CopyOnWriteArrayList<>(); + + try (LogInspector logInspector = new LogInspector(driver)) { + logInspector.onConsoleEntry(logs::add); + } + + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + driver.findElement(By.id("consoleLog")).click(); + + new WebDriverWait(driver, Duration.ofSeconds(5)).until(_d -> !logs.isEmpty()); + Assertions.assertEquals("Hello, world!", logs.get(0).getText()); + } + + @Test + void testListenToConsoleLog() throws ExecutionException, InterruptedException, TimeoutException { + try (LogInspector logInspector = new LogInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + logInspector.onConsoleEntry(future::complete); + + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + driver.findElement(By.id("consoleLog")).click(); + + ConsoleLogEntry logEntry = future.get(5, TimeUnit.SECONDS); + + Assertions.assertEquals("Hello, world!", logEntry.getText()); + Assertions.assertNull(logEntry.getRealm()); + Assertions.assertEquals(1, logEntry.getArgs().size()); + Assertions.assertEquals("console", logEntry.getType()); + Assertions.assertEquals("log", logEntry.getMethod()); + Assertions.assertNull(logEntry.getStackTrace()); + } + } + + @Test + void testListenToJavascriptLog() + throws ExecutionException, InterruptedException, TimeoutException { + try (LogInspector logInspector = new LogInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + logInspector.onJavaScriptLog(future::complete); + + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + driver.findElement(By.id("jsException")).click(); + + JavascriptLogEntry logEntry = future.get(5, TimeUnit.SECONDS); + + Assertions.assertEquals("Error: Not working", logEntry.getText()); + Assertions.assertEquals("javascript", logEntry.getType()); + Assertions.assertEquals(LogLevel.ERROR, logEntry.getLevel()); + } + } + + @Test + void testListenToJavascriptErrorLog() + throws ExecutionException, InterruptedException, TimeoutException { + try (LogInspector logInspector = new LogInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + logInspector.onJavaScriptException(future::complete); + + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + driver.findElement(By.id("jsException")).click(); + + JavascriptLogEntry logEntry = future.get(5, TimeUnit.SECONDS); + + Assertions.assertEquals("Error: Not working", logEntry.getText()); + Assertions.assertEquals("javascript", logEntry.getType()); + } + } + + @Test + void testRetrieveStacktraceForALog() + throws ExecutionException, InterruptedException, TimeoutException { + try (LogInspector logInspector = new LogInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + logInspector.onJavaScriptException(future::complete); + + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + driver.findElement(By.id("logWithStacktrace")).click(); + + JavascriptLogEntry logEntry = future.get(5, TimeUnit.SECONDS); + + StackTrace stackTrace = logEntry.getStackTrace(); + Assertions.assertNotNull(stackTrace); + Assertions.assertEquals(4, stackTrace.getCallFrames().size()); + } + } + + @Test + void testListenToLogsWithMultipleConsumers() + throws ExecutionException, InterruptedException, TimeoutException { + try (LogInspector logInspector = new LogInspector(driver)) { + CompletableFuture completableFuture1 = new CompletableFuture<>(); + logInspector.onJavaScriptLog(completableFuture1::complete); + + CompletableFuture completableFuture2 = new CompletableFuture<>(); + logInspector.onJavaScriptLog(completableFuture2::complete); + + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + driver.findElement(By.id("jsException")).click(); + + JavascriptLogEntry logEntry = completableFuture1.get(5, TimeUnit.SECONDS); + + Assertions.assertEquals("Error: Not working", logEntry.getText()); + Assertions.assertEquals("javascript", logEntry.getType()); + + logEntry = completableFuture2.get(5, TimeUnit.SECONDS); + + Assertions.assertEquals("Error: Not working", logEntry.getText()); + Assertions.assertEquals("javascript", logEntry.getType()); + } + } +} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java new file mode 100644 index 000000000000..8050892d27ca --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java @@ -0,0 +1,112 @@ +package dev.selenium.bidirectional.webdriver_bidi; + +import dev.selenium.BaseTest; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.Alert; +import org.openqa.selenium.By; +import org.openqa.selenium.TimeoutException; +import org.openqa.selenium.UsernameAndPassword; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.bidi.module.Network; +import org.openqa.selenium.bidi.network.AddInterceptParameters; +import org.openqa.selenium.bidi.network.InterceptPhase; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +class NetworkCommandsTest extends BaseTest { + + @BeforeEach + public void setup() { + FirefoxOptions options = new FirefoxOptions(); + options.setCapability("webSocketUrl", true); + driver = new FirefoxDriver(options); + wait = new WebDriverWait(driver, Duration.ofSeconds(10)); + } + + @Test + @Disabled + void canAddIntercept() { + try (Network network = new Network(driver)) { + String intercept = + network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)); + Assertions.assertNotNull(intercept); + } + } + + @Test + @Disabled + void canRemoveIntercept() { + try (Network network = new Network(driver)) { + String intercept = + network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)); + Assertions.assertNotNull(intercept); + network.removeIntercept(intercept); + } + } + + @Test + @Disabled + void canContinueWithAuthCredentials() { + try (Network network = new Network(driver)) { + network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)); + network.onAuthRequired( + responseDetails -> + network.continueWithAuth( + responseDetails.getRequest().getRequestId(), + new UsernameAndPassword("admin", "admin"))); + driver.get("https://the-internet.herokuapp.com/basic_auth"); + String successMessage = "Congratulations! You must have the proper credentials."; + WebElement elementMessage = driver.findElement(By.tagName("p")); + Assertions.assertEquals(successMessage, elementMessage.getText()); + } + } + + @Test + @Disabled + void canContinueWithoutAuthCredentials() { + try (Network network = new Network(driver)) { + network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)); + network.onAuthRequired( + responseDetails -> + // Does not handle the alert + network.continueWithAuthNoCredentials(responseDetails.getRequest().getRequestId())); + driver.get("https://the-internet.herokuapp.com/basic_auth"); + Alert alert = wait.until(ExpectedConditions.alertIsPresent()); + alert.dismiss(); + Assertions.assertTrue(driver.getPageSource().contains("Not authorized")); + } + } + + @Test + @Disabled + void canCancelAuth() { + try (Network network = new Network(driver)) { + network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)); + network.onAuthRequired( + responseDetails -> + // Does not handle the alert + network.cancelAuth(responseDetails.getRequest().getRequestId())); + driver.get("https://the-internet.herokuapp.com/basic_auth"); + Assertions.assertTrue(driver.getPageSource().contains("Not authorized")); + } + } + + @Test + @Disabled + void canFailRequest() { + try (Network network = new Network(driver)) { + network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)); + network.onBeforeRequestSent( + responseDetails -> network.failRequest(responseDetails.getRequest().getRequestId())); + driver.manage().timeouts().pageLoadTimeout(Duration.of(5, ChronoUnit.SECONDS)); + Assertions.assertThrows(TimeoutException.class, () -> driver.get("https://the-internet.herokuapp.com/basic_auth")); + } + } +} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java new file mode 100644 index 000000000000..d00d5af9ce8d --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java @@ -0,0 +1,113 @@ +package dev.selenium.bidirectional.webdriver_bidi; + +import dev.selenium.BaseTest; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.Cookie; +import org.openqa.selenium.bidi.module.Network; +import org.openqa.selenium.bidi.network.BeforeRequestSent; +import org.openqa.selenium.bidi.network.ResponseDetails; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; + +class NetworkEventsTest extends BaseTest { + + @BeforeEach + public void setup() { + FirefoxOptions options = new FirefoxOptions(); + options.setCapability("webSocketUrl", true); + driver = new FirefoxDriver(options); + } + + @Test + void canListenToBeforeRequestSentEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (Network network = new Network(driver)) { + CompletableFuture future = new CompletableFuture<>(); + network.onBeforeRequestSent(future::complete); + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + + BeforeRequestSent requestSent = future.get(5, TimeUnit.SECONDS); + String windowHandle = driver.getWindowHandle(); + Assertions.assertEquals(windowHandle, requestSent.getBrowsingContextId()); + Assertions.assertEquals("get", requestSent.getRequest().getMethod().toLowerCase()); + } + } + + @Test + void canListenToResponseStartedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (Network network = new Network(driver)) { + CompletableFuture future = new CompletableFuture<>(); + network.onResponseStarted(future::complete); + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + + ResponseDetails response = future.get(5, TimeUnit.SECONDS); + String windowHandle = driver.getWindowHandle(); + + Assertions.assertEquals(windowHandle, response.getBrowsingContextId()); + Assertions.assertEquals("get", response.getRequest().getMethod().toLowerCase()); + Assertions.assertEquals(200L, response.getResponseData().getStatus()); + } + } + + @Test + void canListenToResponseCompletedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (Network network = new Network(driver)) { + CompletableFuture future = new CompletableFuture<>(); + network.onResponseCompleted(future::complete); + driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + + ResponseDetails response = future.get(5, TimeUnit.SECONDS); + String windowHandle = driver.getWindowHandle(); + + Assertions.assertEquals(windowHandle, response.getBrowsingContextId()); + Assertions.assertEquals("get", response.getRequest().getMethod().toLowerCase()); + Assertions.assertEquals(200L, response.getResponseData().getStatus()); + } + } + + @Test + void canListenToResponseCompletedEventWithCookie() + throws ExecutionException, InterruptedException, TimeoutException { + try (Network network = new Network(driver)) { + CompletableFuture future = new CompletableFuture<>(); + + driver.get("https://www.selenium.dev/selenium/web/blankPage"); + driver.manage().addCookie(new Cookie("foo", "bar")); + network.onBeforeRequestSent(future::complete); + driver.navigate().refresh(); + + BeforeRequestSent requestSent = future.get(5, TimeUnit.SECONDS); + String windowHandle = driver.getWindowHandle(); + + Assertions.assertEquals(windowHandle, requestSent.getBrowsingContextId()); + Assertions.assertEquals("get", requestSent.getRequest().getMethod().toLowerCase()); + + Assertions.assertEquals("foo", requestSent.getRequest().getCookies().get(0).getName()); + Assertions.assertEquals("bar", requestSent.getRequest().getCookies().get(0).getValue().getValue()); + } + } + + @Test + void canListenToOnAuthRequiredEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (Network network = new Network(driver)) { + CompletableFuture future = new CompletableFuture<>(); + network.onAuthRequired(future::complete); + driver.get("https://the-internet.herokuapp.com/basic_auth"); + + ResponseDetails response = future.get(5, TimeUnit.SECONDS); + String windowHandle = driver.getWindowHandle(); + Assertions.assertEquals(windowHandle, response.getBrowsingContextId()); + Assertions.assertEquals("get", response.getRequest().getMethod().toLowerCase()); + Assertions.assertEquals(401L, response.getResponseData().getStatus()); + } + } +} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java new file mode 100644 index 000000000000..7346049cfd9e --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java @@ -0,0 +1,87 @@ +package dev.selenium.bidirectional.webdriver_bidi; + +import dev.selenium.BaseTest; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; +import org.openqa.selenium.bidi.module.Script; +import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; +import org.openqa.selenium.bidi.script.LocalValue; +import org.openqa.selenium.bidi.script.Message; +import org.openqa.selenium.bidi.script.RealmInfo; +import org.openqa.selenium.bidi.script.RealmType; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; + +class ScriptEventsTest extends BaseTest { + + @BeforeEach + public void setup() { + FirefoxOptions options = new FirefoxOptions(); + options.setCapability("webSocketUrl", true); + driver = new FirefoxDriver(options); + } + + @Test + void canListenToChannelMessage() + throws ExecutionException, InterruptedException, TimeoutException { + try (Script script = new Script(driver)) { + CompletableFuture future = new CompletableFuture<>(); + script.onMessage(future::complete); + + script.callFunctionInBrowsingContext( + driver.getWindowHandle(), + "(channel) => channel('foo')", + false, + Optional.of(List.of(LocalValue.channelValue("channel_name"))), + Optional.empty(), + Optional.empty()); + + Message message = future.get(5, TimeUnit.SECONDS); + Assertions.assertEquals("channel_name", message.getChannel()); + } + } + + @Test + @DisabledOnOs(value = OS.MAC, disabledReason = "Works locally, times out on CI") + void canListenToRealmCreatedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (Script script = new Script(driver)) { + CompletableFuture future = new CompletableFuture<>(); + script.onRealmCreated(future::complete); + + BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); + + context.navigate("https://www.selenium.dev/selenium/blankPage"); + RealmInfo realmInfo = future.get(5, TimeUnit.SECONDS); + Assertions.assertNotNull(realmInfo.getRealmId()); + Assertions.assertEquals(RealmType.WINDOW, realmInfo.getRealmType()); + } + } + + @Test + @Disabled + void canListenToRealmDestroyedEvent() + throws ExecutionException, InterruptedException, TimeoutException { + try (Script script = new Script(driver)) { + CompletableFuture future = new CompletableFuture<>(); + script.onRealmDestroyed(future::complete); + + BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle()); + + context.close(); + RealmInfo realmInfo = future.get(5, TimeUnit.SECONDS); + Assertions.assertNotNull(realmInfo.getRealmId()); + Assertions.assertEquals(RealmType.WINDOW, realmInfo.getRealmType()); + } + } +} diff --git a/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java new file mode 100644 index 000000000000..2e1ab65e9355 --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java @@ -0,0 +1,494 @@ +package dev.selenium.bidirectional.webdriver_bidi; + +import dev.selenium.BaseTest; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriverException; +import org.openqa.selenium.WindowType; +import org.openqa.selenium.bidi.module.LogInspector; +import org.openqa.selenium.bidi.module.Script; +import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; +import org.openqa.selenium.bidi.browsingcontext.ReadinessState; +import org.openqa.selenium.bidi.log.ConsoleLogEntry; +import org.openqa.selenium.bidi.script.ChannelValue; +import org.openqa.selenium.bidi.script.EvaluateResult; +import org.openqa.selenium.bidi.script.EvaluateResultExceptionValue; +import org.openqa.selenium.bidi.script.EvaluateResultSuccess; +import org.openqa.selenium.bidi.script.LocalValue; +import org.openqa.selenium.bidi.script.ObjectLocalValue; +import org.openqa.selenium.bidi.script.PrimitiveProtocolValue; +import org.openqa.selenium.bidi.script.RealmInfo; +import org.openqa.selenium.bidi.script.RealmType; +import org.openqa.selenium.bidi.script.RemoteReference; +import org.openqa.selenium.bidi.script.ResultOwnership; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.firefox.FirefoxOptions; + +class ScriptTest extends BaseTest { + + @BeforeEach + public void setup() { + FirefoxOptions options = new FirefoxOptions(); + options.setCapability("webSocketUrl", true); + driver = new FirefoxDriver(options); + } + + @Test + void canCallFunction() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + List arguments = new ArrayList<>(); + arguments.add(PrimitiveProtocolValue.numberValue(22)); + + Map value = new HashMap<>(); + value.put("some_property", LocalValue.numberValue(42)); + LocalValue thisParameter = LocalValue.objectValue(value); + + arguments.add(thisParameter); + + EvaluateResult result = + script.callFunctionInBrowsingContext( + id, + "function processWithPromise(argument) {\n" + + " return new Promise((resolve, reject) => {\n" + + " setTimeout(() => {\n" + + " resolve(argument + this.some_property);\n" + + " }, 1000)\n" + + " })\n" + + "}", + true, + Optional.of(arguments), + Optional.of(thisParameter), + Optional.of(ResultOwnership.ROOT)); + + EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; + Assertions.assertEquals(64L, (Long) successResult.getResult().getValue().get()); + } + } + + @Test + void canCallFunctionWithDeclaration() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + EvaluateResult result = + script.callFunctionInBrowsingContext( + id, "()=>{return 1+2;}", false, Optional.empty(), Optional.empty(), Optional.empty()); + EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; + Assertions.assertEquals(3L, (Long) successResult.getResult().getValue().get()); + } + } + + @Test + void canCallFunctionWithArguments() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + List arguments = new ArrayList<>(); + LocalValue value1 = PrimitiveProtocolValue.stringValue("ARGUMENT_STRING_VALUE"); + LocalValue value2 = PrimitiveProtocolValue.numberValue(42); + arguments.add(value1); + arguments.add(value2); + + EvaluateResult result = + script.callFunctionInBrowsingContext( + id, + "(...args)=>{return args}", + false, + Optional.of(arguments), + Optional.empty(), + Optional.empty()); + + EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; + Assertions.assertEquals(2, ((List) successResult.getResult().getValue().get()).size()); + } + } + + @Test + void canCallFunctionWithAwaitPromise() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + EvaluateResult result = + script.callFunctionInBrowsingContext( + id, + "async function() {{\n" + + " await new Promise(r => setTimeout(() => r(), 0));\n" + + " return \"SOME_DELAYED_RESULT\";\n" + + " }}", + true, + Optional.empty(), + Optional.empty(), + Optional.empty()); + EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; + Assertions.assertEquals("SOME_DELAYED_RESULT", (String) successResult.getResult().getValue().get()); + } + } + + @Test + void canCallFunctionWithThisParameter() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + Map value = new HashMap<>(); + value.put("some_property", PrimitiveProtocolValue.numberValue(42)); + LocalValue thisParameter = LocalValue.objectValue(value); + + EvaluateResult result = + script.callFunctionInBrowsingContext( + id, + "function(){return this.some_property}", + false, + Optional.empty(), + Optional.of(thisParameter), + Optional.empty()); + + EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; + Assertions.assertEquals("number", successResult.getResult().getType()); + Assertions.assertEquals(42L, (Long) successResult.getResult().getValue().get()); + } + } + + @Test + void canCallFunctionWithOwnershipRoot() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + EvaluateResult result = + script.callFunctionInBrowsingContext( + id, + "async function(){return {a:1}}", + true, + Optional.empty(), + Optional.empty(), + Optional.of(ResultOwnership.ROOT)); + + EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; + Assertions.assertTrue(successResult.getResult().getHandle().isPresent()); + } + } + + @Test + void canCallFunctionThatThrowsException() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + EvaluateResult result = + script.callFunctionInBrowsingContext( + id, + "))) !!@@## some invalid JS script (((", + false, + Optional.empty(), + Optional.empty(), + Optional.empty()); + EvaluateResultExceptionValue exception = (EvaluateResultExceptionValue) result; + Assertions.assertEquals("error", exception.getExceptionDetails().getException().getType()); + Assertions.assertEquals( + "SyntaxError: expected expression, got ')'", exception.getExceptionDetails().getText()); + } + } + + @Test + void canCallFunctionInASandBox() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + EvaluateResult result = + script.callFunctionInBrowsingContext( + id, + "sandbox", + "() => window.foo", + true, + Optional.empty(), + Optional.empty(), + Optional.empty()); + + Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); + } + } + + @Test + void canCallFunctionInARealm() { + String tab = driver.getWindowHandle(); + try (Script script = new Script(tab, driver)) { + List realms = script.getAllRealms(); + String realmId = realms.get(0).getRealmId(); + + EvaluateResult result = script.callFunctionInRealm( + realmId, + "() => { window.foo = 3; }", + true, + Optional.empty(), + Optional.empty(), + Optional.empty()); + + Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); + } + } + + @Test + void canEvaluateScript() { + String id = driver.getWindowHandle(); + + try (Script script = new Script(id, driver)) { + EvaluateResult result = + script.evaluateFunctionInBrowsingContext(id, "1 + 2", true, Optional.empty()); + + EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; + Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); + Assertions.assertEquals(3L, (Long) successResult.getResult().getValue().get()); + } + } + + @Test + void canEvaluateScriptThatThrowsException() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + EvaluateResult result = + script.evaluateFunctionInBrowsingContext( + id, "))) !!@@## some invalid JS script (((", false, Optional.empty()); + + EvaluateResultExceptionValue exception = (EvaluateResultExceptionValue) result; + Assertions.assertEquals("error", exception.getExceptionDetails().getException().getType()); + Assertions.assertEquals( + "SyntaxError: expected expression, got ')'", exception.getExceptionDetails().getText()); + } + } + + @Test + void canEvaluateScriptWithResulWithOwnership() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + EvaluateResult result = + script.evaluateFunctionInBrowsingContext( + id, "Promise.resolve({a:1})", true, Optional.of(ResultOwnership.ROOT)); + + EvaluateResultSuccess successResult = (EvaluateResultSuccess) result; + Assertions.assertTrue(successResult.getResult().getHandle().isPresent()); + } + } + + @Test + void canEvaluateInASandBox() { + String id = driver.getWindowHandle(); + try (Script script = new Script(id, driver)) { + EvaluateResult result = + script.evaluateFunctionInBrowsingContext( + id, "sandbox", "window.foo", true, Optional.empty()); + + + Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); + } + } + + @Test + void canEvaluateInARealm() { + String tab = driver.getWindowHandle(); + try (Script script = new Script(tab, driver)) { + List realms = script.getAllRealms(); + String realmId = realms.get(0).getRealmId(); + + EvaluateResult result = + script.evaluateFunctionInRealm( + realmId, "window.foo", true, Optional.empty()); + + Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); + } + } + + @Test + void canDisownHandle() { + String window = driver.getWindowHandle(); + try (Script script = new Script(window, driver)) { + BrowsingContext context = new BrowsingContext(driver, window); + + context.navigate("https://www.selenium.dev/selenium/web/dynamic.html", ReadinessState.COMPLETE); + + driver.findElement(By.id("adder")).click(); + + getLocatedElement(driver, By.id("box0")); + + EvaluateResult result = + script.evaluateFunctionInBrowsingContext( + window, "document.querySelector('.redbox');", false, Optional.of(ResultOwnership.ROOT)); + String boxId = ((EvaluateResultSuccess)result).getResult().getHandle().get(); + + script.disownBrowsingContextScript( + window, List.of(boxId)); + + LocalValue value = + LocalValue.remoteReference( + RemoteReference.Type.HANDLE, boxId); + + // Since the handle is now eligible for garbage collections, it is no longer available to be used. + Assertions.assertThrows(WebDriverException.class, () -> script.callFunctionInBrowsingContext( + window, + "arg => arg.a", + false, Optional.of(List.of(value)), + Optional.empty(), + Optional.empty())); + } + } + + @Test + void canDisownHandleInARealm() { + String window = driver.getWindowHandle(); + try (Script script = new Script(window, driver)) { + BrowsingContext context = new BrowsingContext(driver, window); + + context.navigate("https://www.selenium.dev/selenium/web/dynamic.html", ReadinessState.COMPLETE); + + driver.findElement(By.id("adder")).click(); + + getLocatedElement(driver, By.id("box0")); + + List realms = script.getAllRealms(); + String realmId = realms.get(0).getRealmId(); + + // Retrieve the handle for the element added to DOM + EvaluateResult result = + script.evaluateFunctionInBrowsingContext( + window, "document.querySelector('.redbox');", false, Optional.of(ResultOwnership.ROOT)); + String boxId = ((EvaluateResultSuccess)result).getResult().getHandle().get(); + + LocalValue value = + LocalValue.remoteReference( + RemoteReference.Type.HANDLE, boxId); + + EvaluateResult checkHandle = script.callFunctionInBrowsingContext( + window, + "arg => arg.a", + false, Optional.of(List.of(value)), + Optional.empty(), + Optional.empty()); + + // The handle is present in memory, else it would result in exception + Assertions.assertEquals(EvaluateResult.Type.SUCCESS, checkHandle.getResultType()); + + // Useful to memory management in a dynamic webpage where DOM mutations happen often + script.disownRealmScript(realmId, List.of(boxId)); + + // Since the handle is now eligible for garbage collections, it is no longer available to be used. + Assertions.assertThrows(WebDriverException.class, () -> script.callFunctionInBrowsingContext( + window, + "arg => arg.a", + false, Optional.of(List.of(value)), + Optional.empty(), + Optional.empty())); + } + } + + @Test + void canGetAllRealms() { + String firstWindow = driver.getWindowHandle(); + String secondWindow = driver.switchTo().newWindow(WindowType.WINDOW).getWindowHandle(); + try (Script script = new Script(firstWindow, driver)) { + List realms = script.getAllRealms(); + Assertions.assertEquals(2, realms.size()); + } + } + + @Test + void canGetRealmByType() { + String firstWindow = driver.getWindowHandle(); + String secondWindow = driver.switchTo().newWindow(WindowType.WINDOW).getWindowHandle(); + try (Script script = new Script(firstWindow, driver)) { + List realms = script.getRealmsByType(RealmType.WINDOW); + Assertions.assertEquals(2, realms.size()); + } + } + + @Test + void canGetRealmInBrowsingContext() { + String windowId = driver.getWindowHandle(); + String tabId = driver.switchTo().newWindow(WindowType.TAB).getWindowHandle(); + try (Script script = new Script(windowId, driver)) { + List realms = script.getRealmsInBrowsingContext(tabId); + Assertions.assertEquals(1, realms.size()); + } + } + + @Test + void canGetRealmInBrowsingContextByType() { + String windowId = driver.getWindowHandle(); + String tabId = driver.switchTo().newWindow(WindowType.TAB).getWindowHandle(); + try (Script script = new Script(windowId, driver)) { + List windowRealms = + script.getRealmsInBrowsingContextByType(windowId, RealmType.WINDOW); + Assertions.assertEquals(1, windowRealms.size()); + } + } + + @Test + void canAddPreloadScript() throws ExecutionException, InterruptedException, TimeoutException { + try (Script script = new Script(driver)) { + String id = + script.addPreloadScript("() => {{ console.log('{preload_script_console_text}') }}"); + + Assertions.assertNotNull(id); + + try (LogInspector logInspector = new LogInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + logInspector.onConsoleEntry(future::complete); + + driver.get("https://www.selenium.dev/selenium/blankPage"); + + ConsoleLogEntry logEntry = future.get(5, TimeUnit.SECONDS); + + Assertions.assertEquals("{preload_script_console_text}", logEntry.getText()); + } + } + } + + @Test + void canAddPreloadScriptWithArguments() { + try (Script script = new Script(driver)) { + String id = + script.addPreloadScript( + "(channel) => channel('will_be_send', 'will_be_ignored')", + List.of(new ChannelValue("channel_name"))); + Assertions.assertNotNull(id); + } + } + + @Test + void canAddPreloadScriptInASandbox() { + try (Script script = new Script(driver)) { + String id = script.addPreloadScript("() => { window.bar=2; }", "sandbox"); + Assertions.assertNotNull(id); + driver.get("https://www.selenium.dev/selenium/blankPage"); + + EvaluateResult result = + script.evaluateFunctionInBrowsingContext( + driver.getWindowHandle(), "sandbox", "window.bar", true, Optional.empty()); + Assertions.assertEquals(EvaluateResult.Type.SUCCESS, result.getResultType()); + } + } + + @Test + void canRemovePreloadScript() throws ExecutionException, InterruptedException, TimeoutException { + try (Script script = new Script(driver)) { + String id = + script.addPreloadScript("() => {{ console.log('{preload_script_console_text}') }}"); + + Assertions.assertNotNull(id); + + try (LogInspector logInspector = new LogInspector(driver)) { + CompletableFuture future = new CompletableFuture<>(); + logInspector.onConsoleEntry(future::complete); + + script.removePreloadScript(id); + + driver.get("https://www.selenium.dev/selenium/blankPage"); + + Assertions.assertThrows(TimeoutException.class, () -> future.get(5, TimeUnit.SECONDS)); + } + } + } +} diff --git a/examples/javascript/test/bidirectional/bidi.spec.js b/examples/javascript/test/bidirectional/bidi.spec.js new file mode 100644 index 000000000000..ca3655667bd2 --- /dev/null +++ b/examples/javascript/test/bidirectional/bidi.spec.js @@ -0,0 +1,52 @@ +const {suite} = require('selenium-webdriver/testing'); +const assert = require("assert"); +const firefox = require('selenium-webdriver/firefox'); +const LogInspector = require('selenium-webdriver/bidi/logInspector'); +const BrowsingContext = require('selenium-webdriver/bidi/browsingContext'); +const {until} = require('selenium-webdriver'); + +suite(function (env) { + describe('Integration Tests', function () { + let driver + + beforeEach(async function () { + driver = await env + .builder() + .setFirefoxOptions(new firefox.Options().enableBidi()) + .build() + }) + + afterEach(async function () { + await driver.quit() + }) + + it('test navigate and listen to errors', async function () { + let logEntry = null + const inspector = await LogInspector(driver) + await inspector.onJavascriptException(function (log) { + logEntry = log + }) + + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + let info = await browsingContext.navigate('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + + assert.notEqual(browsingContext.id, null) + assert.notEqual(info.navigationId, null) + assert(info.url.includes('/bidi/logEntryAdded.html')) + + await driver.wait(until.urlIs('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html')) + await driver.findElement({id: 'jsException'}).click() + + assert.equal(logEntry.text, 'Error: Not working') + assert.equal(logEntry.type, 'javascript') + assert.equal(logEntry.level, 'error') + + await inspector.close() + await browsingContext.close() + }) + }) +}, {browsers: ['firefox']}) \ No newline at end of file diff --git a/examples/javascript/test/bidirectional/browsingContext.spec.js b/examples/javascript/test/bidirectional/browsingContext.spec.js new file mode 100644 index 000000000000..1235e24a78f0 --- /dev/null +++ b/examples/javascript/test/bidirectional/browsingContext.spec.js @@ -0,0 +1,437 @@ +const {suite} = require('selenium-webdriver/testing'); +const assert = require("assert"); +const firefox = require('selenium-webdriver/firefox'); +const BrowsingContext = require('selenium-webdriver/bidi/browsingContext'); +const {By, until} = require("selenium-webdriver"); + +suite(function (env) { + describe('Browsing Context', function () { + let driver + let startIndex = 0 + let endIndex = 5 + let pdfMagicNumber = 'JVBER' + let pngMagicNumber = 'iVBOR' + + beforeEach(async function () { + driver = await env + .builder() + .setFirefoxOptions(new firefox.Options().enableBidi()) + .build() + }) + + afterEach(async function () { + await driver.quit() + }) + + it('test create a browsing context for given id', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + assert.equal(browsingContext.id, id) + }) + + it('test create a window', async function () { + const browsingContext = await BrowsingContext(driver, { + type: 'window', + }) + assert.notEqual(browsingContext.id, null) + }) + + it('test create a window with a reference context', async function () { + const browsingContext = await BrowsingContext(driver, { + type: 'window', + referenceContext: await driver.getWindowHandle(), + }) + assert.notEqual(browsingContext.id, null) + }) + + it('test create a tab', async function () { + const browsingContext = await BrowsingContext(driver, { + type: 'tab', + }) + assert.notEqual(browsingContext.id, null) + }) + + it('test create a tab with a reference context', async function () { + const browsingContext = await BrowsingContext(driver, { + type: 'tab', + referenceContext: await driver.getWindowHandle(), + }) + assert.notEqual(browsingContext.id, null) + }) + + it('test navigate to a url', async function () { + const browsingContext = await BrowsingContext(driver, { + type: 'tab', + }) + + let info = await browsingContext.navigate('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + + assert.notEqual(browsingContext.id, null) + assert.notEqual(info.navigationId, null) + assert(info.url.includes('/bidi/logEntryAdded.html')) + }) + + it('test navigate to a url with readiness state', async function () { + const browsingContext = await BrowsingContext(driver, { + type: 'tab', + }) + + const info = await browsingContext.navigate( + 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html', + 'complete' + ) + + assert.notEqual(browsingContext.id, null) + assert.notEqual(info.navigationId, null) + assert(info.url.includes('/bidi/logEntryAdded.html')) + }) + + it('test get tree with a child', async function () { + const browsingContextId = await driver.getWindowHandle() + const parentWindow = await BrowsingContext(driver, { + browsingContextId: browsingContextId, + }) + await parentWindow.navigate('https://www.selenium.dev/selenium/web/iframes.html', 'complete') + + const contextInfo = await parentWindow.getTree() + assert.equal(contextInfo.children.length, 1) + assert.equal(contextInfo.id, browsingContextId) + assert(contextInfo.children[0]['url'].includes('formPage.html')) + }) + + it('test get tree with depth', async function () { + const browsingContextId = await driver.getWindowHandle() + const parentWindow = await BrowsingContext(driver, { + browsingContextId: browsingContextId, + }) + await parentWindow.navigate('https://www.selenium.dev/selenium/web/iframes.html', 'complete') + + const contextInfo = await parentWindow.getTree(0) + assert.equal(contextInfo.children, null) + assert.equal(contextInfo.id, browsingContextId) + }) + + it('test close a window', async function () { + const window1 = await BrowsingContext(driver, {type: 'window'}) + const window2 = await BrowsingContext(driver, {type: 'window'}) + + await window2.close() + + assert.doesNotThrow(async function () { + await window1.getTree() + }) + await assert.rejects(window2.getTree(), {message: 'no such frame'}) + }) + + it('test close a tab', async function () { + const tab1 = await BrowsingContext(driver, {type: 'tab'}) + const tab2 = await BrowsingContext(driver, {type: 'tab'}) + + await tab2.close() + + assert.doesNotThrow(async function () { + await tab1.getTree() + }) + await assert.rejects(tab2.getTree(), {message: 'no such frame'}) + }) + + it('can print PDF with all valid parameters', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get("https://www.selenium.dev/selenium/web/printPage.html") + const result = await browsingContext.printPage({ + orientation: 'landscape', + scale: 1, + background: true, + width: 30, + height: 30, + top: 1, + bottom: 1, + left: 1, + right: 1, + shrinkToFit: true, + pageRanges: ['1-2'], + }) + + let base64Code = result.data.slice(0, 5) + assert.strictEqual(base64Code, 'JVBER') + }) + + it('can take box screenshot', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + const response = await browsingContext.captureBoxScreenshot(5, 5, 10, 10) + + const base64code = response.slice(0, 5) + assert.equal(base64code, 'iVBOR') + }) + + it('can take element screenshot', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get("https://www.selenium.dev/selenium/web/formPage.html") + const element = await driver.findElement(By.id('checky')) + const elementId = await element.getId() + const response = await browsingContext.captureElementScreenshot(elementId) + + const base64code = response.slice(0, 5) + assert.equal(base64code, 'iVBOR') + }) + + it('can activate a browsing context', async function () { + const id = await driver.getWindowHandle() + const window1 = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await BrowsingContext(driver, { + type: 'window', + }) + + const result = await driver.executeScript('return document.hasFocus();') + + assert.equal(result, false) + + await window1.activate() + const result2 = await driver.executeScript('return document.hasFocus();') + + assert.equal(result2, true) + }) + + it('can handle user prompt', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get("https://www.selenium.dev/selenium/web/alerts.html") + + await driver.findElement(By.id('alert')).click() + + await driver.wait(until.alertIsPresent()) + + await browsingContext.handleUserPrompt() + + const result = await driver.getTitle() + + assert.equal(result, 'Testing Alerts') + }) + + it('can accept user prompt', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get("https://www.selenium.dev/selenium/web/alerts.html") + + await driver.findElement(By.id('alert')).click() + + await driver.wait(until.alertIsPresent()) + + await browsingContext.handleUserPrompt(true) + + const result = await driver.getTitle() + + assert.equal(result, 'Testing Alerts') + }) + + it('can dismiss user prompt', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get("https://www.selenium.dev/selenium/web/alerts.html") + + await driver.findElement(By.id('alert')).click() + + await driver.wait(until.alertIsPresent()) + + await browsingContext.handleUserPrompt(false) + + const result = await driver.getTitle() + + assert.equal(result, 'Testing Alerts') + }) + + it('can pass user text to user prompt', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get("https://www.selenium.dev/selenium/web/alerts.html") + + await driver.findElement(By.id('prompt')).click() + + await driver.wait(until.alertIsPresent()) + + const userText = 'Selenium automates browsers' + + await browsingContext.handleUserPrompt(undefined, userText) + + const result = await driver.getPageSource() + assert.equal(result.includes(userText), true) + }) + + it('can accept user prompt with user text', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get("https://www.selenium.dev/selenium/web/alerts.html") + + await driver.findElement(By.id('prompt')).click() + + await driver.wait(until.alertIsPresent()) + + const userText = 'Selenium automates browsers' + + await browsingContext.handleUserPrompt(true, userText) + + const result = await driver.getPageSource() + assert.equal(result.includes(userText), true) + }) + + it('can dismiss user prompt with user text', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get("https://www.selenium.dev/selenium/web/alerts.html") + + await driver.findElement(By.id('alert')).click() + + await driver.wait(until.alertIsPresent()) + + const userText = 'Selenium automates browsers' + + await browsingContext.handleUserPrompt(false, userText) + + const result = await driver.getPageSource() + assert.equal(result.includes(userText), false) + }) + + it('can set viewport', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get("https://www.selenium.dev/selenium/web/blank.html") + + await browsingContext.setViewport(250, 300) + + const result = await driver.executeScript('return [window.innerWidth, window.innerHeight];') + assert.equal(result[0], 250) + assert.equal(result[1], 300) + }) + + it('can reload a browsing context', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + const result = await browsingContext.navigate( + 'https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html', 'complete') + + await browsingContext.reload(undefined, 'complete') + assert.notEqual(result.navigationId, null) + assert(result.url.includes('/bidi/logEntryAdded.html')) + }) + + it('can take screenshot', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + const response = await browsingContext.captureScreenshot() + const base64code = response.slice(startIndex, endIndex) + assert.equal(base64code, pngMagicNumber) + }) + + it('can traverse browser history', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await browsingContext.navigate('https://www.selenium.dev/selenium/web/formPage.html', 'complete') + + await driver.wait(until.elementLocated(By.id('imageButton'))).submit() + await driver.wait(until.titleIs('We Arrive Here'), 2500) + + await browsingContext.traverseHistory(-1) + + const source = await driver.getPageSource() + + assert.equal(source.includes('We Leave From Here'), true) + }) + + it('can navigate back in browser history', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await browsingContext.navigate('https://www.selenium.dev/selenium/web/formPage.html', 'complete') + + await driver.wait(until.elementLocated(By.id('imageButton'))).submit() + await driver.wait(until.titleIs('We Arrive Here'), 2500) + + await browsingContext.back() + + const source = await driver.getPageSource() + + assert.equal(source.includes('We Leave From Here'), true) + }) + + it('can navigate forward in browser history', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await browsingContext.navigate('https://www.selenium.dev/selenium/web/formPage.html', 'complete') + + await driver.wait(until.elementLocated(By.id('imageButton'))).submit() + await driver.wait(until.titleIs('We Arrive Here'), 2500) + + await browsingContext.back() + + const source = await driver.getPageSource() + + assert.equal(source.includes('We Leave From Here'), true) + + await browsingContext.forward() + + await driver.wait(until.titleIs('We Arrive Here'), 2500) + }); + + it.skip('Get All Top level browsing contexts', async () => { + const id = await driver.getWindowHandle() + const window1 = await BrowsingContext(driver, { + browsingContextId: id, + }) + await BrowsingContext(driver, { type: 'window' }) + const res = await window1.getTopLevelContexts() + assert.equal(res.length, 2) + }) + }) +}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/browsingContextInspector.spec.js b/examples/javascript/test/bidirectional/browsingContextInspector.spec.js new file mode 100644 index 000000000000..d542072dca87 --- /dev/null +++ b/examples/javascript/test/bidirectional/browsingContextInspector.spec.js @@ -0,0 +1,122 @@ +const {suite} = require('selenium-webdriver/testing'); +const assert = require("assert"); +const firefox = require('selenium-webdriver/firefox'); +const BrowsingContextInspector = require("selenium-webdriver/bidi/browsingContextInspector"); +const BrowsingContext = require("selenium-webdriver/bidi/browsingContext"); + +suite(function (env) { + describe('Browsing Context Inspector', function () { + let driver + + beforeEach(async function () { + driver = await env + .builder() + .setFirefoxOptions(new firefox.Options().enableBidi()) + .build() + }) + + afterEach(async function () { + await driver.quit() + }) + + it('can listen to window browsing context created event', async function () { + let contextInfo = null + const browsingContextInspector = await BrowsingContextInspector(driver) + await browsingContextInspector.onBrowsingContextCreated((entry) => { + contextInfo = entry + }) + + await driver.switchTo().newWindow('window') + const windowHandle = await driver.getWindowHandle() + assert.equal(contextInfo.id, windowHandle) + assert.equal(contextInfo.url, 'about:blank') + assert.equal(contextInfo.children, null) + assert.equal(contextInfo.parentBrowsingContext, null) + }) + + it('can listen to tab browsing context created event', async function () { + let contextInfo = null + const browsingContextInspector = await BrowsingContextInspector(driver) + await browsingContextInspector.onBrowsingContextCreated((entry) => { + contextInfo = entry + }) + + await driver.switchTo().newWindow('tab') + const tabHandle = await driver.getWindowHandle() + + assert.equal(contextInfo.id, tabHandle) + assert.equal(contextInfo.url, 'about:blank') + assert.equal(contextInfo.children, null) + assert.equal(contextInfo.parentBrowsingContext, null) + }) + + it('can listen to dom content loaded event', async function () { + const browsingContextInspector = await BrowsingContextInspector(driver) + let navigationInfo = null + await browsingContextInspector.onDomContentLoaded((entry) => { + navigationInfo = entry + }) + + const browsingContext = await BrowsingContext(driver, { + browsingContextId: await driver.getWindowHandle(), + }) + await browsingContext.navigate('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html', 'complete') + + assert.equal(navigationInfo.browsingContextId, browsingContext.id) + assert.strictEqual(navigationInfo.url.includes('/bidi/logEntryAdded.html'), true) + }) + + it('can listen to browsing context loaded event', async function () { + let navigationInfo = null + const browsingContextInspector = await BrowsingContextInspector(driver) + + await browsingContextInspector.onBrowsingContextLoaded((entry) => { + navigationInfo = entry + }) + const browsingContext = await BrowsingContext(driver, { + browsingContextId: await driver.getWindowHandle(), + }) + await browsingContext.navigate('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html', 'complete') + + assert.equal(navigationInfo.browsingContextId, browsingContext.id) + assert.strictEqual(navigationInfo.url.includes('/bidi/logEntryAdded.html'), true) + }) + + it('can listen to fragment navigated event', async function () { + let navigationInfo = null + const browsingContextInspector = await BrowsingContextInspector(driver) + + const browsingContext = await BrowsingContext(driver, { + browsingContextId: await driver.getWindowHandle(), + }) + await browsingContext.navigate('https://www.selenium.dev/selenium/web/linked_image.html', 'complete') + + await browsingContextInspector.onFragmentNavigated((entry) => { + navigationInfo = entry + }) + + await browsingContext.navigate('https://www.selenium.dev/selenium/web/linked_image.html#linkToAnchorOnThisPage', 'complete') + + assert.equal(navigationInfo.browsingContextId, browsingContext.id) + assert.strictEqual(navigationInfo.url.includes('linkToAnchorOnThisPage'), true) + }) + + it('can listen to browsing context destroyed event', async function () { + let contextInfo = null + const browsingContextInspector = await BrowsingContextInspector(driver) + await browsingContextInspector.onBrowsingContextDestroyed((entry) => { + contextInfo = entry + }) + + await driver.switchTo().newWindow('window') + + const windowHandle = await driver.getWindowHandle() + await driver.close() + + assert.equal(contextInfo.id, windowHandle) + assert.equal(contextInfo.url, 'about:blank') + assert.equal(contextInfo.children, null) + assert.equal(contextInfo.parentBrowsingContext, null) + }) + }) +}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/emulateGeoLocation.spec.js b/examples/javascript/test/bidirectional/emulateGeoLocation.spec.js new file mode 100644 index 000000000000..776a156a18e3 --- /dev/null +++ b/examples/javascript/test/bidirectional/emulateGeoLocation.spec.js @@ -0,0 +1,33 @@ +const { By, Key, Browser} = require('selenium-webdriver'); +const { suite } = require('selenium-webdriver/testing'); +const assert = require("assert"); + +suite(function(env) { + describe('Emulate geolocation', function() { + let driver; + + before(async function() { + driver = await env.builder().build(); + }); + + after(() => driver.quit()); + + it('Emulate coordinates of Tokyo', async function() { + const cdpConnection = await driver.createCDPConnection('page'); + + // Latitude and longitude of Tokyo, Japan + const coordinates = { + latitude: 35.689487, + longitude: 139.691706, + accuracy: 100, + }; + + await cdpConnection.execute( + "Emulation.setGeolocationOverride", + coordinates + ); + await driver.get("https://kawasaki-india.com/dealer-locator/"); + }); + + }); +},{ browsers: [Browser.CHROME, Browser.FIREFOX]}); \ No newline at end of file diff --git a/examples/javascript/test/bidirectional/input.spec.js b/examples/javascript/test/bidirectional/input.spec.js new file mode 100644 index 000000000000..64556fd13a63 --- /dev/null +++ b/examples/javascript/test/bidirectional/input.spec.js @@ -0,0 +1,65 @@ +const {suite} = require('selenium-webdriver/testing') +const assert = require("assert") +const firefox = require('selenium-webdriver/firefox') +const {By, Key} = require("selenium-webdriver") +const Input = require('selenium-webdriver/bidi/input') + +suite(function (env) { + describe('Input module', function () { + let driver + + beforeEach(async function () { + driver = await env + .builder() + .setFirefoxOptions(new firefox.Options().enableBidi()) + .build() + }) + + afterEach(async function () { + await driver.quit() + }) + + it('can perform input action', async function () { + const browsingContextId = await driver.getWindowHandle() + const input = await Input(driver) + await driver.get('https://www.selenium.dev/selenium/web/formSelectionPage.html') + + let options = await driver.findElements(By.tagName('option')) + + const actions = driver.actions().click(options[1]).keyDown(Key.SHIFT).click(options[3]).keyUp(Key.SHIFT).getSequences() + + await input.perform(browsingContextId, actions) + + let showButton = await driver.findElement(By.name('showselected')) + showButton.click() + + let resultElement = await driver.findElement(By.id('result')) + await resultElement.getText().then(function (text) { + assert(text.includes('oquefort parmigiano cheddar')) + }) + }) + + it('can execute release in browsing context', async function () { + const browsingContextId = await driver.getWindowHandle() + const input = await Input(driver) + await driver.get('https://www.selenium.dev/selenium/web/bidi/release_action.html') + + let inputTextBox = await driver.findElement(By.id('keys')) + + await driver.executeScript('arguments[0].focus()', inputTextBox) + + const actions = await driver.actions().keyDown('a').keyDown('b').getSequences() + + await input.perform(browsingContextId, actions) + + await driver.executeScript('resetEvents()') + + await input.release(browsingContextId) + + const events = await driver.executeScript('return allEvents.events') + + assert.strictEqual(events[0].code, 'KeyB') + assert.strictEqual(events[1].code, 'KeyA') + }) + }) +}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/locateNodes.spec.js b/examples/javascript/test/bidirectional/locateNodes.spec.js new file mode 100644 index 000000000000..53818c26c332 --- /dev/null +++ b/examples/javascript/test/bidirectional/locateNodes.spec.js @@ -0,0 +1,245 @@ +const {suite} = require('selenium-webdriver/testing'); +const assert = require("assert"); +const firefox = require('selenium-webdriver/firefox'); +const {BrowsingContext} = require("selenium-webdriver"); +const {Locator} = require("selenium-webdriver/bidi/browsingContext"); +const {LocalValue} = require("selenium-webdriver/bidi/protocolValue"); +const {ArgumentValue} = require("selenium-webdriver/bidi/argumentValue"); + +suite(function (env) { + describe('Locate Nodes', function () { + let driver + + beforeEach(async function () { + driver = await env + .builder() + .setFirefoxOptions(new firefox.Options().enableBidi()) + .build() + }) + + afterEach(async function () { + await driver.quit() + }) + + xit('can locate nodes', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + + const element = await browsingContext.locateNodes(Locator.css('div')) + assert.strictEqual(element.length, 13) + }) + + xit('can locate node', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + + const element = await browsingContext.locateNode(Locator.css('div')) + assert.strictEqual(element.type, 'node') + }) + + xit('can locate node with css locator', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + + const elements = await browsingContext.locateNodes(Locator.css('div.extraDiv, div.content'), 1) + const element = elements[0] + assert.strictEqual(element.type, 'node') + assert.notEqual(element.value, undefined) + assert.strictEqual(element.value.localName, 'div') + assert.strictEqual(element.value.attributes.class, 'content') + assert.notEqual(element.sharedId, undefined) + }) + + xit('can locate node with xpath locator', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + const elements = await browsingContext.locateNodes(Locator.xpath('/html/body/div[2]'), 1) + + const element = elements[0] + assert.strictEqual(element.type, 'node') + assert.notEqual(element.value, undefined) + assert.strictEqual(element.value.localName, 'div') + assert.strictEqual(element.value.attributes.class, 'content') + assert.notEqual(element.sharedId, undefined) + }) + + xit('can locate node with inner test locator', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + const elements = await browsingContext.locateNodes(Locator.innerText('Spaced out'), 1) + + const element = elements[0] + assert.strictEqual(element.type, 'node') + assert.notEqual(element.value, undefined) + assert.strictEqual(element.value.localName, 'div') + assert.strictEqual(element.value.attributes.class, 'content') + assert.notEqual(element.sharedId, undefined) + }) + + xit('can locate node with max node count', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + + const elements = await browsingContext.locateNodes(Locator.css('div'), 4) + assert.strictEqual(elements.length, 4) + }) + + xit('can locate node with none ownership value', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + + const elements = await browsingContext.locateNodes(Locator.css('div'), undefined, 'none') + assert.strictEqual(elements.length, 13) + assert.strictEqual(elements[0].handle, null) + }) + + xit('can locate node with root ownership value', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + + const elements = await browsingContext.locateNodes(Locator.css('div'), undefined, 'root') + assert.strictEqual(elements.length, 13) + assert.notEqual(elements[0].handle, null) + }) + + xit('can locate node with given start nodes', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get(Pages.formPage) + + const script = await ScriptManager(id, driver) + + const result = await script.evaluateFunctionInBrowsingContext( + id, + "document.querySelectorAll('form')", + false, + 'root', + ) + + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.notEqual(result.realmId, null) + assert.equal(result.result.type, 'nodelist') + + const value = result.result.value + + const startNodes = [] + + value.forEach((node) => { + startNodes.push(new ReferenceValue(node.handle, node.sharedId)) + }) + + const elements = await browsingContext.locateNodes( + Locator.css('input'), + 50, + 'none', + undefined, + undefined, + startNodes, + ) + + assert.strictEqual(elements.length, 35) + }) + + xit('can locate nodes in a given sandbox', async function () { + const sandbox = 'sandbox' + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await browsingContext.navigate('https://www.selenium.dev/selenium/web/xhtmlTest.html', 'complete') + + const elements = await browsingContext.locateNodes(Locator.css('div'), 1, undefined, sandbox) + + assert.strictEqual(elements.length, 1) + + const nodeId = elements[0].sharedId + + const script = await ScriptManager(id, driver) + + let argumentValues = [] + let mapValue = { sharedId: LocalValue.createStringValue(nodeId) } + argumentValues.push(new ArgumentValue(LocalValue.createMapValue(mapValue))) + + const response = await script.callFunctionInBrowsingContext( + id, + 'function(){ return arguments[0]; }', + false, + argumentValues, + undefined, + undefined, + sandbox, + ) + + assert.equal(response.resultType, EvaluateResultType.SUCCESS) + assert.equal(response.result.type, 'map') + + const sharedId = response.result.value.sharedId + + assert.strictEqual(sharedId.value, nodeId) + }) + + xit('can find element', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + + const element = await browsingContext.locateElement(Locator.css('p')) + const elementText = await element.getText() + assert.strictEqual(elementText, 'Open new window') + }) + + xit('can find elements', async function () { + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await driver.get('https://www.selenium.dev/selenium/web/xhtmlTest.html') + + const elements = await browsingContext.locateElements(Locator.css('div')) + assert.strictEqual(elements.length, 13) + + const elementText = await elements[0].getText() + assert.strictEqual(elementText.includes('Open new window'), true) + }) + }) +}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/network_commands.spec.js b/examples/javascript/test/bidirectional/network_commands.spec.js new file mode 100644 index 000000000000..9be1942d0986 --- /dev/null +++ b/examples/javascript/test/bidirectional/network_commands.spec.js @@ -0,0 +1,82 @@ +const {suite} = require('selenium-webdriver/testing') +const assert = require("assert") +const firefox = require('selenium-webdriver/firefox') +const Network = require('selenium-webdriver/bidi/network') +const {until, By} = require('selenium-webdriver') +const {AddInterceptParameters} = require("selenium-webdriver/bidi/addInterceptParameters"); +const {InterceptPhase} = require("selenium-webdriver/bidi/interceptPhase"); + +suite(function (env) { + describe('Network commands', function () { + let driver + let network + + beforeEach(async function () { + driver = await env + .builder() + .setFirefoxOptions(new firefox.Options().enableBidi()) + .build() + + network = await Network(driver) + }) + + afterEach(async function () { + await network.close() + await driver.quit() + }) + + xit('can add intercept', async function () { + const intercept = await network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)) + assert.notEqual(intercept, null) + }) + + xit('can remove intercept', async function () { + const network = await Network(driver) + const intercept = await network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)) + assert.notEqual(intercept, null) + + await network.removeIntercept(intercept) + }) + + xit('can continue with auth credentials ', async function () { + await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)) + + await network.authRequired(async (event) => { + await network.continueWithAuth(event.request.request, 'admin','admin') + }) + await driver.get('https://the-internet.herokuapp.com/basic_auth') + + const successMessage = 'Congratulations! You must have the proper credentials.' + + let elementMessage = await driver.findElement(By.tagName('p')).getText() + assert.equal(elementMessage, successMessage) + }) + + xit('can continue without auth credentials ', async function () { + await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)) + + await network.authRequired(async (event) => { + await network.continueWithAuthNoCredentials(event.request.request) + }) + + await driver.get('https://the-internet.herokuapp.com/basic_auth') + const alert = await driver.wait(until.alertIsPresent()) + await alert.dismiss() + + let source = await driver.getPageSource() + assert.equal(source.includes('Not authorized'), true) + }) + + xit('can cancel auth ', async function () { + await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)) + + await network.authRequired(async (event) => { + await network.cancelAuth(event.request.request) + }) + + await driver.get('https://the-internet.herokuapp.com/basic_auth') + let source = await driver.getPageSource() + assert.equal(source.includes('Not authorized'), true) + }) + }) +}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/network_events.spec.js b/examples/javascript/test/bidirectional/network_events.spec.js new file mode 100644 index 000000000000..7f5a09b15427 --- /dev/null +++ b/examples/javascript/test/bidirectional/network_events.spec.js @@ -0,0 +1,111 @@ +const {suite} = require('selenium-webdriver/testing'); +const assert = require("assert"); +const firefox = require('selenium-webdriver/firefox'); +const Network = require("selenium-webdriver/bidi/network"); +const {until} = require("selenium-webdriver"); + +suite(function (env) { + describe('Network events', function () { + let driver + + beforeEach(async function () { + driver = await env + .builder() + .setFirefoxOptions(new firefox.Options().enableBidi()) + .build() + }) + + afterEach(async function () { + await driver.quit() + }) + + it('can listen to event before request is sent', async function () { + let beforeRequestEvent = null + const network = await Network(driver) + await network.beforeRequestSent(function (event) { + beforeRequestEvent = event + }) + + await driver.get('https://www.selenium.dev/selenium/web/blank.html') + + assert.equal(beforeRequestEvent.request.method, 'GET') + const url = beforeRequestEvent.request.url + assert.equal(url, await driver.getCurrentUrl()) + }) + + it('can request cookies', async function () { + const network = await Network(driver) + let beforeRequestEvent = null + await network.beforeRequestSent(function (event) { + beforeRequestEvent = event + }) + + await driver.get('https://www.selenium.dev/selenium/web/blank.html') + await driver.manage().addCookie({ + name: 'north', + value: 'biryani', + }) + await driver.navigate().refresh() + + assert.equal(beforeRequestEvent.request.method, 'GET') + assert.equal(beforeRequestEvent.request.cookies[0].name, 'north') + assert.equal(beforeRequestEvent.request.cookies[0].value.value, 'biryani') + const url = beforeRequestEvent.request.url + assert.equal(url, await driver.getCurrentUrl()) + + await driver.manage().addCookie({ + name: 'south', + value: 'dosa', + }) + await driver.navigate().refresh() + + assert.equal(beforeRequestEvent.request.cookies[1].name, 'south') + assert.equal(beforeRequestEvent.request.cookies[1].value.value, 'dosa') + }) + + it('can redirect http equiv', async function () { + let beforeRequestEvent = [] + const network = await Network(driver) + await network.beforeRequestSent(function (event) { + beforeRequestEvent.push(event) + }) + + await driver.get('http://www.selenium.dev/selenium/web/bidi/redirected_http_equiv.html') + await driver.wait(until.urlContains('redirected.html'), 1000) + + assert.equal(beforeRequestEvent[0].request.method, 'GET') + assert(beforeRequestEvent[0].request.url.includes('redirected_http_equiv.html')) + assert.equal(beforeRequestEvent[2].request.method, 'GET') + assert(beforeRequestEvent[2].request.url.includes('redirected.html')) + }) + + it('can subscribe to response started', async function () { + let onResponseStarted = [] + const network = await Network(driver) + await network.responseStarted(function (event) { + onResponseStarted.push(event) + }) + + await driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + + assert.equal(onResponseStarted[0].request.method, 'GET') + assert.equal(onResponseStarted[0].request.url, await driver.getCurrentUrl()) + assert.equal(onResponseStarted[0].response.url, await driver.getCurrentUrl()) + }) + + it('can subscribe to response completed', async function () { + let onResponseCompleted = [] + const network = await Network(driver) + await network.responseCompleted(function (event) { + onResponseCompleted.push(event) + }) + + await driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html') + + assert.equal(onResponseCompleted[0].request.method, 'GET') + assert.equal(onResponseCompleted[0].request.url, await driver.getCurrentUrl()) + assert.equal(onResponseCompleted[0].response.fromCache, false) + assert.equal(onResponseCompleted[0].response.status, 200) + }) + }) +}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/script_commands.spec.js b/examples/javascript/test/bidirectional/script_commands.spec.js new file mode 100644 index 000000000000..b8ce14bf5ca8 --- /dev/null +++ b/examples/javascript/test/bidirectional/script_commands.spec.js @@ -0,0 +1,478 @@ +const {suite} = require('selenium-webdriver/testing') +const assert = require("assert") +const firefox = require('selenium-webdriver/firefox') +const {By, until} = require("selenium-webdriver") +const ScriptManager = require('selenium-webdriver/bidi/scriptManager') +const {ResultOwnership} = require("selenium-webdriver/bidi/resultOwnership"); +const {ArgumentValue} = require("selenium-webdriver/bidi/argumentValue"); +const {LocalValue, RemoteReferenceType, ReferenceValue} = require("selenium-webdriver/bidi/protocolValue"); +const {EvaluateResultType} = require("selenium-webdriver/bidi/evaluateResult"); +const BrowsingContext = require("selenium-webdriver/bidi/browsingContext"); +const {WebDriverError} = require("selenium-webdriver/lib/error"); +const {RealmType} = require("selenium-webdriver/bidi/realmInfo"); +const LogInspector = require("selenium-webdriver/bidi/logInspector"); + +suite(function (env) { + describe('Script commands', function () { + let driver + + beforeEach(async function () { + driver = await env + .builder() + .setFirefoxOptions(new firefox.Options().enableBidi()) + .build() + }) + + afterEach(async function () { + await driver.quit() + }) + + it('can call function', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + let argumentValues = [] + let value = new ArgumentValue(LocalValue.createNumberValue(22)) + argumentValues.push(value) + + let mapValue = {some_property: LocalValue.createNumberValue(42)} + let thisParameter = new ArgumentValue(LocalValue.createObjectValue(mapValue)).asMap() + + const result = await manager.callFunctionInBrowsingContext( + id, + 'function processWithPromise(argument) {' + + 'return new Promise((resolve, reject) => {' + + 'setTimeout(() => {' + + 'resolve(argument + this.some_property);' + + '}, 1000)' + + '})' + + '}', + true, + argumentValues, + thisParameter, + ResultOwnership.ROOT) + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.equal(result.result.value, 64) + }) + + it('can call function with declaration', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const result = await manager.callFunctionInBrowsingContext(id, '()=>{return 1+2;}', false) + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.equal(result.result.value, 3) + }) + + it('can call function to get element', async function () { + await driver.get('https://www.selenium.dev/selenium/web/bidi/logEntryAdded') + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const result = await manager.callFunctionInBrowsingContext( + id, + '() => document.getElementById("consoleLog")', + false, + ) + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.notEqual(result.realmId, null) + assert.equal(result.result.type, 'node') + assert.notEqual(result.result.value, null) + assert.notEqual(result.result.value.nodeType, null) + }) + + it('can call function with arguments', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + let argumentValues = [] + let value1 = new ArgumentValue(LocalValue.createStringValue('ARGUMENT_STRING_VALUE')) + let value2 = new ArgumentValue(LocalValue.createNumberValue(42)) + argumentValues.push(value1) + argumentValues.push(value2) + + const result = await manager.callFunctionInBrowsingContext( + id, + '(...args)=>{return args}', + false, + argumentValues, + ) + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.equal(result.result.value.length, 2) + }) + + it('can call function with await promise', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const result = await manager.callFunctionInBrowsingContext( + id, + 'async function() {{\n' + + ' await new Promise(r => setTimeout(() => r(), 0));\n' + + ' return "SOME_DELAYED_RESULT";\n' + + ' }}', + true, + ) + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.equal(result.result.value, 'SOME_DELAYED_RESULT') + }) + + it('can call function with await promise false', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const result = await manager.callFunctionInBrowsingContext( + id, + 'async function() {{\n' + + ' await new Promise(r => setTimeout(() => r(), 0));\n' + + ' return "SOME_DELAYED_RESULT";\n' + + ' }}', + false, + ) + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.equal(result.result.type, 'promise') + }) + + it('can call function with this parameter', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + let mapValue = {some_property: LocalValue.createNumberValue(42)} + let thisParameter = new ArgumentValue(LocalValue.createObjectValue(mapValue)).asMap() + + const result = await manager.callFunctionInBrowsingContext( + id, + 'function(){return this.some_property}', + false, + null, + thisParameter, + ) + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.equal(result.result.value, 42) + }) + + it('can call function with ownership root', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const result = await manager.callFunctionInBrowsingContext( + id, + 'async function(){return {a:1}}', + true, + null, + null, + ResultOwnership.ROOT, + ) + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + }) + + it('can call function with ownership none', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const result = await manager.callFunctionInBrowsingContext( + id, + 'async function(){return {a:1}}', + true, + null, + null, + ResultOwnership.NONE, + ) + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.notEqual(result.realmId, null) + assert.equal(result.result.handle, undefined) + assert.notEqual(result.result.value, null) + }) + + it('can call function that throws exception', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const result = await manager.callFunctionInBrowsingContext(id, '))) !!@@## some invalid JS script (((', false) + assert.equal(result.resultType, EvaluateResultType.EXCEPTION) + + assert.equal(result.exceptionDetails.exception.type, 'error') + assert.equal(result.exceptionDetails.text, "SyntaxError: expected expression, got ')'") + assert.equal(result.exceptionDetails.columnNumber, 39) + assert.equal(result.exceptionDetails.stackTrace.callFrames.length, 0) + }) + + it('can call function in a sandbox', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + await manager.callFunctionInBrowsingContext(id, '() => { window.foo = 2; }', true, null, null, null, 'sandbox') + + const resultInSandbox = await manager.callFunctionInBrowsingContext( + id, + '() => window.foo', + true, + null, + null, + null, + 'sandbox', + ) + + assert.equal(resultInSandbox.resultType, EvaluateResultType.SUCCESS) + }) + + it('can call function in a realm', async function () { + const firstTab = await driver.getWindowHandle() + await driver.switchTo().newWindow('tab') + const manager = await ScriptManager(firstTab, driver) + + const realms = await manager.getAllRealms() + const realmId = realms[0].realmId + + await manager.callFunctionInRealm(realmId, '() => { window.foo = 3; }', true) + + const result = await manager.callFunctionInRealm(realmId, '() => window.foo', true) + + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.equal(result.result.value, 3) + }) + + it('can evaluate script', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const result = await manager.evaluateFunctionInBrowsingContext(id, '1 + 2', true) + + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.equal(result.result.value, 3) + }) + + it('can evaluate script that throws exception', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const result = await manager.evaluateFunctionInBrowsingContext( + id, + '))) !!@@## some invalid JS script (((', + false, + ) + + assert.equal(result.resultType, EvaluateResultType.EXCEPTION) + assert.equal(result.exceptionDetails.exception.type, 'error') + assert.equal(result.exceptionDetails.text, "SyntaxError: expected expression, got ')'") + assert.equal(result.exceptionDetails.columnNumber, 39) + assert.equal(result.exceptionDetails.stackTrace.callFrames.length, 0) + }) + + it('can evaluate script with result ownership', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const result = await manager.evaluateFunctionInBrowsingContext( + id, + 'Promise.resolve({a:1})', + true, + ResultOwnership.ROOT, + ) + + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.notEqual(result.result.handle, null) + }) + + it('can evaluate in a sandbox', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + await manager.evaluateFunctionInBrowsingContext(id, 'window.foo = 2', true, null, 'sandbox') + + const resultInSandbox = await manager.evaluateFunctionInBrowsingContext(id, 'window.foo', true, null, 'sandbox') + + assert.equal(resultInSandbox.resultType, EvaluateResultType.SUCCESS) + assert.equal(resultInSandbox.result.value, 2) + }) + + it('can evaluate in a realm', async function () { + const firstTab = await driver.getWindowHandle() + await driver.switchTo().newWindow('tab') + const manager = await ScriptManager(firstTab, driver) + + const realms = await manager.getAllRealms() + const realmId = realms[0].realmId + + await manager.evaluateFunctionInRealm(realmId, 'window.foo = 3', true) + + const result = await manager.evaluateFunctionInRealm(realmId, 'window.foo', true) + + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.equal(result.result.value, 3) + }) + + it('can disown handles', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const browsingContext = await BrowsingContext(driver, {browsingContextId: id}) + + const info = await browsingContext.navigate( + 'https://www.selenium.dev/selenium/web/dynamic.html', + 'complete' + ) + + await driver.findElement(By.id('adder')).click() + + await driver.wait(until.elementLocated(By.id('box0')), 10000) + + const evaluateResult = await manager.evaluateFunctionInBrowsingContext( + id, + "document.querySelector('.redbox');", + false, + ResultOwnership.ROOT, + ) + + assert.equal(evaluateResult.resultType, EvaluateResultType.SUCCESS) + let boxId = evaluateResult.result.handle + + await manager.disownBrowsingContextScript(id, boxId) + + await manager.callFunctionInBrowsingContext(id, 'arg => arg.a', false).catch((error) => { + assert(error instanceof WebDriverError) + }) + }) + + it('can disown handles in realm', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const browsingContext = await BrowsingContext(driver, {browsingContextId: id}) + + const info = await browsingContext.navigate( + 'https://www.selenium.dev/selenium/web/dynamic.html', + 'complete' + ) + + await driver.findElement(By.id('adder')).click() + + await driver.wait(until.elementLocated(By.id('box0')), 10000) + + const realms = await manager.getAllRealms() + const realmId = realms[0].realmId + + const evaluateResult = await manager.evaluateFunctionInBrowsingContext( + id, + "document.querySelector('.redbox');", + false, + ResultOwnership.ROOT, + ) + + assert.equal(evaluateResult.resultType, EvaluateResultType.SUCCESS) + let boxId = evaluateResult.result.handle + + let argumentValues = [] + let value1 = new ArgumentValue(new ReferenceValue(RemoteReferenceType.HANDLE, boxId)) + argumentValues.push(value1) + let checkHandle = await manager.callFunctionInBrowsingContext(id, 'arg => arg.a', false, argumentValues) + + assert.equal(checkHandle.resultType, EvaluateResultType.SUCCESS) + + await manager.disownRealmScript(realmId, boxId) + + await manager.callFunctionInBrowsingContext(id, 'arg => arg.a', false).catch((error) => { + assert(error instanceof WebDriverError) + }) + }) + + it('can get all realms', async function () { + const firstWindow = await driver.getWindowHandle() + await driver.switchTo().newWindow('window') + const secondWindow = await driver.getWindowHandle() + const manager = await ScriptManager(firstWindow, driver) + + const realms = await manager.getAllRealms() + assert.equal(realms.length, 2) + }) + + it('can get realm by type', async function () { + const firstWindow = await driver.getWindowHandle() + await driver.switchTo().newWindow('window') + const secondWindow = await driver.getWindowHandle() + const manager = await ScriptManager(firstWindow, driver) + + const realms = await manager.getRealmsByType(RealmType.WINDOW) + assert.equal(realms.length, 2) + }) + + it('can get realm in browsing context', async function () { + const windowId = await driver.getWindowHandle() + await driver.switchTo().newWindow('tab') + const tabId = await driver.getWindowHandle() + const manager = await ScriptManager(windowId, driver) + + const realms = await manager.getRealmsInBrowsingContext(tabId) + + const tabRealm = realms[0] + assert.equal(tabRealm.realmType, RealmType.WINDOW) + }) + + it('can get realm in browsing context by type', async function () { + const windowId = await driver.getWindowHandle() + await driver.switchTo().newWindow('tab') + const manager = await ScriptManager(windowId, driver) + + const realms = await manager.getRealmsInBrowsingContextByType(windowId, RealmType.WINDOW) + + const windowRealm = realms[0] + assert.equal(windowRealm.realmType, RealmType.WINDOW) + }) + + it('can add preload script', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const scriptId = await manager.addPreloadScript('() => {{ console.log(\'{preload_script_console_text}\') }}') + + let logEntry = null + const inspector = await LogInspector(driver) + await inspector.onConsoleEntry(function (log) { + logEntry = log + }) + + await driver.get('https://www.selenium.dev/selenium/blank') + + assert.equal(logEntry.text, '{preload_script_console_text}') + }) + + it('can add preload script to sandbox', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + await manager.addPreloadScript('() => { window.bar = 2; }', undefined, 'sandbox') + + await driver.get('https://www.selenium.dev/selenium/blank') + + let result_in_sandbox = await manager.evaluateFunctionInBrowsingContext( + id, + 'window.bar', + true, + null, + 'sandbox', + ) + + assert.equal(result_in_sandbox.result.type, 'number') + assert.equal(result_in_sandbox.result.value, 2) + }) + + it('can remove preload script', async function () { + const id = await driver.getWindowHandle() + const manager = await ScriptManager(id, driver) + + const scriptId = await manager.addPreloadScript('() => {{ console.log(\'{preload_script_console_text}\') }}') + + let logEntry = null + const inspector = await LogInspector(driver) + await inspector.onConsoleEntry(function (log) { + logEntry = log + }) + + await manager.removePreloadScript(scriptId) + + await driver.get('https://www.selenium.dev/selenium/blank') + + assert.equal(logEntry, null) + }) + }) +}, {browsers: ['firefox']}) diff --git a/examples/javascript/test/bidirectional/script_events.spec.js b/examples/javascript/test/bidirectional/script_events.spec.js new file mode 100644 index 000000000000..3d3411387ce9 --- /dev/null +++ b/examples/javascript/test/bidirectional/script_events.spec.js @@ -0,0 +1,93 @@ +const {suite} = require('selenium-webdriver/testing') +const assert = require("assert") +const firefox = require('selenium-webdriver/firefox') +const {ScriptManager, BrowsingContext} = require("selenium-webdriver") +const {ArgumentValue} = require("selenium-webdriver/bidi/argumentValue") +const {RealmType} = require("selenium-webdriver/bidi/realmInfo") +const {LocalValue, ChannelValue} = require("selenium-webdriver/bidi/protocolValue") +const {EvaluateResultType} = require("selenium-webdriver/bidi/evaluateResult"); + +suite(function (env) { + describe('Script events', function () { + let driver + + beforeEach(async function () { + driver = await env + .builder() + .setFirefoxOptions(new firefox.Options().enableBidi()) + .build() + }) + + afterEach(async function () { + await driver.quit() + }) + + it('can listen to channel message', async function () { + const manager = await ScriptManager(undefined, driver) + + let message = null + + await manager.onMessage((m) => { + message = m + }) + + let argumentValues = [] + let value = new ArgumentValue(LocalValue.createChannelValue(new ChannelValue('channel_name'))) + argumentValues.push(value) + + const result = await manager.callFunctionInBrowsingContext( + await driver.getWindowHandle(), + '(channel) => channel("foo")', + false, + argumentValues, + ) + assert.equal(result.resultType, EvaluateResultType.SUCCESS) + assert.notEqual(message, null) + assert.equal(message.channel, 'channel_name') + assert.equal(message.data.type, 'string') + assert.equal(message.data.value, 'foo') + }) + + it('can listen to realm created message', async function () { + const manager = await ScriptManager(undefined, driver) + + let realmInfo = null + + await manager.onRealmCreated((result) => { + realmInfo = result + }) + + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await browsingContext.navigate('https://www.selenium.dev/selenium/web/blank', 'complete') + + assert.notEqual(realmInfo, null) + assert.notEqual(realmInfo.realmId, null) + assert.equal(realmInfo.realmType, RealmType.WINDOW) + }) + + xit('can listen to realm destroyed message', async function () { + const manager = await ScriptManager(undefined, driver) + + let realmInfo = null + + await manager.onRealmDestroyed((result) => { + realmInfo = result + }) + + const id = await driver.getWindowHandle() + const browsingContext = await BrowsingContext(driver, { + browsingContextId: id, + }) + + await browsingContext.close() + + assert.notEqual(realmInfo, null) + assert.notEqual(realmInfo.realmId, null) + assert.equal(realmInfo.realmType, RealmType.WINDOW) + }) + }) +}, {browsers: ['firefox']}) diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.en.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.en.md new file mode 100644 index 000000000000..6e7cbe79eebb --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.en.md @@ -0,0 +1,21 @@ +--- +title: "BiDirectional API (W3C compliant)" +linkTitle: "W3C" +weight: 16 +description: > + Examples of working with Chrome DevTools Protocol in Selenium. + CDP support is temporary until WebDriver BiDi has been implemented. +aliases: [ +"/documentation/en/webdriver/bidirectional/bidirectional_w3c", +"/documentation/en/webdriver/bidi_apis/bidi_w3c", +"/documentation/webdriver/bidi_apis/bidi_w3c" +] +--- + +The following list of APIs will be growing as the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) grows +and browser vendors implement the same. +Additionally, Selenium will try to support real-world use cases that internally use a combination of W3C BiDi protocol APIs. + +If there is additional functionality you'd like to see, please raise a +[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). + diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.ja.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.ja.md new file mode 100644 index 000000000000..dde7e33f7a77 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.ja.md @@ -0,0 +1,25 @@ +--- +title: "BiDirectional API (W3C compliant)" +linkTitle: "BiDi API (W3C compliant)" +weight: 16 +aliases: [ +"/documentation/ja/webdriver/bidi_apis/bidi_w3c", +"/ja/documentation/webdriver/bidi_apis/bidi_w3c" +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from English to Japanese. + Do you speak Japanese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +The following list of APIs will be growing as the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) grows +and browser vendors implement the same. +Additionally, Selenium will try to support real-world use cases that internally use a combination of W3C BiDi protocol APIs. + +If there is additional functionality you'd like to see, please raise a +[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.pt-br.md new file mode 100644 index 000000000000..afedb63de712 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.pt-br.md @@ -0,0 +1,25 @@ +--- +title: "BiDirectional API (W3C compliant)" +linkTitle: "BiDi API (W3C compliant)" +weight: 16 +aliases: [ +"/documentation/pt-br/webdriver/bidi_apis/bidi_w3c", +"/pt-br/documentation/webdriver/bidi_apis/bidi_w3c" +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Portuguese. Do you speak Portuguese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +The following list of APIs will be growing as the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) grows +and browser vendors implement the same. +Additionally, Selenium will try to support real-world use cases that internally use a combination of W3C BiDi protocol APIs. + +If there is additional functionality you'd like to see, please raise a +[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.zh-cn.md new file mode 100644 index 000000000000..70e97c54bc5c --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/_index.zh-cn.md @@ -0,0 +1,16 @@ +--- +title: "BiDirectional API (W3C compliant)" +linkTitle: "BiDi API (W3C compliant)" +weight: 16 +aliases: [ +"/documentation/zh-cn/webdriver/bidi_apis/bidi_w3c", +"/zh-cn/documentation/webdriver/bidi_apis/bidi_w3c" +] +--- + +The following list of APIs will be growing as the [WebDriver BiDirectional Protocol](https://w3c.github.io/webdriver-bidi/) grows +and browser vendors implement the same. +Additionally, Selenium will try to support real-world use cases that internally use a combination of W3C BiDi protocol APIs. + +If there is additional functionality you'd like to see, please raise a +[feature request](https://github.com/SeleniumHQ/selenium/issues/new?assignees=&labels=&template=feature.md). \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md new file mode 100644 index 000000000000..97e0ac72c185 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md @@ -0,0 +1,598 @@ +--- +title: "Browsing Context" +linkTitle: "Browsing Context" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/browsing_context", +] +--- + +## Commands +This section contains the APIs related to browsing context commands. + +### Open a new window + +Creates a new browsing context in a new window. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L44-L47" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L35-L37" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Open a new tab + +Creates a new browsing context in a new tab. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L58-L61" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L50-L52" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Use existing window handle + +Creates a browsing context for the existing tab/window to run commands. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L37-L41" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L27-L30" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Open a window with a reference browsing context +A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). +The API allows to pass the reference browsing context, which is used to create a new window. The implementation is operating system specific. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L50-L55" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L42-L45" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Open a tab with a reference browsing context +A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). +The API allows to pass the reference browsing context, which is used to create a new tab. The implementation is operating system specific. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L64-L69" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L57-L60" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate to a URL + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L72-L80" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L69" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate to a URL with readiness state + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L83-L92" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L81-L84" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context tree + +Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L95-L108" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L92-L98" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context tree with depth + +Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context upto the depth value passed. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L111-L123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L105-L111" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get All Top level browsing contexts + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L126-L133" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.20.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L428-L433" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Close a tab/window + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L136-L153" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L117-L120" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Activate a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L157-L161" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L194-L206" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Reload a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L169-L173" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L353-L353" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Handle user prompt + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L220-L228" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L303" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L248-L252" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L364-L364" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Viewport Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L259-L268" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L167-L171" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Element Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L275-L280" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L186" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Set Viewport + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L304-L307" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L337" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Print page + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L317-L322" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L147-L159" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate back + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L330-L336" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L398-L398" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate forward + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L342-L352" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L422-L422" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Traverse history + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L359-L365" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L380-L380" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events +This section contains the APIs related to browsing context events. + +### Browsing Context Created Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L34-L41" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L24-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Dom Content loaded Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L54-L63" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L54-L63" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Browsing Context Loaded Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L81-88" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L71-L79" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigated Started Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L97-104" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Fragment Navigated Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L87-L98" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### User Prompt Opened Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### User Prompt Closed Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L150-163" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Browsing Context Destroyed Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L170-L181" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#106-L114" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md new file mode 100644 index 000000000000..0062fd79087b --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md @@ -0,0 +1,604 @@ +--- +title: "Browsing Context" +linkTitle: "Browsing Context" +weight: 1 +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Japanese. Do you speak Japanese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +## Commands +This section contains the APIs related to browsing context commands. + +### Open a new window + +Creates a new browsing context in a new window. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L44-L47" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L35-L37" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Open a new tab + +Creates a new browsing context in a new tab. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L58-L61" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L50-L52" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Use existing window handle + +Creates a browsing context for the existing tab/window to run commands. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L37-L41" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L27-L30" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Open a window with a reference browsing context +A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). +The API allows to pass the reference browsing context, which is used to create a new window. The implementation is operating system specific. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L50-L55" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L42-L45" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Open a tab with a reference browsing context +A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). +The API allows to pass the reference browsing context, which is used to create a new tab. The implementation is operating system specific. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L64-L69" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L57-L60" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate to a URL + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L72-L80" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L69" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate to a URL with readiness state + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L83-L92" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L81-L84" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context tree + +Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L95-L108" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L92-L98" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context tree with depth + +Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context upto the depth value passed. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L111-L123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L105-L111" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get All Top level browsing contexts + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L126-L133" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.20.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L428-L433" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Close a tab/window + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L136-L153" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L117-L120" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Activate a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L157-L161" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L194-L206" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Reload a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L169-L173" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L353-L353" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Handle user prompt + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L220-L228" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L303" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L248-L252" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L364-L364" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Viewport Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L259-L268" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L167-L171" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Element Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L275-L280" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L186" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Set Viewport + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L304-L307" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L337" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Print page + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L317-L322" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L147-L159" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate back + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L330-L336" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L398-L398" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate forward + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L342-L352" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L422-L422" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Traverse history + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L359-L365" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L380-L380" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events +This section contains the APIs related to browsing context events. + +### Browsing Context Created Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L34-L41" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L24-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Dom Content loaded Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L54-L63" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L54-L63" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Browsing Context Loaded Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L81-88" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L71-L79" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigated Started Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L97-104" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Fragment Navigated Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L87-L98" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### User Prompt Opened Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### User Prompt Closed Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L150-163" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Browsing Context Destroyed Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L170-L181" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#106-L114" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md new file mode 100644 index 000000000000..188703feb2b8 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md @@ -0,0 +1,604 @@ +--- +title: "Browsing Context" +linkTitle: "Browsing Context" +weight: 1 +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Portuguese. Do you speak Portuguese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +## Commands +This section contains the APIs related to browsing context commands. + +### Open a new window + +Creates a new browsing context in a new window. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L44-L47" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L35-L37" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Open a new tab + +Creates a new browsing context in a new tab. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L58-L61" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L50-L52" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Use existing window handle + +Creates a browsing context for the existing tab/window to run commands. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L37-L41" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L27-L30" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Open a window with a reference browsing context +A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). +The API allows to pass the reference browsing context, which is used to create a new window. The implementation is operating system specific. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L50-L55" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L42-L45" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Open a tab with a reference browsing context +A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). +The API allows to pass the reference browsing context, which is used to create a new tab. The implementation is operating system specific. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L64-L69" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L57-L60" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate to a URL + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L72-L80" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L69" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate to a URL with readiness state + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L83-L92" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L81-L84" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context tree + +Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L95-L108" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L92-L98" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context tree with depth + +Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context upto the depth value passed. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L111-L123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L105-L111" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get All Top level browsing contexts + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L126-L133" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.20.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L428-L433" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Close a tab/window + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L136-L153" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L117-L120" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Activate a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L157-L161" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L194-L206" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Reload a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L169-L173" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L353-L353" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Handle user prompt + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L220-L228" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L303" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L248-L252" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L364-L364" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Viewport Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L259-L268" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L167-L171" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Element Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L275-L280" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L186" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Set Viewport + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L304-L307" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L337" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Print page + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L317-L322" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L147-L159" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate back + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L330-L336" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L398-L398" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate forward + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L342-L352" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L422-L422" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Traverse history + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L359-L365" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L380-L380" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events +This section contains the APIs related to browsing context events. + +### Browsing Context Created Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L34-L41" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L24-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Dom Content loaded Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L54-L63" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L54-L63" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Browsing Context Loaded Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L81-88" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L71-L79" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigated Started Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L97-104" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Fragment Navigated Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L87-L98" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### User Prompt Opened Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### User Prompt Closed Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L150-163" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Browsing Context Destroyed Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L170-L181" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#106-L114" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md new file mode 100644 index 000000000000..865e27a20fab --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md @@ -0,0 +1,604 @@ +--- +title: "Browsing Context" +linkTitle: "Browsing Context" +weight: 1 +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Chinese. Do you speak Chinese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +## Commands +This section contains the APIs related to browsing context commands. + +### Open a new window + +Creates a new browsing context in a new window. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L44-L47" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L35-L37" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Open a new tab + +Creates a new browsing context in a new tab. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L58-L61" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L50-L52" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Use existing window handle + +Creates a browsing context for the existing tab/window to run commands. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L37-L41" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L27-L30" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Open a window with a reference browsing context +A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). +The API allows to pass the reference browsing context, which is used to create a new window. The implementation is operating system specific. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L50-L55" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L42-L45" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Open a tab with a reference browsing context +A reference browsing context is a [top-level browsing context](https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context). +The API allows to pass the reference browsing context, which is used to create a new tab. The implementation is operating system specific. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L64-L69" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L57-L60" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate to a URL + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L72-L80" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L69" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate to a URL with readiness state + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L83-L92" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L81-L84" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context tree + +Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L95-L108" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L92-L98" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context tree with depth + +Provides a tree of all browsing contexts descending from the parent browsing context, including the parent browsing context upto the depth value passed. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L111-L123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L105-L111" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get All Top level browsing contexts + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L126-L133" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.20.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L428-L433" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Close a tab/window + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L136-L153" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L117-L120" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Activate a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L157-L161" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L194-L206" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Reload a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L169-L173" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L353-L353" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Handle user prompt + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L220-L228" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L303" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.13.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L248-L252" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L364-L364" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Viewport Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L259-L268" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L167-L171" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Capture Element Screenshot + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L275-L280" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L186" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Set Viewport + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L304-L307" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L337" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + +### Print page + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.14.1" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L317-L322" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L147-L159" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate back + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L330-L336" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L398-L398" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigate forward + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L342-L352" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L422-L422" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Traverse history + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16.0" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L359-L365" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContext.spec.js#L380-L380" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events +This section contains the APIs related to browsing context events. + +### Browsing Context Created Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L34-L41" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L24-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Dom Content loaded Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L54-L63" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L54-L63" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Browsing Context Loaded Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L81-88" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9.2" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L71-L79" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Navigated Started Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L97-104" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Fragment Navigated Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.15.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#L87-L98" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### User Prompt Opened Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L113-123" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### User Prompt Closed Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L150-163" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Browsing Context Destroyed Event + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L170-L181" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18.0" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/browsingContextInspector.spec.js#106-L114" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/input.en.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/input.en.md new file mode 100644 index 000000000000..10992dd2d36e --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/input.en.md @@ -0,0 +1,48 @@ +--- +title: "Input" +linkTitle: "Input" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/input", +] +--- + +This section contains the APIs related to input commands. + +## Perform Actions + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L41-L44" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L29-L31" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Release Actions + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L59-L65" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L57-57" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/input.ja.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/input.ja.md new file mode 100644 index 000000000000..069cedccb487 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/input.ja.md @@ -0,0 +1,57 @@ +--- +title: "Browsing Context" +linkTitle: "Browsing Context" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/browsing_context", +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Japanese. Do you speak Japanese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +This section contains the APIs related to input commands. + +## Perform Actions + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L41-L44" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L29-L31" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Release Actions + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L59-L65" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L57-57" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/input.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/input.pt-br.md new file mode 100644 index 000000000000..8618ef22526b --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/input.pt-br.md @@ -0,0 +1,57 @@ +--- +title: "Browsing Context" +linkTitle: "Browsing Context" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/browsing_context", +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Portuguese. Do you speak Portuguese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +This section contains the APIs related to input commands. + +## Perform Actions + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L41-L44" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L29-L31" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Release Actions + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L59-L65" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L57-57" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/input.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/input.zh-cn.md new file mode 100644 index 000000000000..ce905e55d561 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/input.zh-cn.md @@ -0,0 +1,57 @@ +--- +title: "Browsing Context" +linkTitle: "Browsing Context" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/browsing_context", +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Chinese. Do you speak Chinese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +This section contains the APIs related to input commands. + +## Perform Actions + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L41-L44" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L29-L31" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Release Actions + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java#L59-L65" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/input.spec.js#L57-57" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/log.en.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/log.en.md new file mode 100644 index 000000000000..8ae3eb9e6d02 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/log.en.md @@ -0,0 +1,70 @@ +--- +title: "Log" +linkTitle: "Log" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/log", +] +--- + +This section contains the APIs related to logging. + +## Console logs + +Listen to the `console.log` events and register callbacks to process the event. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L31-L38" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L23-37" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## JavaScript exceptions + +Listen to the JS Exceptions +and register callbacks to process the exception details. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L70-L77" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L44-54" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Listen to JS Logs + +Listen to all JS logs at all levels and register callbacks to process the log. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L52-L59" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/log.ja.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/log.ja.md new file mode 100644 index 000000000000..7b94be6de2f8 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/log.ja.md @@ -0,0 +1,76 @@ +--- +title: "BiDirectional API (W3C compliant)" +linkTitle: "BiDi API (W3C compliant)" +weight: 12 +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Japanese. Do you speak Japanese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +This section contains the APIs related to logging. + +## Console logs + +Listen to the `console.log` events and register callbacks to process the event. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L31-L38" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L23-37" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## JavaScript exceptions + +Listen to the JS Exceptions +and register callbacks to process the exception details. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L70-L77" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L44-54" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Listen to JS Logs + +Listen to all JS logs at all levels and register callbacks to process the log. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L52-L59" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/log.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/log.pt-br.md new file mode 100644 index 000000000000..be0814eaa07a --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/log.pt-br.md @@ -0,0 +1,76 @@ +--- +title: "BiDirectional API (W3C compliant)" +linkTitle: "BiDi API (W3C compliant)" +weight: 12 +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Portuguese. Do you speak Portuguese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +This section contains the APIs related to logging. + +## Console logs + +Listen to the `console.log` events and register callbacks to process the event. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L31-L38" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L23-37" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## JavaScript exceptions + +Listen to the JS Exceptions +and register callbacks to process the exception details. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L70-L77" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L44-54" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Listen to JS Logs + +Listen to all JS logs at all levels and register callbacks to process the log. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L52-L59" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/log.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/log.zh-cn.md new file mode 100644 index 000000000000..240ac370a900 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/log.zh-cn.md @@ -0,0 +1,77 @@ +--- +title: "BiDirectional API (W3C compliant)" +linkTitle: "BiDi API (W3C compliant)" +weight: 12 + +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Chinese. Do you speak Chinese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +This section contains the APIs related to logging. + +## Console logs + +Listen to the `console.log` events and register callbacks to process the event. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L31-L38" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L23-37" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## JavaScript exceptions + +Listen to the JS Exceptions +and register callbacks to process the exception details. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L70-L77" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.8" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/logInspector.spec.js#L44-54" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Listen to JS Logs + +Listen to all JS logs at all levels and register callbacks to process the log. + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/LogTest.java#L52-L59" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/network.en.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/network.en.md new file mode 100644 index 000000000000..ec619ad8b956 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/network.en.md @@ -0,0 +1,205 @@ +--- +title: "Network" +linkTitle: "Network" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/network", +] +--- +## Commands + +This section contains the APIs related to network commands. + +### Add network intercept + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L36-L38" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L29-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Remove network intercept + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L46-L50" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L34-L35" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Continue request blocked at authRequired phase with credentials + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L57-L64" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L42-L46" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Continue request blocked at authRequired phase without credentials + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L74-L80" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L56-L60" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Cancel request blocked at authRequired phase + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L90-L96" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L71-L75" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Fail request + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L104-L108" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events + +This section contains the APIs related to network events. + +### Before Request Sent + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L30-L35" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L23-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Response Started + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L45-L51" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L83-L89" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Response Completed + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L62-L68" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L97-L103" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Auth Required + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L101-L106" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/network.ja.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/network.ja.md new file mode 100644 index 000000000000..ba14e8ac4b6f --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/network.ja.md @@ -0,0 +1,213 @@ +--- +title: "Network" +linkTitle: "Network" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/network", +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Japanese. Do you speak Japanese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +# Commands + +This section contains the APIs related to network commands. + +### Add network intercept + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L36-L38" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L29-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Remove network intercept + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L46-L50" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L34-L35" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Continue request blocked at authRequired phase with credentials + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L57-L64" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L42-L46" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Continue request blocked at authRequired phase without credentials + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L74-L80" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L56-L60" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Cancel request blocked at authRequired phase + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L90-L96" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L71-L75" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Fail request + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L104-L108" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events + +This section contains the APIs related to network events. + +### Before Request Sent + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L30-L35" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L23-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Response Started + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L45-L51" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L83-L89" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Response Completed + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L62-L68" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L97-L103" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Auth Required + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L101-L106" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/network.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/network.pt-br.md new file mode 100644 index 000000000000..91a6e8d346ff --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/network.pt-br.md @@ -0,0 +1,214 @@ +--- +title: "Network" +linkTitle: "Network" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/network", +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Portuguese. Do you speak Portuguese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +# Commands + +This section contains the APIs related to network commands. + +### Add network intercept + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L36-L38" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L29-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Remove network intercept + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L46-L50" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L34-L35" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Continue request blocked at authRequired phase with credentials + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L57-L64" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L42-L46" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Continue request blocked at authRequired phase without credentials + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L74-L80" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L56-L60" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Cancel request blocked at authRequired phase + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L90-L96" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L71-L75" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Fail request + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L104-L108" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events + +This section contains the APIs related to network events. + +### Before Request Sent + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L30-L35" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L23-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Response Started + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L45-L51" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L83-L89" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Response Completed + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L62-L68" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L97-L103" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Auth Required + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L101-L106" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/network.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/network.zh-cn.md new file mode 100644 index 000000000000..1bdf2cdf7135 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/network.zh-cn.md @@ -0,0 +1,213 @@ +--- +title: "Network" +linkTitle: "Network" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/network", +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Chinese. Do you speak Chinese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + +## Commands + +This section contains the APIs related to network commands. + +### Add network intercept + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L36-L38" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L29-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Remove network intercept + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L46-L50" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L34-L35" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Continue request blocked at authRequired phase with credentials + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L57-L64" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L42-L46" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Continue request blocked at authRequired phase without credentials + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L74-L80" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L56-L60" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Cancel request blocked at authRequired phase + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L90-L96" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_commands.spec.js#L71-L75" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Fail request + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java#L104-L108" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events + +This section contains the APIs related to network events. + +### Before Request Sent + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L30-L35" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L23-L29" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Response Started + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L45-L51" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L83-L89" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Response Completed + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L62-L68" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/network_events.spec.js#L97-L103" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Auth Required + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.17" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkEventsTest.java#L101-L106" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/script.en.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/script.en.md new file mode 100644 index 000000000000..f49919513e7f --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/script.en.md @@ -0,0 +1,339 @@ +--- +title: "Script" +linkTitle: "Script" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/script", +] +--- + +## Commands +This section contains the APIs related to script commands. + +### Call function in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L52-L75" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L32-L53" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Call function in a sandbox + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L201-L210" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L202-L204" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Call function in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L219-L229" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L222-L227" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L239-L242" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L237-L239" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a sandbox + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L280-L283" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L279-L283" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L293-L299" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L292-L299" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Disown handles in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L322-L322" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L330-L330" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Disown handles in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L375-L375" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L372-L372" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get all realms + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L391-L392" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L383-L385" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get realm by type + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L401-402" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L393-L395" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context realms + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L411-412" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L403-L405" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context realms by type + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L422-423" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L416-L416" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Preload a script + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L463-463" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L424-L426" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Remove a preloaded script + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L486-486" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L471-L471" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events +This section contains the APIs related to script events. + +### Message + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L37-L51" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L26-L43" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Realm Created + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L58-L68" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L52-L65" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Realm Destroyed + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L75-L85" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.19" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L73-L86" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + + diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/script.ja.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/script.ja.md new file mode 100644 index 000000000000..6e599f05818c --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/script.ja.md @@ -0,0 +1,347 @@ +--- +title: "Script" +linkTitle: "Script" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/script", +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Japanese. Do you speak Japanese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + + +## Commands +This section contains the APIs related to script commands. + +### Call function in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L52-L75" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L32-L53" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Call function in a sandbox + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L201-L210" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L202-L204" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Call function in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L219-L229" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L222-L227" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L239-L242" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L237-L239" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a sandbox + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L280-L283" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L279-L283" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L293-L299" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L292-L299" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Disown handles in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L322-L322" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L330-L330" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Disown handles in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L375-L375" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L372-L372" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get all realms + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L391-L392" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L383-L385" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get realm by type + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L401-402" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L393-L395" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context realms + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L411-412" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L403-L405" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context realms by type + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L422-423" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L416-L416" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Preload a script + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L463-463" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L424-L426" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Remove a preloaded script + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L486-486" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L471-L471" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events +This section contains the APIs related to script events. + +### Message + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L37-L51" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L26-L43" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Realm Created + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L58-L68" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L52-L65" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Realm Destroyed + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L75-L85" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.19" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L73-L86" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/script.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/script.pt-br.md new file mode 100644 index 000000000000..8d2aa29c98d5 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/script.pt-br.md @@ -0,0 +1,347 @@ +--- +title: "Script" +linkTitle: "Script" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/script", +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Portuguese. Do you speak Portuguese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + + +## Commands +This section contains the APIs related to script commands. + +### Call function in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L52-L75" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L32-L53" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Call function in a sandbox + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L201-L210" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L202-L204" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Call function in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L219-L229" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L222-L227" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L239-L242" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L237-L239" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a sandbox + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L280-L283" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L279-L283" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L293-L299" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L292-L299" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Disown handles in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L322-L322" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L330-L330" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Disown handles in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L375-L375" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L372-L372" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get all realms + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L391-L392" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L383-L385" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get realm by type + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L401-402" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L393-L395" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context realms + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L411-412" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L403-L405" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context realms by type + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L422-423" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L416-L416" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Preload a script + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L463-463" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L424-L426" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Remove a preloaded script + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L486-486" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L471-L471" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events +This section contains the APIs related to script events. + +### Message + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L37-L51" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L26-L43" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Realm Created + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L58-L68" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L52-L65" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Realm Destroyed + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L75-L85" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.19" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L73-L86" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/script.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/script.zh-cn.md new file mode 100644 index 000000000000..82dfefda80d8 --- /dev/null +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/script.zh-cn.md @@ -0,0 +1,347 @@ +--- +title: "Script" +linkTitle: "Script" +weight: 1 +aliases: [ + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/script", +] +--- + +{{% pageinfo color="warning" %}} +

    + + Page being translated from + English to Chinese. Do you speak Chinese? Help us to translate + it by sending us pull requests! +

    +{{% /pageinfo %}} + + +## Commands +This section contains the APIs related to script commands. + +### Call function in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L52-L75" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L32-L53" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Call function in a sandbox + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L201-L210" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L202-L204" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Call function in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L219-L229" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L222-L227" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L239-L242" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L237-L239" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a sandbox + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L280-L283" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L279-L283" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Evaluate script in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L293-L299" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L292-L299" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Disown handles in a browsing context + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L322-L322" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L330-L330" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Disown handles in a realm + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L375-L375" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L372-L372" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get all realms + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L391-L392" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L383-L385" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get realm by type + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L401-402" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L393-L395" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context realms + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L411-412" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L403-L405" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Get browsing context realms by type + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L422-423" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.9" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L416-L416" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Preload a script + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L463-463" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L424-L426" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Remove a preloaded script + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.15" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptTest.java#L486-486" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.10" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_commands.spec.js#L471-L471" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +## Events +This section contains the APIs related to script events. + +### Message + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L37-L51" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L26-L43" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Realm Created + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L58-L68" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.18" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L52-L65" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + +### Realm Destroyed + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< badge-version version="4.16" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ScriptEventsTest.java#L75-L85" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-version version="4.19" >}} +{{< gh-codeblock path="/examples/javascript/test/bidirectional/script_events.spec.js#L73-L86" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}}