stuplum/astrolabe

Questions about Usage

Closed this issue · 1 comments

Hello, I was a bit confused on how to write custom methods works in astrolabe. My understanding is that all properties of the page must be an object. Each of these obj specifies a get or value property. What is the difference and when should I use which? Are there other properties we should know about?

Also, the keyword this seems to Page when inside of a value/get method correct?

Here is an example outlining a login form:

https://github.com/Droogans/ProtractorPageObjects/blob/chapter-5/test/pages/login/Form.js

Notice that I use get at the top of the page. Each one has a call inside of it referencing an element on the page. The get method is for detailing your page elements, and aside from that, does not require invocation in order to return a result. It is, in essence, an attribute, not a function.

Meaning,

loginPage.btnLogin.click();

Is correct, whereas

loginPage.btnLogin().click();

Is incorrect.

If you want to invoke something on the page, use value. For instance:

https://github.com/Droogans/ProtractorPageObjects/blob/chapter-5/test/pages/login/Form.js#L30

Here is a login function, which calls a function.

loginPage.login();

Is correct, whereas

loginPage.login;

would not work.

I recommend putting all of your page elements at the top of the page, in alphabetical order, and prefixing them with something that reminds you what type of element it is. I explain why, among other things, in great detail in the tutorial I wrote that outlines these things, using astrolabe and protractor:

https://github.com/Droogans/ProtractorPageObjects/