Reputation: 302
I am new to Scala and still learning. And I am trying to perform/design following approach:
class BasePage (implicit val webDriver: WebDriver, val environment: String) {...}
class LoginPage extends BasePage {...}
class testSpecs extends Specification{
new WithBrowser(webDriver = currentDriver, app = application){
implicit val webDriver= browser.webDriver
implicit val environment = s"localhost:$port"
val loginPage = new LoginPage()
...
}
What I want is to make webDriver and environment available (when first time it is created) to all the page object classes throughout the test script/test in testSpecs.
In this approach I am getting error like :
could not find implicit value for parameter webDriver: org.openqa.selenium.WebDriver
Thanks very much in advance.
Upvotes: 1
Views: 131
Reputation: 15086
The constructor to BasePage
expects 2 arguments. When class LoginPage
is defined, those implicit values aren't in scope, so you'll have to write it like this:
class LoginPage(implicit val webDriver: WebDriver, val environment: String) extends BasePage {...}
Now LoginPage
also has 2 implicit parameters which are passed implicitly to BasePage
's constructor.
Upvotes: 1