开发者

Unable to click anchor with image inside LI tag

I have HTML like

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML Transitional//EN">
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<HTML>
  <BODY class=" ext-border-box ext-ie ext-ie7 ext-windows" style="OVERFLOW: hidden">
    <DIV class=" x-viewport x-component x-border-layout-ct" id="x-auto-0" style="WIDTH: 1280px; HEIGHT: 862px" __eventBits="16384">
      <DIV class=" x-panel x-component x-border-panel" id="x-auto-9" style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; LEFT: 224px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 1054px; TOP: 35px; BORDER-RIGHT-WIDTH: 0px">
        <DIV class="x-panel-bwrap"><DIV class="x-panel-body x-panel-body-noheader" style="WIDTH: 1054px; HEIGHT: 775px" __eventBits="16384">
          <DIV class=" x-tab-panel x-component" id="x-auto-17" hideFocus style="WIDTH: 1052px" __eventBits="6909">
            <DIV class="x-tab-panel-header x-unselectable" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; WIDTH: 1052px" unselectable="on">
              <DIV class="x-tab-strip-wrap" style="WIDTH: 1052px" role="presentation">
                <UL class="x-tab-strip x-tab-strip-top">
                  <LI class="x-tab-strip-closable  x-component x-tab-strip-active " id="x-auto-17__x-auto-180" hideFocus style="MozOutline: none" __eventBits="125" role="tab">
                    <A class="x-tab-strip-close" role="presentation"></A>
                  </LI>
                </UL>
              </DIV>
            </DIV>
          </DIV>
        </DIV>      
      </DIV>
    </DIV>
  </DIV>
</BODY>
</HTML>

I am not able to click Object with <A> tag which has class attribute. I tried using three different ways

1. ie.link(:class,"x-tab-strip-close").click
2. ie.li(:class,"x-tab-strip-closable  x-component x-tab-strip-active ")开发者_JAVA技巧.link(:class,"x-tab-strip-close").click
3. ie.li(:xpath,"//li[@class='x-tab-strip-close']").click

All the three types resulted in element not found exception. Please let me know how do I click the element.


Hey just try to do something like

 .link(:class, "x-tab-strip-closable x-component x-tab-strip-active").exist? == true
        begin
             browser.link(:class, "x-tab-strip-closable x-component x-tab-strip-active").click

          rescue => e
              rescueHandle(e)
          end
 else
     puts "FAILED! Could not find Class for Component"
         return false
  end

I think you will get to know more if some error are there.


This should work with the HTML you have provided:

browser.link(:class => "x-tab-strip-close").click

If you get "element not found" check if the link is in a frame. It could also be a timing issue, the link is not there when you are looking for it.


This looks like it's part of some custom tab control that is using a lot of CSS and javascript running on the client. I can find some postings in the Sencha "Ext JS" community forum that has similar class names. Looking at some of their samples.

As with any page that has a lot of client side code doing CSS and other magic, you may need to wait a second or two after the page loads for the client side code to execute. So that would be one of the first things I would try.

If not, I notice that a lot of the tab code is creating onmouseover events, and the contents of the DOM are changing on the fly when I mouseover tabs, so you may have to see if you can first fire an 'on-mouseover' event prior to trying to click on the item, potentially that could take it from a state where it is able to be clicked.

The other folks with similar tab names are 'EXT.NET' Again I can find stuff in their forums where these class names appear. I can also find examples of this (it's a button to close a tab) in their examples page for some of the tabs. Similar advice regarding waiting, or trying onmouseover first, applies here as well.

If firing an event first doesn't work, and I'm right about the source of the controls, please see if you can find your control somewhere among their samples/examples and if so post the link, that will let folks here interact with a control of that style and gives us a better chance to figure out what makes it tick.

We also had a similar request from someone a few months back on the Watir google group, but the original poster ("Mahesh") never replied to potential answers so it is unknown if/how they resolved the issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜