Thanks Jeff and Zeljko for both the more OO method and the
quick method.
To explain further what I need to do is to get the id. From
that id then I want to click a gif image in an IMG tag
example as shown below:
<IMG onclick=rusure(80) alt="Delete Asset"
src="/brand/client/images/del.gif" border=0>
Let's say the id is 80 and I pass it in a variable $myid
How do I proceed to click that image? because onclick is
not
part of the IMG attribute it's a javascript that the
developer is passing the id to.
$ie.frame("main").image(:??, ??).click
thanks for the help
--- Jeff Wood <[EMAIL PROTECTED]> wrote:
> Actually, the more object oriented ruby way to do it
> would be
>
> --SCRIPT--
>
> # define a method so you don't repeat yourself when you
> want to do this later.
> def getLinkID( *args )
>
> # we used *args so we can pass whatever we want to the
> #link call.
>
> regex = /id=(\d+)/
> id = nil
>
> begin
>
> # setup your tools & values
> href = ie.link( *args ).href
>
> # find the value
> matches = regex.match( href )
> if matches
> # found it
> id = matches[1]
> end
>
> rescue
>
> # this failure would "normally" happen if ie.link
> can't find the
> link in the page.
>
> end
>
> # return whatever we have ... value or nil
> id
>
> end
>
> # how this is callable as
> my_id = getLinkID( :text, "New Vehicle" )
>
> # or ( whatever you want )
> my_id = getLinkID( :name, /Blah/ )
>
> --SCRIPT--
>
> I try to stay away from the less-readable perl-like ways
> of doing it.
> I don't like implicit variables.
>
> j.
>
> On 10/19/05, Zeljko Filipin <[EMAIL PROTECTED]>
> wrote:
> > I am not shure what do you need. My guess is that you
> need to isolate
> > 'id=89' from 'sub_viewvehicle.php?id=89&t=vehicle'. If
> you need
> > something else, let me know.
> >
> > # try to find 'id=' followed with two digits (\d) in
> > 'sub_viewvehicle.php?id=89&t=vehicle'
> > # 'sub_viewvehicle.php?id=89&t=vehicle' =~ /id=\d\d/
> > ie.link(:text, 'New Vehicle').href =~ /id=\d\d/
> >
> > # string that matches is stored in variable $& (and
> yes, this is ugly
> > looking variable, and it has a nicer Ruby name, but I
> can not find it
> > now)
> > puts $&
> >
> > Zeljko
> >
> > 2005/10/18, Roy Sin <[EMAIL PROTECTED]>:
> > > Hi All,
> > >
> > > Below is a sample of a href on a hyperlink
> > >
> > > <A href="sub_viewvehicle.php?id=89&t=vehicle">New
> > > Vehicle</A>
> > >
> > > How can I get the dynamic id?
> > >
> > > thanks
> > >
> > >
> > >
> > >
> > > __________________________________
> > > Yahoo! Mail - PC Magazine Editors' Choice 2005
> > > http://mail.yahoo.com
> > > _______________________________________________
> > > Wtr-general mailing list
> > > [email protected]
> > > http://rubyforge.org/mailman/listinfo/wtr-general
> > >
> >
> > _______________________________________________
> > Wtr-general mailing list
> > [email protected]
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
>
>
> --
> "http://ruby-lang.org -- do you ruby?"
>
> Jeff Wood
>
> _______________________________________________
> Wtr-general mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-general
>
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general