Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scala selenium dsl page object

I am using the Selenium dsl and would like to use a Page object. Currently however it seems I have to define the page object inside the test class. The reason I would want a page object is to share common features between tests so this seems a bit pointless... Has anyone been using the page object model with Selenium DSL? What is the idea behind defining the page object in the same class? How come I get a compiler error if I define the page object outside of the test class. Am I doing something wrong?

The compiler error I get is:

Expected MySpec.this.type#Page, actual: MyPage

like image 653
shmish111 Avatar asked May 08 '26 15:05

shmish111


1 Answers

You can define the class outside of the test class like this:

class TwitterPage {
  val url = "http://twitter.com"
}

Then, use it inside the test by mixing in the Page trait:

val page = new TwitterPage with Page
go to page
title should be ("Welcome to Twitter")

This compiled and worked just fine for me.

like image 53
Alex Yarmula Avatar answered May 11 '26 09:05

Alex Yarmula