Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the text of /html/head/title element using Geb framework?

Using the Page Object pattern, I'd like to implement some "at" verifications based on the text of /html/head/title element.

How do I get the text of the title?

I know Geb doesn't support XPath expressions.

like image 340
Tomas Pinos Avatar asked Oct 15 '25 15:10

Tomas Pinos


1 Answers

@Tim_Yates is right, but you specifically asked about the Page Object model.

You setup the rules for your successful page load, like so:

class GoogleHomePage extends Page {
  static url = "http://google.com/"
  static at = { title == "Google" }  // the bit you asked about
}

Then, your actual test:

Browser.drive {
  to GoogleHomePage // goes to GoogleHomePage and verifies by calling at(). 
}

(if you don't want at() checking, use via() instead of to().)

like image 145
inanutshellus Avatar answered Oct 17 '25 22:10

inanutshellus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!