Skip to content

Commit 1ad1956

Browse files
committed
Get Edge driver to work with DriverSpec.scala.
1 parent 876eee5 commit 1ad1956

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.scalatestplus.selenium
33
import org.scalatest._
44
import SharedHelpers.EventRecordingReporter
55
import org.openqa.selenium.firefox.{FirefoxDriver, FirefoxOptions}
6-
import org.openqa.selenium.safari.SafariDriver
76
import org.openqa.selenium.chrome.ChromeDriver
87
import org.openqa.selenium.ie.InternetExplorerDriver
98
import org.scalatest.tagobjects.Slow
@@ -18,7 +17,7 @@ class DriverSpec extends funspec.AnyFunSpec {
1817

1918
it("should change its title based on the term searched") {
2019
// Cancel test when cannot access google.com
21-
try goTo("http://www.google.com") catch { case e: Throwable => cancel(e) }
20+
try goTo("https://www.google.com") catch { case e: Throwable => cancel(e) }
2221
try {
2322
clickOn("q")
2423
textField("q").value = "Cheese!"
@@ -35,11 +34,11 @@ class DriverSpec extends funspec.AnyFunSpec {
3534

3635
class GoogleSearchSpecWithChrome extends GoogleSearchSpec with Chrome
3736
class GoogleSearchSpecWithFirefox extends GoogleSearchSpec with Firefox
37+
class GoogleSearchSpecWithEdge extends GoogleSearchSpec with Edge
3838

3939
it("should work with Chrome", Slow) {
4040
// Cancel when Chrome is not available
41-
try new ChromeDriver catch { case e: Throwable => cancel(e) }
42-
val s = new GoogleSearchSpecWithChrome
41+
val s = try new GoogleSearchSpecWithChrome catch { case e: Throwable => cancel(e) }
4342
val rep = new EventRecordingReporter
4443
s.run(None, Args(reporter = rep))
4544
val scopeOpenedList = rep.scopeOpenedEventsReceived
@@ -58,8 +57,7 @@ class DriverSpec extends funspec.AnyFunSpec {
5857

5958
it("should work with Firefox", Slow) {
6059
// Cancel when Firefox is not available
61-
try new FirefoxDriver(new FirefoxOptions) catch { case e: Throwable => cancel(e) }
62-
val s = new GoogleSearchSpecWithFirefox
60+
val s = try new GoogleSearchSpecWithFirefox catch { case e: Throwable => cancel(e) }
6361
val rep = new EventRecordingReporter
6462
s.run(None, Args(reporter = rep))
6563
val scopeOpenedList = rep.scopeOpenedEventsReceived
@@ -78,8 +76,7 @@ class DriverSpec extends funspec.AnyFunSpec {
7876

7977
it("should work with Internet Explorer", Slow) {
8078
// Cancel when Internet Explorer is not available
81-
try new InternetExplorerDriver catch { case e: Throwable => cancel(e) }
82-
val s = new GoogleSearchSpecWithFirefox
79+
val s = try new GoogleSearchSpecWithFirefox catch { case e: Throwable => cancel(e) }
8380
val rep = new EventRecordingReporter
8481
s.run(None, Args(reporter = rep))
8582
val scopeOpenedList = rep.scopeOpenedEventsReceived
@@ -98,8 +95,26 @@ class DriverSpec extends funspec.AnyFunSpec {
9895

9996
it("should work with Safari", Slow) {
10097
// Cancel when Safari is not available
101-
try new SafariDriver catch { case e: Throwable => cancel(e) }
102-
val s = new GoogleSearchSpecWithFirefox
98+
val s = try new GoogleSearchSpecWithFirefox catch { case e: Throwable => cancel(e) }
99+
val rep = new EventRecordingReporter
100+
s.run(None, Args(reporter = rep))
101+
val scopeOpenedList = rep.scopeOpenedEventsReceived
102+
assert(scopeOpenedList.size == 1)
103+
assert(scopeOpenedList(0).message == "google.com")
104+
val scopeClosedList = rep.scopeClosedEventsReceived
105+
assert(scopeClosedList.size == 1)
106+
assert(scopeClosedList(0).message == "google.com")
107+
val testStartingList = rep.testStartingEventsReceived
108+
assert(testStartingList.size == 1)
109+
assert(testStartingList(0).testName == "google.com should change its title based on the term searched")
110+
val testSucceededList = rep.testSucceededEventsReceived
111+
assert(testSucceededList.size == 1)
112+
assert(testSucceededList(0).testName == "google.com should change its title based on the term searched")
113+
}
114+
115+
it("should work with Microsoft Edge", Slow) {
116+
// Cancel when Microsoft Edge is not available
117+
val s = try new GoogleSearchSpecWithEdge catch { case e: Throwable => cancel(e) }
103118
val rep = new EventRecordingReporter
104119
s.run(None, Args(reporter = rep))
105120
val scopeOpenedList = rep.scopeOpenedEventsReceived

0 commit comments

Comments
 (0)