[Owasp-o2-platform] How to set a text value into an html element?

Dinis Cruz dinis.cruz at owasp.org
Mon May 21 14:05:31 UTC 2012

Hi Fabricio

There are a couple things that could be happening:

   - The page load event might be triggered before the field exists (for
   example if that field is created via Javascript)
   - The field is not really a field (in HTML), it could be something
   created via CSS
   - The 'email' field type could not be recognized by WatiN (I had to say
   that it is the first time I've seen that input type)

Here are a couple ideas for you to try:

*1) introduce a delay after the page opens* - this should help to clarify
if the is is created by dynamic creation of fields:

*return ie.fields();*
you can also wait for a particular field/button/link to exists

*ie.waitForField('field name');*
or wait for a particular variable to exists

ie.waitForJsVariable(*'variable name');*

*2) inject firebug-lite into the browser and use it to find the element*


and use firebug to find out what is going on (and maybe write the
javascript required to make the manipulation you want)
*3) inject firebug-lite and jquery*


If you are a jQuery user/fan, this is the only way you can now manipulate
Javascript  :)

*4) manipulate the javascript from O2 script*
*ie.eval("alert('hello from O2')");*
Here are a couple other variations (note how in the example below there is
a two way communication channel between O2 the Browser

*ie.invokeEval("alert('hello again')");*
*ie.invokeEval("aMethod = function(name) { return 'hello ' + name; } ");*
*return ie.invokeScript("aMethod","'John Smith'");*

Finally, Fabricio, feel free to catch me on skype (DinisCruz) or GTalk, and
I'l help you to figure out a way around it

Dinis Cruz

Blog: http://diniscruz.blogspot.com
Twitter: http://twitter.com/DinisCruz
Web: http://www.owasp.org/index.php/O2

On 21 May 2012 13:35, Fabricio Braz <fabricio.braz at gmail.com> wrote:

> Hi there,
> I was trying to test a log in page, but O2 has not recognized the form
> field "login_email".
> Just to make it clear, here are the steps I've done:
> - After loading the target page I run the following command:
> return ie.fields();
> - The page shows two fields (user login_email and password_login),
> even though the O2 Output shows only the password_login field.
> - I started to look into the page elements ie.elements() and I found
> the missed field. Here is an extract of it:
>     HTMLElement: System.__ComObject
>     Id:
>     Images: WatiN.Core.ImageCollection
>     InnerHtml: <INPUT style="WIDTH: 200px; HEIGHT: 26px"
> id=login_email name=email type=email>
>     OuterHtml: <DIV class=input><INPUT style="WIDTH: 200px; HEIGHT:
> 26px" id=login_email name=email type=email> </DIV>
> - Since the element was identified, I thought that I could use the
> setText to supply the user name I wanted to log in.
>     ie.elements()[28].set_Text("fabricio.braz at gmail.com");
> When I got the following error:
>     44::1::CS0311::The type 'WatiN.Core.Element' cannot be used as
> type parameter 'T' in the generic type or method
> 'O2.DotNetWrappers.ExtensionMethods.WinForms_ExtensionMethods_Control_Object.set_Text<T>(T,
> string)'. There is no implicit reference conversion from
> 'WatiN.Core.Element' to
> 'System.Windows.Forms.Control'.::c:\Users\fabricio.braz\AppData\Local\Temp\eprso105.0.cs
> Considering the scenario above, could you help me set a text value
> into the login_email field?
> Thanks in advance,
> Fabricio Braz
> _______________________________________________
> Owasp-o2-platform mailing list
> Owasp-o2-platform at lists.owasp.org
> https://lists.owasp.org/mailman/listinfo/owasp-o2-platform
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.owasp.org/pipermail/owasp-o2-platform/attachments/20120521/1d1462a6/attachment.html>

More information about the Owasp-o2-platform mailing list