0

I am getting below error while compiling

multiple-value selection.Text() in single-value context

var selection *agouti.Selection
s1 := a.page.FirstByXPath(`//*[@id="name"]`)
selection = s1
tmp_address = selection.Text() // Error is occurring at this Line.

Please help to resolve this issue.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Raman
  • 41
  • 1
  • 6

1 Answers1

1

The *agouti.Selection method Text() returns a (string, error). See here in the source code: https://github.com/sclevine/agouti/blob/dab7b01f206e43278618a7e0f5bc3ea39e48445a/selection_properties.go#L10

You need to do:

selection, err = s1 tmp_address = selection.Text() 

If you want to handle the error, or

selection, _ = s1 tmp_address = selection.Text() 

If you wish to ignore it.

Also, if you format your questions in the future properly it will help get better responses.

rofls
  • 4,993
  • 3
  • 27
  • 37
  • Thanks for quick reply. But I tried this also and found this error ---> assignment mismatch: 2 variables but 1 values – Raman May 22 '18 at 08:36
  • Well, that method _does_ return two variables. So, that error may be coming from somewhere else. Best if you share the full stack trace or spend more time deciphering it, to extract all the relevant parts. – rofls May 22 '18 at 08:37
  • Are you sharing all the code from your program in the question? – rofls May 22 '18 at 08:38
  • No, I have not shared the full code, above is only piece of code where I am getting the error. – Raman May 22 '18 at 08:44
  • If you share the full stack trace or more code I may be able to help you more. I'm guessing the error is coming from somewhere else. It should show a line number at the top that is relevant. – rofls May 22 '18 at 08:45
  • Thanks everyone for your quick reply. It is solved. – Raman May 22 '18 at 09:07