[wtr-general] Re: Need to click on a link which has only the class name.

2011-06-16 Thread orde
I'd agree with the post above.  Unless you have some other compelling
reason, the approach above should be fine.

In any event, $1 is returning nil in this code snippet:

if /LI class=.*id=mainTabsId__CaseDetailsA class=(\S*)
onclick=.*/
  begin
ie.link(:class, $1).click
  rescue = e
rescueHandle(e)
   end
else
   puts $1 # nil
   puts FAILED! Could not find Class for Close Button
   return false
end

On Jun 15, 12:30 pm, Chuck van der Linden sqa...@gmail.com wrote:
 On Jun 15, 12:27 am, Mahesh mahesh...@gmail.com wrote:









  Hi,

  LI class=x-tab-strip-closable x-tab-with-icon x-tab-strip-active 
  id=mainTabsId__CaseDetailsA class=x-tab-strip-close onclick=return
  false;/A

  This is the source code, and i am using the if condition to extract
  the dynamic class name to extract the class name  click the link.

  The Watir script i am using is:

  if /LI class=.*id=mainTabsId__CaseDetailsA class=(\S*) onclick=.*/
                  begin
                          ie.link(:class, $1).click
                  rescue = e
                          rescueHandle(e)
                  end
          else
                  puts FAILED! Could not find Class for Close Button
                  return false
          end

 You say you are dynamically extracting the class of the link, does
 this mean it is changing in a regular basis?

 I'm having a hard time following exactly what your challenge is here,
 What do you know, e.g. what is constant each time or predictable each
 time?  how do you know you've found the link you want to click?

 If the pattern is for example a list item with a particular ID, that
 contains the link you want,  and the class of the link always contains
 the text ...strip-close then you could do something like this

  if browser.li(:id, mainTabsId__CaseDetails').link(:class, /strip-
 close/).exists?
    browser.li(:id, mainTabsId__CaseDetails').link(:class, /strip-
 close/).click
  else
    puts FAILED! Could not find Close Button
    return false
  end

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Need to click on a link which has only the class name.

2011-06-15 Thread Mahesh
Ashok, this is the source code:

LI class=x-tab-strip-closable x-tab-with-icon x-tab-strip-active 
id=mainTabsId__CaseDetailsA class=x-tab-strip-close onclick=return
false;/A

On Jun 15, 6:20 pm, Ashok Tulachan tulachanas...@gmail.com wrote:
 What's the source code for your link???

 Ashok



 On Wed, Jun 15, 2011 at 2:27 AM, Mahesh mahesh...@gmail.com wrote:
  Hi,

  LI class=x-tab-strip-closable x-tab-with-icon x-tab-strip-active 
  id=mainTabsId__CaseDetailsA class=x-tab-strip-close onclick=return
  false;/A

  This is the source code, and i am using the if condition to extract
  the dynamic class name to extract the class name  click the link.

  The Watir script i am using is:

  if /LI class=.*id=mainTabsId__CaseDetailsA class=(\S*) onclick=.*/
                 begin
                         ie.link(:class, $1).click
                 rescue = e
                         rescueHandle(e)
                 end
         else
                 puts FAILED! Could not find Class for Close Button
                 return false
         end

  --
  Before posting, please readhttp://watir.com/support. In short: search
  before you ask, be nice.

  watir-general@googlegroups.com
 http://groups.google.com/group/watir-general
  watir-general+unsubscr...@googlegroups.com

 --
 Regards,

 Ashok Tulachan

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] Re: Need to click on a link which has only the class name.

2011-06-15 Thread Ashok Tulachan
*LI class=x-tab-strip-closable x-tab-with-icon x-tab-strip-active 
id=mainTabsId__CaseDetailsA class=x-tab-strip-close onclick=return
false;/A*
**

Mahesh, If that's the link source code then,

Try this,

if ie.link(:class, x-tab-strip-closable x-tab-with-icon
x-tab-strip-active).exist? == true
begin
 ie.link(:class, x-tab-strip-closable x-tab-with-icon
x-tab-strip-active).click
  rescue = e
  rescueHandle(e)
  end
 else
 puts FAILED! Could not find Class for Close Button
 return false
  end

Let me know if it works.

Ashok
On Wed, Jun 15, 2011 at 9:27 AM, Mahesh mahesh...@gmail.com wrote:

 Ashok, this is the source code:

 LI class=x-tab-strip-closable x-tab-with-icon x-tab-strip-active 
 id=mainTabsId__CaseDetailsA class=x-tab-strip-close onclick=return
 false;/A

 On Jun 15, 6:20 pm, Ashok Tulachan tulachanas...@gmail.com wrote:
  What's the source code for your link???
 
  Ashok
 
 
 
  On Wed, Jun 15, 2011 at 2:27 AM, Mahesh mahesh...@gmail.com wrote:
   Hi,
 
   LI class=x-tab-strip-closable x-tab-with-icon x-tab-strip-active 
   id=mainTabsId__CaseDetailsA class=x-tab-strip-close onclick=return
   false;/A
 
   This is the source code, and i am using the if condition to extract
   the dynamic class name to extract the class name  click the link.
 
   The Watir script i am using is:
 
   if /LI class=.*id=mainTabsId__CaseDetailsA class=(\S*) onclick=.*/
  begin
  ie.link(:class, $1).click
  rescue = e
  rescueHandle(e)
  end
  else
  puts FAILED! Could not find Class for Close Button
  return false
  end
 
   --
   Before posting, please readhttp://watir.com/support. In short: search
   before you ask, be nice.
 
   watir-general@googlegroups.com
  http://groups.google.com/group/watir-general
   watir-general+unsubscr...@googlegroups.com
 
  --
  Regards,
 
  Ashok Tulachan

 --
  Before posting, please read http://watir.com/support. In short: search
 before you ask, be nice.

 watir-general@googlegroups.com
 http://groups.google.com/group/watir-general
 watir-general+unsubscr...@googlegroups.com




-- 
Regards,

Ashok Tulachan

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Need to click on a link which has only the class name.

2011-06-15 Thread Chuck van der Linden
On Jun 15, 12:27 am, Mahesh mahesh...@gmail.com wrote:
 Hi,

 LI class=x-tab-strip-closable x-tab-with-icon x-tab-strip-active 
 id=mainTabsId__CaseDetailsA class=x-tab-strip-close onclick=return
 false;/A

 This is the source code, and i am using the if condition to extract
 the dynamic class name to extract the class name  click the link.

 The Watir script i am using is:

 if /LI class=.*id=mainTabsId__CaseDetailsA class=(\S*) onclick=.*/
                 begin
                         ie.link(:class, $1).click
                 rescue = e
                         rescueHandle(e)
                 end
         else
                 puts FAILED! Could not find Class for Close Button
                 return false
         end

You say you are dynamically extracting the class of the link, does
this mean it is changing in a regular basis?

I'm having a hard time following exactly what your challenge is here,
What do you know, e.g. what is constant each time or predictable each
time?  how do you know you've found the link you want to click?

If the pattern is for example a list item with a particular ID, that
contains the link you want,  and the class of the link always contains
the text ...strip-close then you could do something like this

 if browser.li(:id, mainTabsId__CaseDetails').link(:class, /strip-
close/).exists?
   browser.li(:id, mainTabsId__CaseDetails').link(:class, /strip-
close/).click
 else
   puts FAILED! Could not find Close Button
   return false
 end


-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com