Denys Medvediev
Denys Medvediev

Reputation: 1240

How can i get value from geb content?

I have some geb content like this

buttonName(wait: true){$("a.btn_primary")}

I need get value from {} i.e. i need string $("a.btn_primary")

For example def value = "$("a.btn_primary")"

Upvotes: 0

Views: 3189

Answers (2)

OPC
OPC

Reputation: 11

Try

def value = buttonName.value() 

if .text() does not work.

From The Book of Geb,

"The value of input, select and textarea elements can be retrieved and set with the value method. Calling value() with no arguments will return the String value of the first element in the Navigator. Calling value(value) will set the current value of all elements in the Navigator. The argument can be of any type and will be coerced to a String if necessary. The exceptions are that when setting a checkbox value the method expects a boolean (or, an existing checkbox value) and when setting a multiple select the method expects an array or Collection of values."

Hope it works out!

Upvotes: 1

Sharif Mamun
Sharif Mamun

Reputation: 3554

If your buttonName is correct, then try this:

def value = buttonName.text()

Cheers!

Upvotes: 3

Related Questions