• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

SilkTest中Exists()的替代方法

发布: 2011-4-11 10:42 | 作者: 不详 | 来源: 领测软件测试网采编 | 查看: 28次 | 进入软件测试论坛讨论

领测软件测试网

  SilkTest中Exists()的替代方法  软件测试

  Posted by Stan Taylor on March 31, 2010

  I've recently started a new SilkTest project testing a web application, using SilkTest's new open agent and the 4Test scripting language. This post covers an aspect of what I've learned.

  In the SilkTest 'classic' agent, you used the 'Exists()' method to test whether an object exists in the application under test, e.g.,:

  if (Page.Object1.Object2.Object3.Exists())

  // do something...

  With the open agent's dynamic object recognition, the Find() method is what you need to use, but it took me some research to figure out how to do an if statement with the find() method. Here's a test:

  if (Desktop.Find("//BrowserApplication//BrowserWindow//INPUT[@id='sysname']",{5, false}) != NULL)

  // do something

  You'll notice that I added an optional argument: {5,null}. These two values constitute a FINDOPTIONS data type record. The first one is the timeout. The second value is the important one for our purposes: it "determines whether the Find method throws an E_WINDOW_NOT_FOUND exception if no object is found or NULL is returned if no object is found. "

  So, you set that value to FALSE and then test to see whether or not the Find() method returns NULL. If not null, the object exists.

  --------------------------------------------------------------------------------

  Comments

  The following can be tried:

  [-] window BrowserChild AUTPage1

  [ ] tag "Jingle Bells"

  [ ] locator "//BrowserApplication//BrowserWindow[@caption='Jingle Bells']"

  [ ]

  [-] DomElement HomePageImage

  [ ] locator "//IMG[@title='You are on Home page.']"

  [ ]

  [ ]

  [-] void TestObjExists ()

  [ ]

  [-] if AUTPage1.HomePageImage.Exists()

  [ ] Print ("You got lucky & are on Home page.")

  [-] else

  [ ] LogWarning ("Sorry, you missed the bus.")

  Posted by: STU | April 5, 2010 02:03 PM

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网