Below is the code to find tab order
auto=WIN32OLE.new('AutoItX3.control')
# mark the first control in order to prevent indefinite loop.
auto.Send("{TAB}")
auto.Send("{TAB}")
element = ie.show_active
tabOrder = 1
controlKey = "EthDomain"
while (element != nil or element != "")
if (element.include? (controlKey)) //controlKey : is either id or
name or text
break
else
auto.Send("{TAB}")
tabOrder += 1
element = ie.show_active
end
end
puts tabOrder
George wrote:
> Thanks, Joedio. There is a way to do this using AutoIt. If I use
> send_keys, then check the value of the text_field, I can determine
> which element has focus. Unfortunately, this won't work with buttons
> and links.
>
>
> On May 18, 9:57 am, joedio <[email protected]> wrote:
> > The Watir tabindex method you used is for HTMl tags with a tabindex
> > attribute.
> > For example:
> > <a href="#interactive" tabindex="1" >Link A</a>
> > <a href="#interactive" tabindex="2" >Link B</a>
> >
> > As you mention, your web page is NOT using the tabindex attribute,
> > thus the method return 0.
> >
> > Perhaps you could use AutoIt's send_keys command to tab through the
> > web page, e.g.
> >
> > # Advance to the next object in the tabbing order
> > browser.send_keys("{TAB}")
> >
> > and after each command detect which object has focus. You could then
> > collect the tabbing
> > order, which could be saved and compared to the tabbing order found on
> > subsequent runs.
> >
> > Sorry but I don't know of a means to tell which object has focus,
> > Watir's Watir::Element class lack an in_focus? method.
> > It has focus method to set the focus but not a method to verify if it
> > is in focus.
> > Perhaps someone else can assist with that.
> >
> > On May 14, 7:06 pm, George <[email protected]> wrote:
> >
> >
> >
> >
> >
> > > I'm trying to verify the tab order on a login page by accessing the
> > > tabindex attribute. Unfortunately, the tabindex isn't specified in the
> > > HTML code and performing the following code isn't helping me. Does
> > > anybody have any ideas?
> >
> > > ~~~~~~~~~~~~~~~~~~
> >
> > > @browser = Watir::IE.attach(:title, /Login/)
> >
> > > puts @browser.text_field(:id, 'username').document.tabindex # returns
> > > 0
> >
> > > puts @browser.text_field(:id, 'username').attribute_value('tabindex')
> > > # returns 0
> >
> > > puts @browser.text_field(:id, 'password').document.tabindex # returns
> > > 0, expected 1
> >
> > > puts @browser.text_field(:id, 'password').document.tabindex # returns
> > > 0, expected 1
> >
> > > ~~~~~~~~~~~~~~~~~~
> >
> > > --
> > > Before posting, please readhttp://watir.com/support. In short: search
> > > before you ask, be nice.
> >
> > > You received this message because you are subscribed
> > > tohttp://groups.google.com/group/watir-general
> > > To post: [email protected]
> > > To unsubscribe: [email protected]
> >
> > --
> > Before posting, please readhttp://watir.com/support. In short: search
> > before you ask, be nice.
> >
> > You received this message because you are subscribed
> > tohttp://groups.google.com/group/watir-general
> > To post: [email protected]
> > To unsubscribe: [email protected]
>
> --
> Before posting, please read http://watir.com/support. In short: search before
> you ask, be nice.
>
> You received this message because you are subscribed to
> http://groups.google.com/group/watir-general
> To post: [email protected]
> To unsubscribe: [email protected]
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
You received this message because you are subscribed to
http://groups.google.com/group/watir-general
To post: [email protected]
To unsubscribe: [email protected]