Watir:需要双击元素来打开自定义弹出 [英] Watir: Need to double click on an element to open custom popup

查看:169
本文介绍了Watir:需要双击元素来打开自定义弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WATIR一个新手。我现在面临的问题是 - 我测试的应用程序放置在页面上的缩略图(如Windows图标),我需要双击它。在这样做,一个自定义弹出(JavaScript实现AJAX弹出式)将打开。该fire_event(onfocus此)是不是为我工作。我也试过咔哒的两倍,但同样是没有帮助的。是否有处理这种任何其他方式?你的帮助是非常AP preciated。

由2010年7月6日:

我解决了,但我有另一个查询了。

下面是HTML的,我是能够解决使用@ ie.div(:类,GridElementInlineIE)。fire_event(onfocus此')


 < D​​IV CLASS =gridViewItem的风格=显示:内联表; onfocus此='openAsset(634119577077187500,,LIBRARY_ASSETS_TAB,1,A111);'
        ID ='GridComponent634119577077187500'>
        <表格样式=显示:内联表;类=gridViewItemTable的cellpadding =0CELLSPACING =0
            的onclick =highlightAsset(这一点,事件)pr​​ojectid =dmguid =634119577077187500
            ID =_ thumb_634119577077187500对象类=VIDEO>
            &其中; TR>
                < TD风格=填充:10px的10px的0px 7px的>
                    < IMG类=assetListGridImage draggableThumbnailID =thumb_634119577077187500
                        标题=A111ALT =A111
                        SRC =/图片/ wait.gifdmguid =634119577077187500projectid =
                        对象类=VIDEO_onclick =highlightAsset(这一点,事件)/>
                < / TD>
            < / TR>
            &其中; TR>
                < TD风格=填充:0px 0px 0px 7px的>

                    A111
                < / TD>
            < / TR>
            &其中; TR>
                < TD风格=填充:0px 0px 5px的7px的;最小高度:33px;最大高度:33px;高度:33px;>
                    < IMG ALT ='不出演NAME ='IMAGE634119577077187500称号='星资产SRC =/图片/ star_off.png的onclick ='toggleStar(事件,对此,634119577077187500)级='STa​​rGRID平台' />
                    < IMG ALT =视频标题=视频SRC =/图片/ asset_type / VIDEO.png/>
                    < IMG SRC =/图片/ shared.png称号='共享'ALT =共享/>
                < / TD>

            < / TR>
        < /表>
    < / DIV>
 


现在我需要双击这个项目(以下code)。但是,即使被发现的元素(强调用黄色),则双击无法正常工作。我想@ ie.div(:类,gridViewItem)。fire_event(onfocus此')。我也尝试了while循环和点击两次选项没有任何影响。我使用的是Watir 1.6与Ruby186-27_rc2。

  DIV CLASS =GridElementInline>
                <表类=GridElementInline的风格=边界:2px的实心#1e606e;最小高度:134px;高度:134px;最大高度:134px的onclick =highlightAsset(这一点,事件)
                                                projectid =''folderid =2383ID =_ tblBinlist2383称号=今天>
                    &其中; TR>
                        < TD风格=填充:10px的10px的0px 7px的;>
                            <表ID ='tblBinlist2383'folderid ='2383'projectId =''_onclick ='highlightAsset(这一点,事件)onfocus此='showBinDetails(2383,)级='binThumbnail GridElementInline'的cel​​lpadding =0 'CELLSPACING ='0'>&其中; TR>&其中; TD>&所述; IMG类='fourGridViewImage'的src ='的http://流.....'/>&所述; / TD>&其中; TD> < IMG类='fourGridViewImage'SRC =HTTP://流....../>< / TD>< / TR>< TR>< TD>< IMG类='fourGridViewImage SRC =HTTP://流....../>< / TD>< TD>< IMG类='fourGridViewImage'SRC =HTTP://流....../ >< / TD>< / TR>< /表>
                        < / TD>
                    < / TR>
                &其中; TR>
                < TD合并单元格=2ALIGN =中心的风格=填充:10px的10px的0px 7px的;字体大小:9px;空白:NOWRAP;>
                < D​​IV align =left称号=今天>
                    今天
                < / DIV>
                < / TD>
                < / TR>
                < /表>
            < / DIV>
 

解决方案

还有一个优雅的解决方案,我在Windows中没有为Watir 1.6.7。

我去的Ruby / lib目录/宝石/宝石/ 1.8 /宝石/ watir-1.6.7 / lib中/ watir / element.rb(你的路径可能会改变,但主要的想法是访问watir库和修改element.rb文件)。

我添加了这些行:

 高清fire_event_no_wait(事件)
  assert_exists
  assert_enabled
  亮点(:集)
  元素=#{self.class}。新(#{@ page_container.attach_command}:unique_number,#{} self.unique_number)
  ruby_ code =需要'rubygems的'; <<
          需要#{File.expand_path(File.dirname(__ FILE __))} /核心; <<
          #{}元素.fire_event(\#{事件} \)
  系统(spawned_click_no_wait_command(ruby_ code))
  亮点(:清)
结束
 

这将创建一个名为fire_event_no_wait方法的行为就像click_no_wait在watir。

希望这有助于任何人的活动。

I am a newbie in WATIR. The problem I am facing is - The application I am testing has thumbnails (like Windows icons) placed on the page and I need to double click it. On doing that, an custom popup (ajax popup implemented in javascript) will open. The fire_event("ondblclick") is not working for me. I also tried 'click' twice but that too is not helping. Is there any other way of handling this? Your help is highly appreciated.

Added 6 July 2010:

I solved it but I have another query now.

Below was the HTML for which I was able to solve using "@ie.div(:class,'GridElementInlineIE').fire_event('ondblclick') "


<div class="gridViewItem" style='display: inline-table;' ondblclick='openAsset("634119577077187500", "", "LIBRARY_ASSETS_TAB", "1", "A111");'
        id='GridComponent634119577077187500'>
        <table style="display: inline-table;" class="gridViewItemTable" cellpadding="0" cellspacing="0"
            onclick="highlightAsset(this, event)" projectid="" dmguid="634119577077187500"
            id="_thumb_634119577077187500" objectclass="VIDEO">
            <tr>
                <td style="padding: 10px 10px 0px 7px">
                    <img class="assetListGridImage draggableThumbnail" id="thumb_634119577077187500"
                        title="A111" alt="A111"
                        src="/images/wait.gif" dmguid="634119577077187500" projectid=""
                        objectclass="VIDEO" _onclick="highlightAsset(this, event)" />
                </td>
            </tr>
            <tr>
                <td style="padding: 0px 0px 0px 7px">

                    A111
                </td>
            </tr>
            <tr>
                <td style="padding: 0px 0px 5px 7px; min-height: 33px; max-height: 33px; height: 33px;">
                    <img alt='Not starred' name='IMAGE634119577077187500' title='Star this asset' src='/Images/star_off.png' onclick='toggleStar(event, this, "634119577077187500")' class='starGrid' />
                    <img alt='video' title='video' src='/Images/asset_type/VIDEO.png'/>
                    <img src='/images/shared.png'  title ='Shared' alt='Shared' />
                </td>

            </tr>
        </table>
    </div>


Now I need to double click on this item (code below). But even though the element is being identified (highlighted with a yellow), the double click is not working. I am trying "@ie.div(:class,'gridViewItem').fire_event('ondblclick')". I've also tried the while loops and click-twice options to no effect. I'm using Watir 1.6 with Ruby186-27_rc2.

           div class="GridElementInline">
                <table class="GridElementInline" style="border: solid 2px #1e606e;min-height:134px;height:134px;max-height: 134px" onclick="highlightAsset(this, event)"
                                                projectid='' folderid="2383" id="_tblBinlist2383" title = "today">
                    <tr>
                        <td style="padding: 10px 10px 0px 7px;">
                            <table id='tblBinlist2383' folderid='2383' projectId='' _onclick='highlightAsset(this, event)' ondblclick='showBinDetails("2383", "")' class='binThumbnail GridElementInline' cellpadding='0' cellspacing='0'><tr><td><img class='fourGridViewImage' src='http://stream.....' /></td><td><img class='fourGridViewImage' src='http://stream.....' /></td></tr><tr><td><img class='fourGridViewImage' src='http://stream.....' /></td><td><img class='fourGridViewImage' src='http://stream.....' /></td></tr></table>
                        </td>
                    </tr>
                <tr>
                <td colspan="2" align="center" style="padding: 10px 10px 0px 7px; font-size: 9px;white-space: nowrap;">
                <div align="left" title="today">
                    today
                </div>
                </td>
                </tr>
                </table>
            </div>

解决方案

There's one elegant solution I did for Watir 1.6.7 in Windows.

I went to ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/element.rb (your path may change, but the main idea is to access the watir library and modify the element.rb file).

I added these lines:

def fire_event_no_wait(event)
  assert_exists
  assert_enabled
  highlight(:set)
  element = "#{self.class}.new(#{@page_container.attach_command}, :unique_number, #  {self.unique_number})"
  ruby_code = "require 'rubygems';" <<
          "require '#{File.expand_path(File.dirname(__FILE__))}/core';" <<
          "#{element}.fire_event(\"#{event}\")"
  system(spawned_click_no_wait_command(ruby_code))
  highlight(:clear)
end

this will create a method called fire_event_no_wait that behaves just like click_no_wait in watir.

Hope this helps anyone out.

这篇关于Watir:需要双击元素来打开自定义弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆