GithubHelp home page GithubHelp logo

doytsujin / scala-js-env-selenium Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scala-js/scala-js-env-selenium

0.0 1.0 0.0 137 KB

Scala.js environment

License: BSD 3-Clause "New" or "Revised" License

Scala 100.00%

scala-js-env-selenium's Introduction

scalajs-env-selenium

Scala.js

Usage

Simply add the following line to your project/plugins.sbt (note that this line must be placed before addSbtPlugin("org.scala-js" % "sbt-scalajs" % <scalajs-version>); otherwise you may get errors such as java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState when you run tests):

// For Scala.js 0.6.x
libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "0.3.0"

// For Scala.js 1.x
libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.0"

and the following line to your sbt settings:

// Apply to the 'run' command
jsEnv := new org.scalajs.jsenv.selenium.SeleniumJSEnv(capabilities)

// Apply to tests
jsEnv in Test := new org.scalajs.jsenv.selenium.SeleniumJSEnv(capabilities)

where capabilities is one of the members of org.openqa.selenium.remote.DesiredCapabilities.

For example for Firefox:

jsEnv := new org.scalajs.jsenv.selenium.SeleniumJSEnv(
    new org.openqa.selenium.firefox.FirefoxOptions())

You are responsible for installing the drivers needed for the browsers you request.

When executing the program with run a new browser window will be created, the code will be executed in it and finally the browser will close itself. All the console outputs will appear in SBT as usual. Executing test will open several browser windows and close them all before the end of the tests.

In browser debugging

If you wish to keep the browser window opened after the execution has terminated simply add the option withKeepAlive on the environment:

new SeleniumJSEnv(capabilities, SeleniumJSEnv.Config().withKeepAlive(true))

It is recommend to use this with a run and not test because the latter tends to leave too many browser windows open.

Debugging tests on a single window

By default tests are executed in their own window for parallelism. When debugging tests with withKeepAlive it is possible to disable this option using the sbt setting parallelExecution in Test := false.

Headless Usage

It is often desirable to run Selenium headlessly. This could be to run tests on a server without graphics, or to just prevent browser windows popping up when running locally.

xvfb

A common approach on Linux and Mac OSX, is to use xvfb, "X Virtual FrameBuffer". It starts an X server headlessly, without the need for a graphics driver.

Once you have xvfb installed, usage here with SBT is as simple as:

Xvfb :1 &
DISPLAY=:1 sbt

The :1 indicates the X display-number, which is a means to uniquely identify an X server on a host. The 1 is completely arbitrary—you can choose any number so long as there isn't another X server running that's already associated with it.

License

scalajs-env-selenium is distributed under the BSD 3-Clause license.

Contributing

Follow the contributing guide.

scala-js-env-selenium's People

Contributors

gshakhn avatar gzm0 avatar hmil avatar japgolly avatar mushtaq avatar nicolasstucki avatar ramnivas avatar sjrd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.