Skip to content

Commit b71f012

Browse files
committed
Merge branch 'init-source'
2 parents 156c0e0 + 4b8f939 commit b71f012

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+8247
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.class
2+
*.log
3+
target/
4+
.idea/

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# ScalaTest + Selenium
2+
ScalaTest + Selenium provides integration support between ScalaTest and Selenium.
3+
4+
**Publishing**
5+
6+
Please use the following commands to publish to Sonatype:
7+
8+
```
9+
$ sbt +publishSigned
10+
```

build.sbt

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name := "scalatestplus-selenium"
2+
3+
organization := "org.scalatestplus"
4+
5+
version := "1.0.0-SNAP1"
6+
7+
homepage := Some(url("https://github.com/scalatest/scalatestplus-selenium"))
8+
9+
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))
10+
11+
developers := List(
12+
Developer(
13+
"bvenners",
14+
"Bill Venners",
15+
16+
url("https://github.com/bvenners")
17+
),
18+
Developer(
19+
"cheeseng",
20+
"Chua Chee Seng",
21+
22+
url("https://github.com/cheeseng")
23+
)
24+
)
25+
26+
crossScalaVersions := List("2.10.7", "2.11.12", "2.12.8", "2.13.0-M5")
27+
28+
libraryDependencies ++= Seq(
29+
"org.scalatest" %% "scalatest" % "3.1.0-SNAP8",
30+
"org.seleniumhq.selenium" % "selenium-java" % "2.45.0",
31+
"org.eclipse.jetty" % "jetty-server" % "9.4.12.v20180830" % "test",
32+
"org.eclipse.jetty" % "jetty-webapp" % "9.4.12.v20180830" % "test"
33+
)
34+
35+
testOptions in Test :=
36+
Seq(
37+
Tests.Argument(TestFrameworks.ScalaTest,
38+
"-l", "org.scalatest.tags.Slow"
39+
))
40+
41+
enablePlugins(SbtOsgi)
42+
43+
osgiSettings
44+
45+
OsgiKeys.exportPackage := Seq(
46+
"org.scalatestplus.selenium.*"
47+
)
48+
49+
OsgiKeys.importPackage := Seq(
50+
"org.scalatest.*",
51+
"org.scalactic.*",
52+
"scala.*;version=\"$<range;[==,=+);$<replace;"+scalaBinaryVersion.value+";-;.>>\"",
53+
"*;resolution:=optional"
54+
)
55+
56+
OsgiKeys.additionalHeaders:= Map(
57+
"Bundle-Name" -> "ScalaTestPlusSelenium",
58+
"Bundle-Description" -> "ScalaTest+Selenium is an open-source integration library between ScalaTest and Selenium for Scala projects.",
59+
"Bundle-DocURL" -> "http://www.scalatest.org/",
60+
"Bundle-Vendor" -> "Artima, Inc."
61+
)
62+
63+
publishTo := {
64+
val nexus = "https://oss.sonatype.org/"
65+
Some("publish-releases" at nexus + "service/local/staging/deploy/maven2")
66+
}
67+
68+
publishMavenStyle := true
69+
70+
publishArtifact in Test := false
71+
72+
pomIncludeRepository := { _ => false }
73+
74+
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
75+
76+
pgpSecretRing := file((Path.userHome / ".gnupg" / "secring.gpg").getAbsolutePath)
77+
78+
pgpPassphrase := None

project/build.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.2.8

project/plugins.sbt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
2+
3+
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.2.2")
4+
5+
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.4")
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2001-2014 Artima, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.scalatestplus.selenium
17+
18+
/**
19+
* Trait that facilitates using the <em>page object pattern</em> with the ScalaTest Selenium DSL.
20+
*
21+
* <p>
22+
* If you use the page object pattern, mixing trait <code>Page</code> into your page classes will allow you to use the <code>go to</code>
23+
* syntax with your page objects. Here's an example:
24+
* </p>
25+
*
26+
* <pre class="stHighlight">
27+
* class HomePage extends Page {
28+
* val url = "localhost:9000/index.html"
29+
* }
30+
*
31+
* val homePage = new HomePage
32+
* go to homePage
33+
* </pre>
34+
*/
35+
trait Page {
36+
/**
37+
* The URL of the page represented by this page object.
38+
*/
39+
val url: String
40+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2001-2013 Artima, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.scalatestplus.selenium
17+
18+
19+
/**
20+
* Trait containing one abstract method that can capture a screenshot and save it as a file to a given directory.
21+
*/
22+
private[selenium] trait ScreenshotCapturer {
23+
24+
/**
25+
* Captures a screenshot and saves it as a file in the specified directory.
26+
*/
27+
def captureScreenshot(directory: String)
28+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2001-2013 Artima, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.scalatestplus.selenium
17+
18+
import org.scalatest.{TestSuiteMixin, TestSuite, Outcome, Failed}
19+
20+
/**
21+
* Stackable trait that when mixed into a <code>Suite with ScreenshotCapturer</code> ensures a screenshot
22+
* is captured for every failed test.
23+
*
24+
* <p>
25+
* The screenshot is file is placed in a directory whose name is defined by <code>screenshotDir</code>. By
26+
* default, <code>screenshotDir</code> returns the value of the <code>java.io.tmpdir</code> system property.
27+
* To change this, override <code>screenshotDir</code>.
28+
* </p>
29+
*/
30+
private[selenium] trait ScreenshotOnFailure extends TestSuiteMixin { this: TestSuite with ScreenshotCapturer =>
31+
32+
/**
33+
* The name of the directory into which screenshots will be captured.
34+
*
35+
* <p>
36+
* By default, this method returns the value of the <code>java.io.tmpdir</code> system property.
37+
* To change this, override <code>screenshotDir</code>.
38+
* </p>
39+
*/
40+
val screenshotDir: String = System.getProperty("java.io.tmpdir")
41+
42+
/**
43+
* Delegates to <code>super.withFixture</code> to execute the passed <code>NoArgTest</code>, and if the test fails,
44+
* captures a screenshot to the directory name defined by <code>screenshotDir</code>.
45+
*
46+
* <p>
47+
* This method captures screenshots by invoking <code>captureScreenshot</code>, defined in trait <code>ScreenshotCapturer</code>.
48+
* If <code>captureScreenshot</code> completes abruptly with an exception, information about that exception, including the full
49+
* stack trace, is printed to the standard error stream, and the original exception that indicated a failed test is rethrown.
50+
* </p>
51+
*/
52+
abstract override def withFixture(test: NoArgTest): Outcome = {
53+
super.withFixture(test) match {
54+
case failed: Failed =>
55+
try captureScreenshot(screenshotDir)
56+
catch {
57+
case innerE: Throwable =>
58+
Console.err.println("Unable to capture screenshot to " + screenshotDir)
59+
innerE.printStackTrace(Console.err)
60+
}
61+
failed
62+
case other => other
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)