在QTP中申明XPath

发表于:2014-7-21 11:50

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:dushuai    来源:51Testing软件测试网采编

  Example 1:
  <body>
  <h4>John Smith<input type=checkbox name="select" /></h4>
  <body>
  <h4>Anne Anderson<input type="checkbox" name="select" checked=true /></h4>
  In QTP:
  'Selecting John Smith
  Browser("XPath").WebElement("xpath:=//h4[1]").Click
  'Selecting Anne Anderson
  Browser("XPath").WebElement("xpath:==/h4[contains(text(), 'Anne')]").Click)
  Example 2:
  XPath:
  1. (//tr[@class='row2']/td[1])[2]
  2. (//td[contains(text(),'Address')])[2]
  In QTP:
  1. Browser("XPath").WebElement("xpath:=(//tr[@class='row2']/td[1])[2]").Click
  2. Browser("XPath").WebElement("xpath:=(//td[contains(text(),'Address')])[2]").Click
  Example 3:
  <table id='table1'>
  <tr class='row1' id=BPT>
  <td>View ID</td>
  <td><input type='button' value='Button 1' class='btn_blue' id='btnfirst'></td>
  </tr>
  In QTP:
  'Selecting Button 1
  Browser("XPath").WebButton("xpath:=//td/input[@id='btnfirst']").Click
  'Select Button 1
  Browser("XPath").WebButton("xpath:=(//table[@id='table1']/*/*)[1]/*[2]/input").Click
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号