HELP - Acessing password (text) field

83 views
Skip to first unread message

Alberto Magalhães

unread,
Nov 24, 2014, 1:11:47 PM11/24/14
to watir-...@googlegroups.com
Hi,

I'm having trouble getting access to a password text field - claveConsultiva

I apreciate all the help

<div id="left">
<div id="navtitle">
<ul class="fv">
<li class="fl titleout">
<div class="title">
Entrar no NetBanco Particulares
</div>
</li>
<li class="fl navon" style="position: relative">
<div class="boxarrowdownon"></div>
Particulares
</li>
<li class="fl navoff btnarea" title="Entrar no NetBanco Empresas">

</li>
</ul>
</div>
<div id="nota" class="fc">
Para aceder às suas contas, introduza o Nome de Utilizador e o Código de Acesso.<BR/><strong>Por razões de segurança, recomendamos a utilização do Teclado Virtual.</strong>
</div>
<form name="formulario" autocomplete="off" method="post" action="../login/?">
<input type="hidden" name="accion" value="3"/>
<input type="hidden" name="ssafe" value="48A2057113F89EA3741705D7968B4AFFD8F8A23F"/>
<input type="hidden" name="linkHomeURL" value="/pagina/indice/0,,276_1_2,00.html"/>
<div class="input_container">
<span class="inner">
<label for="identificacionUsuario">Nome de Utilizador</label>
<input autofocus type="text" class="inputlong" id="identificacionUsuario" name="identificacionUsuario" value="210348500" maxlength="64" autocomplete="off" />
</span>
</div>
<div class="input_container">
<span class="inner">
<label for="claveConsultiva">Código de Acesso</label>
<input type="password" id="claveConsultiva" name="claveConsultiva" maxlength="16" autocomplete="off" />
<a href="javascript:;" id="vkbd" title="Teclado Virtual" alt="Teclado Virtual"></a>
<div class="fc"></div>
</span>
</div>
</form>
</div>

Titus Fortner

unread,
Nov 24, 2014, 1:49:51 PM11/24/14
to watir-...@googlegroups.com
This works with the html you posted.

browser.text_field(id: 'claveConsultiva').set "foobar"

Alberto Magalhaes

unread,
Nov 24, 2014, 2:33:30 PM11/24/14
to watir-...@googlegroups.com
Thanks Titu..

Bu i think is probably because of the iframe.


<iframe name="ws" id="ws" src="&#x2f;bepp&#x2f;sanpt&#x2f;usuarios&#x2f;login&#x2f;0,,,0.shtml&#x3f;usr&#x3d;210348500" onLoad="startdyncode()" frameborder="0" style="overflow: hidden; width: 100%; z-index:200; position:relative; min-height:400px" scrolling="no" ></iframe>
<div class="clear"></div>
<meta http-equiv="Cache-Control" content="private,no-cache,no-store,must-revalidate,max-age=0"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="1"/>
</div>

On Mon, Nov 24, 2014 at 6:49 PM, Titus Fortner <titusf...@gmail.com> wrote:
This works with the html you posted.
<iframe name="ws" id="ws" src="&#x2f;bepp&#x2f;sanpt&#x2f;usuarios&#x2f;login&#x2f;0,,,0.shtml&#x3f;usr&#x3d;210348500" onLoad="startdyncode()" frameborder="0" style="overflow: hidden; width: 100%; z-index:200; position:relative; min-height:400px" scrolling="no" ></iframe>
<div class="clear"></div>
<meta http-equiv="Cache-Control" content="private,no-cache,no-store,must-revalidate,max-age=0"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="1"/>
</div>

--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.
 
watir-...@googlegroups.com
http://groups.google.com/group/watir-general
watir-genera...@googlegroups.com

---
You received this message because you are subscribed to a topic in the Google Groups "Watir General" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/watir-general/lUfGWIwZ_Xc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to watir-genera...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Titus Fortner

unread,
Nov 24, 2014, 2:37:11 PM11/24/14
to watir-general
Ah, the html didn't have the iframe in it. so:
browser.iframe(id: 'ws').text_field(id: 'claveConsultiva').set "foobar"

You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-genera...@googlegroups.com.

Joe Fleck

unread,
Nov 24, 2014, 2:45:43 PM11/24/14
to Watir General
Yes.  Definitely not having the iframe will cause it not to work.

Joe

Alberto Magalhães

unread,
Nov 24, 2014, 4:19:01 PM11/24/14
to watir-...@googlegroups.com

Joe and Titus 

it's not working.


thanks in advance

Titus Fortner

unread,
Nov 24, 2014, 4:36:54 PM11/24/14
to watir-general
This works for me.

browser = Watir::Browser.new :chrome
browser.iframe(id: 'ws').text_field(id: 'identificacionUsuario').set 'Foo'
browser.iframe(id: 'ws').text_field(id: 'claveConsultiva').set 'Bar'
browser.iframe(id: 'ws').link(id: 'login_button').click

--

Alberto Magalhaes

unread,
Nov 24, 2014, 5:26:42 PM11/24/14
to watir-...@googlegroups.com
Titus,

I'm trying this:
require 'watir-webdriver'
browser = Watir::Browser.new :chrome
browser.text_field(:name => "usr").set "foo"
browser.button(:value => "Login").click
usr=Nome%20de%20Utilizador'
browser.iframe(id: 'ws').text_field(id: 'claveConsultiva').set 'bar'
browser.iframe(id: 'ws').link(id: 'login_button').click
You received this message because you are subscribed to a topic in the Google Groups "Watir General" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/watir-general/lUfGWIwZ_Xc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to watir-genera...@googlegroups.com.

Joe Fleck

unread,
Nov 24, 2014, 5:30:50 PM11/24/14
to Watir General
Alberto,

What line is this failing on?

Joe

Titus Fortner

unread,
Nov 24, 2014, 5:35:03 PM11/24/14
to watir-general
Sometimes there are issues with auto-focus elements.

Add this line before the set, and it will work.
browser.iframe(id: 'ws').text_field(id: 'claveConsultiva').click

Alberto Magalhaes

unread,
Nov 24, 2014, 5:35:41 PM11/24/14
to watir-...@googlegroups.com
C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/iframe.rb:10:in `locate': unable to locate iframe using {:id=>"ws", :tag_name=>"iframe"} (Watir::Exception::UnknownFrameException)
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:510:in `assert_exists'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/iframe.rb:31:in `assert_exists'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:532:in `locate'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:510:in `assert_exists'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/user_editable.rb:11:in `set'
from teste_2.rb:8:in `<main>'
>Exit code: 1

Alberto Magalhaes

unread,
Nov 24, 2014, 5:36:23 PM11/24/14
to watir-...@googlegroups.com
Joe,
Line 10. thanks

Titus Fortner

unread,
Nov 24, 2014, 5:44:58 PM11/24/14
to watir-general
I take that back, I had a typo when trying to set. I'm not having any problem with the code...

2.1.2 :073 > browser = Watir::Browser.new :chrome
 => #<Watir::Browser:0x1f1ef64532cb8556 url="data:," title="data:,"> 
2.1.2 :075 > browser.text_field(:name => "usr").set "foo"
 => nil 
2.1.2 :076 > browser.button(value: 'Login').click
 => [] 
2.1.2 :077 > browser.iframe(id: 'ws').text_field(id: 'claveConsultiva').set 'bar'
 => nil 
2.1.2 :078 > browser.iframe(id: 'ws').link(id: 'login_button').click
 => [] 
2.1.2 :079 > 

Alberto Magalhaes

unread,
Nov 24, 2014, 5:49:02 PM11/24/14
to watir-...@googlegroups.com
same error :-(

require 'watir-webdriver'
browser = Watir::Browser.new :chrome
#substituir o USERID pelo user de acesso
browser.text_field(:name => "usr").set "foo"
browser.button(:value => "Login").click
browser.iframe(id: "ws").text_field(id: "claveConsultiva").set 'bar'
browser.iframe(id: "ws").link(id: "login_button").click
C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/iframe.rb:10:in `locate': unable to locate iframe using {:id=>"ws", :tag_name=>"iframe"} (Watir::Exception::UnknownFrameException)
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:510:in `assert_exists'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/iframe.rb:31:in `assert_exists'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:532:in `locate'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:510:in `assert_exists'
from C:/Ruby21/lib/ruby/gems/2.1.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/user_editable.rb:11:in `set'
from teste_2.rb:8:in `<main>'


Titus Fortner

unread,
Nov 24, 2014, 5:51:02 PM11/24/14
to watir-general
What version Watir, Chrome & ChromeDriver? Does it work in Firefox?

Alberto Magalhaes

unread,
Nov 24, 2014, 5:54:39 PM11/24/14
to watir-...@googlegroups.com
ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]
Watir 5.0
Google Chrome Version 39.0.2171.65

Titus Fortner

unread,
Nov 24, 2014, 6:02:56 PM11/24/14
to watir-general
Are you using watir-classic or watir-webdriver?

If watir-webdriver, switch to this gem:


Justin Ko

unread,
Nov 25, 2014, 9:46:54 AM11/25/14
to watir-...@googlegroups.com
It looks like there is sometimes a delay in the loading of the iframe containing the password field. Adding a wait to the setting of the password field solved the problem (at least for me):

browser.iframe(id: "ws").text_field(id: "claveConsultiva").when_present.set 'bar'

The `when_present` method tells Watir to wait for the element to appear before setting it.

- Justin Ko

Alberto Magalhaes

unread,
Nov 25, 2014, 4:46:59 PM11/25/14
to watir-...@googlegroups.com
thanks it's working!!
Reply all
Reply to author
Forward
0 new messages