From d900e0574d726046fcbd3d699feef947ef20c616 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Mallru Date: Sat, 20 Jan 2024 18:56:58 +0530 Subject: [PATCH 1/3] Add playwright to js-environments --- doc/project/js-environments.md | 45 ++++++++++++++++++++++++++++++++++ doc/tutorial/basic/index.md | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/doc/project/js-environments.md b/doc/project/js-environments.md index 5c75b4a..ebc0387 100644 --- a/doc/project/js-environments.md +++ b/doc/project/js-environments.md @@ -69,6 +69,51 @@ jsEnv := PhantomJSEnv(args = Seq("arg1", "arg2")).value For more options of the PhantomJS environment, see [the Scaladoc of `PhantomJSEnv`]({{ site.production_url }}/api/sbt-scalajs-env-phantomjs/1.0.0/org/scalajs/jsenv/phantomjs/sbtplugin/PhantomJSEnvPlugin$$autoImport$.html). +## Playwright +[Playwright](https://playwright.dev/) is a comprehensive testing library, enabling automation of Chromium, Firefox, and WebKit browsers. It supports multiple platforms and languages, including Mobile Web, making it an optimal choice for testing JavaScript in real browser environments. + +[`scala-js-env-playwright`](https://github.com/gmkumar2005/scala-js-env-playwright) is an independent project that offers jsEnv and employs Playwright for JavaScript execution. + +The playwright based `jsEnv` can be enabled by adding following settings in build.sbt +```scala +jsEnv := new PWEnv( + browserName = "chrome", + headless = true, + showLogs = true + ) +``` +Addtionally it requires following line in `project/plugins.sbt`: +```scala +// For Scala.js 1.x +libraryDependencies += "io.github.gmkumar2005" %% "scala-js-env-playwright" % "0.1.8" +``` + +The `browserName` parameter accepts `chrome` , `chromium` , `firefox`, and `webkit` as possible options. Please be aware that webkit support is currently in an experimental stage. + +### In browser debugging +To maintain the browser window open post-execution, simply incorporate the `withKeepAlive` option into the environment. + +```scala +lazy val pwenvConfig = Def.setting { + jsenv.playwright.PWEnv + .Config() + .withKeepAlive(true) +} + +jsEnv := new jsenv.playwright.PWEnv( + browserName = "chrome", + headless = true, + showLogs = true, + pwenvConfig.value, +) + +``` +### Headless Usage +Running in headless mode is crucial for operations within Docker containers and build servers. By default, `scala-js-env-playwright` operates in headless mode. However, for debugging purposes, you can set headless to `false`. + +## Details +For more options of the plawwright environment see the github project [PlayWright-jsEnv](https://github.com/gmkumar2005/scala-js-env-playwright) + ## Selenium [Selenium](http://docs.seleniumhq.org/) provides a programmatic interface to real browsers. diff --git a/doc/tutorial/basic/index.md b/doc/tutorial/basic/index.md index 02e46d6..1079a3a 100644 --- a/doc/tutorial/basic/index.md +++ b/doc/tutorial/basic/index.md @@ -351,7 +351,7 @@ After reloading, you can invoke `run` successfully: [info] Running tutorial.webapp.TutorialApp [success] (...) -Alternatively to Node.js with jsdom, you can use [Selenium](http://docs.seleniumhq.org/). +Alternatively to Node.js with jsdom, you can use [Selenium](http://docs.seleniumhq.org/) or [Playwright](https://github.com/gmkumar2005/scala-js-env-playwright) You can find more information about this in the [documentation about JavaScript environments]({{ BASE_PATH }}/doc/project/js-environments.html). ### Adding uTest From 2bb411919b54d3d01f92f911fcb291542e39e76f Mon Sep 17 00:00:00 2001 From: Kiran Kumar Mallru Date: Tue, 23 Jan 2024 01:14:16 +0530 Subject: [PATCH 2/3] minor formatting and grammer fixes --- doc/project/js-environments.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/project/js-environments.md b/doc/project/js-environments.md index ebc0387..f62ffd4 100644 --- a/doc/project/js-environments.md +++ b/doc/project/js-environments.md @@ -70,19 +70,21 @@ For more options of the PhantomJS environment, see [the Scaladoc of `PhantomJSEnv`]({{ site.production_url }}/api/sbt-scalajs-env-phantomjs/1.0.0/org/scalajs/jsenv/phantomjs/sbtplugin/PhantomJSEnvPlugin$$autoImport$.html). ## Playwright -[Playwright](https://playwright.dev/) is a comprehensive testing library, enabling automation of Chromium, Firefox, and WebKit browsers. It supports multiple platforms and languages, including Mobile Web, making it an optimal choice for testing JavaScript in real browser environments. +[Playwright](https://playwright.dev/) is a comprehensive testing library, enabling automation of Chromium, Firefox, and WebKit browsers. -[`scala-js-env-playwright`](https://github.com/gmkumar2005/scala-js-env-playwright) is an independent project that offers jsEnv and employs Playwright for JavaScript execution. +It supports multiple platforms and languages, including Mobile Web, making it an optimal choice for testing JavaScript in real browser environments. -The playwright based `jsEnv` can be enabled by adding following settings in build.sbt +[`scala-js-env-playwright`](https://github.com/gmkumar2005/scala-js-env-playwright) is an independent project that offers a `JSEnv` that uses Playwright for JavaScript execution. + +The playwright-based `jsEnv` can be enabled by adding the following settings in `build.sbt` ```scala jsEnv := new PWEnv( - browserName = "chrome", - headless = true, - showLogs = true + browserName = "chrome", + headless = true, + showLogs = true ) ``` -Addtionally it requires following line in `project/plugins.sbt`: +Addtionally it requires the following line in `project/plugins.sbt`: ```scala // For Scala.js 1.x libraryDependencies += "io.github.gmkumar2005" %% "scala-js-env-playwright" % "0.1.8" From 02e0d16895082715309a4cc332c649f36f919912 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Mallru Date: Tue, 23 Jan 2024 01:21:28 +0530 Subject: [PATCH 3/3] Minor changes --- doc/project/js-environments.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/project/js-environments.md b/doc/project/js-environments.md index f62ffd4..3500498 100644 --- a/doc/project/js-environments.md +++ b/doc/project/js-environments.md @@ -90,10 +90,12 @@ Addtionally it requires the following line in `project/plugins.sbt`: libraryDependencies += "io.github.gmkumar2005" %% "scala-js-env-playwright" % "0.1.8" ``` -The `browserName` parameter accepts `chrome` , `chromium` , `firefox`, and `webkit` as possible options. Please be aware that webkit support is currently in an experimental stage. +The `browserName` parameter accepts `chrome` , `chromium` , `firefox`, and `webkit` as possible options. + +Please be aware that webkit support is currently in an experimental stage. ### In browser debugging -To maintain the browser window open post-execution, simply incorporate the `withKeepAlive` option into the environment. +To maintain the browser window open post-execution, add the `withKeepAlive` option into the environment. ```scala lazy val pwenvConfig = Def.setting { @@ -111,7 +113,10 @@ jsEnv := new jsenv.playwright.PWEnv( ``` ### Headless Usage -Running in headless mode is crucial for operations within Docker containers and build servers. By default, `scala-js-env-playwright` operates in headless mode. However, for debugging purposes, you can set headless to `false`. +Running in headless mode is crucial for operations within Docker containers and build servers. + +By default, `scala-js-env-playwright` operates in headless mode. +However, for debugging purposes, you can set headless to `false`. ## Details For more options of the plawwright environment see the github project [PlayWright-jsEnv](https://github.com/gmkumar2005/scala-js-env-playwright)