Skip to content

Commit a295812

Browse files
committed
Fixed unclosed browser windows in WebBrowserSpec.
1 parent c2b45a6 commit a295812

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/main/scala/org/scalatestplus/selenium/WebBrowser.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4776,6 +4776,13 @@ trait Edge extends WebBrowser with Driver with ScreenshotCapturer {
47764776
}
47774777
}
47784778

4779+
/**
4780+
* Companion object that facilitates the importing of <code>Edge</code> members as
4781+
* an alternative to mixing it in. One use case is to import <code>Edge</code> members so you can use
4782+
* them in the Scala interpreter.
4783+
*/
4784+
object Edge extends Edge
4785+
47794786
/*
47804787
* <p>
47814788
* If you mix in <a href="../ScreenshotOnFailure.html"><code>ScreenshotOnFailure</code></a>, ScalaTest will capture a screenshot and store it to either the system temp directory

src/test/scala/org/scalatestplus/selenium/WebBrowserSpec.scala

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,18 +1983,25 @@ class WebBrowserSpec extends JettySpec with matchers.should.Matchers with SpanSu
19831983
import org.scalatest.prop.TableDrivenPropertyChecks._
19841984
import org.scalatest.prop.TableFor1
19851985
// Chrome requires a system property, InternetExplorer only works on Windows
1986-
val examples: TableFor1[WebBrowser with Driver] = {
1987-
val availableDrivers: List[WebBrowser with Driver] =
1986+
val availableDrivers: List[WebBrowser with Driver] =
19881987
List(
1989-
try List(Chrome) catch { case _: Throwable => List.empty[WebBrowser with Driver] },
1990-
try List(Firefox) catch { case _: Throwable => List.empty[WebBrowser with Driver] },
1991-
List(HtmlUnit),
1992-
try List(InternetExplorer) catch { case _: Throwable => List.empty[WebBrowser with Driver] },
1993-
try List(Safari) catch { case _: Throwable => List.empty[WebBrowser with Driver] }
1988+
try List(new Chrome {}) catch { case _: Throwable => List.empty[WebBrowser with Driver] },
1989+
try List(new Firefox {}) catch { case _: Throwable => List.empty[WebBrowser with Driver] },
1990+
List(new HtmlUnit {}),
1991+
try List(new InternetExplorer {}) catch { case _: Throwable => List.empty[WebBrowser with Driver] },
1992+
try List(new Safari {}) catch { case _: Throwable => List.empty[WebBrowser with Driver] },
1993+
try List(new Edge {}) catch { case _: Throwable => List.empty[WebBrowser with Driver] }
19941994
).flatten
1995+
val examples: TableFor1[WebBrowser with Driver] =
19951996
Table("web browser", availableDrivers: _*)
1997+
try {
1998+
forAll (examples) { d =>
1999+
d shouldBe a [Driver]
2000+
}
2001+
} finally {
2002+
availableDrivers.foreach(d => d.close()(d.webDriver))
19962003
}
1997-
forAll (examples) { d => d shouldBe a [Driver] }
2004+
19982005
}
19992006
}
20002007
describe("Page trait") {

0 commit comments

Comments
 (0)