TestStack / TestStack.Seleno

Seleno helps you write automated UI tests in the right way by implementing Page Objects and Page Components and by reading from and writing to web pages using strongly typed view models.
http://teststack.github.com/TestStack.Seleno/
MIT License
180 stars 60 forks source link

PageWriter.ReplaceInputValueWith suggests inputName as parameter but requires input Id #198

Open skyne opened 9 years ago

skyne commented 9 years ago

For ReplaceInputValueWith(string inputName, string value) i think i should give the input (for example a TextBox) name, but then nothing happens, the method can't fill my TextBox. This is because ReplaceInputValueWith uses HtmlControlFor<>() which requires the element's id as parameter.

I have an extensive Asp.Net MVC form with a model, this model has more objects as properties, and a forms builts up from 'model.property.property' textboxes. I tried to fill this form with Input.Model() method, but that isn't working. So i tried to fill the textboxes with Input.ReplaceInputValueWith(), checked the source of the page, the Input field's id was in form of "Propertyname_Propertyname" and name "Propertyname.PropertyName", this confused me.

So the examples: When i try to fill the TextBox with the next method, everything is just works fine.

Input.ReplaceInputValueWith("Propertyname_Propertyname", "somevalue")

but with

Input.ReplaceInputValueWith(model => model.Propertyname.Propertyname, "value")

or

Input.ReplaceInputValueWith("Propertyname.Propertyname", "value")

nothing happens, no exception, no error just nothing.

robdmoore commented 9 years ago

Have you tried adding the mvc control id generator to your Seleno host configuration?

On 25 Mar 2015, at 11:41 pm, skyne notifications@github.com wrote:

For ReplaceInputValueWith(string inputName, string value) i think i should give the input (for example a TextBox) name, but then nothing happens, the method can't fill my TextBox. This is because ReplaceInputValueWith uses HtmlControlFor<>() which requires the element's id as parameter.

I have an extensive Asp.Net MVC form with a model, this model has more objects as properties, and a forms builts up from 'model.property.property' textboxes. I tried to fill this form with Input.Model() method, but that isn't working. So i tried to fill the textboxes with Input.ReplaceInputValueWith(), checked the source of the page, the Input field's id was in form of "Propertyname_Propertyname" and name "Propertyname.PropertyName", this confused me.

So the examples: When i try to fill the TextBox with the next method, everything is just works fine.

Input.ReplaceInputValueWith("Propertyname_Propertyname", "somevalue") but with

Input.ReplaceInputValueWith(model => model.Propertyname.Propertyname, "value") or

Input.ReplaceInputValueWith("Propertyname.Propertyname", "value") nothing happens, no exception, no error just nothing.

— Reply to this email directly or view it on GitHub.

skyne commented 9 years ago

Okay, it's fixed my particural issue, the Input.Model() method now works, but not the

Input.ReplaceInputValueWith("Propertyname.Propertyname", "value")

The ReplaceInputValueWith method still needs the id of the input not the name as suggested with the name of the first parameter.

Anyway, thanks for the hint :)

robdmoore commented 9 years ago

Ok. That's something we can look into :).

On 26 Mar 2015, at 3:58 pm, skyne notifications@github.com wrote:

Okay, it's fixed my particural issue, the Input.Model() method now works, but not the

Input.ReplaceInputValueWith("Propertyname.Propertyname", "value") The ReplaceInputValueWith method still needs the id of the input not the name as suggested with the name of the first parameter.

Anyway, thanks for the hint :)

— Reply to this email directly or view it on GitHub.