Вопрос

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.

Это было полезно?

Решение

@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().)

Другие советы

The documentation shows:

Browser.drive {
    go "http://google.com/ncr"

    // make sure we actually got to the page
    assert title == "Google"

    ....
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top