UFT之String to Xml控件及XPATH检查点

上一篇 / 下一篇  2014-03-27 22:51:55 / 个人分类:QTP/UFT

3Hb7i3qG-xL&b0

1.Read form file控件,file选择xml文件

x@_5I{0j"I*rF0

Xml文件:

)bser"mt+dU0

<FlightOrder>

_$hD6i Uk0

<Class>Business</Class>51Testing软件测试网C"K5Jcdg#@8K ?

<CustomerName>John Doe</CustomerName>51Testing软件测试网j%SF'OL2Y8n

<DepartureDate>2014-03-08</DepartureDate>

O(W@XeO0

<FlightNumber>1304</FlightNumber>51Testing软件测试网9[k3QH7h"o_XW w Cz

<NumberOfTickets>2</NumberOfTickets>51Testing软件测试网 S(G8C4u5D3X_

</FlightOrder>

3Uv+h j n0

 51Testing软件测试网p#y5r!R C(];t

2.String to xml控件,source stirng 选择link to data sourceavailable steps,选择read from fileoutput-content51Testing软件测试网a5h&h.oO!{h8W-U

 51Testing软件测试网"T#]3y%rk(eY

3设置xml检查点:51Testing软件测试网xS?3A0~R M

*通过xml验证文件51Testing软件测试网{9N)N$Zae,Q

Imports Schema,选择xsd文件,导入后设置检查点值51Testing软件测试网3z.Z pB AR$K)d)W

 51Testing软件测试网rv]Vc$] M

Xsd文件51Testing软件测试网/V4E c nni}

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

8PjhI~:G0[0

<xs:element name="FlightOrder">51Testing软件测试网-X XH vP

 <xs:complexType>51Testing软件测试网J2^l/a8H,y Q]

  <xs:sequence>51Testing软件测试网7`$p"A"k)r h)OE

   <xs:element name="Class" type="xs:string" fixed="AAA"/>51Testing软件测试网fN*~&hV6p2?

   <xs:element name="CustomerName" type="xs:string"/>

"G3H m:YrX/L0

   <xs:element name="DepartureDate" type="xs:date"/>

9B r8^2?yp'C4k#S0

   <xs:element name="FlightNumber" type="xs:integer "/>51Testing软件测试网W k-RTulWP!o

   <xs:element name="NumberOfTickets" type="xs:integer"/>51Testing软件测试网&`1Q;U&Ach"YM,t.g

  </xs:sequence>51Testing软件测试网1F w8_tb

 </xs:complexType>

LQ4j@#l*EqV0

</xs:element>51Testing软件测试网;c#Q#S_"X/uN+};@

</xs:schema>

H,ooB c$P&j}M&M0

 

q!L pW&k+x!X1Y#~9w3f!M0

*通过xpath验证51Testing软件测试网!tg1y o`BK8`

 51Testing软件测试网Z2jg(E?

 右键String to xml控件的value框,copy xpath51Testing软件测试网F;a~zpM

/Arguments[1]/InputString[1]51Testing软件测试网 uP7W1p"S1N

添加xpath验证属性51Testing软件测试网vVtxX

 51Testing软件测试网.^C'|E![z5L

粘贴XPATH,并修改为51Testing软件测试网I#XX'u2Y] l1j

/FlightOrder/Class,值为Business51Testing软件测试网 ]4Hf'L`[

//Class=Business51Testing软件测试网 P"D1{1IU

 

sn U[e0

如果xml文件包含较多子节点51Testing软件测试网"VaOf}:Q)r#` e

/FlightOrder/Class[1]=//Class[1]51Testing软件测试网"g `r6\wv1~

 51Testing软件测试网V]2aR+A2ir|}

勾选ignore namespace51Testing软件测试网:cA_!Rf JIH hV*J

 51Testing软件测试网uS z0|.hfd3Z

 51Testing软件测试网+[+?,\D&m,~ i

如果清除ignore namespace51Testing软件测试网0]-zGZ R,R

右键String to xml控件的value框时,选择copy full qualified XPATH

)u SE)s_-dT'eF0

如下51Testing软件测试网)VY!etC |~

/*[local-name(.)='Arguments'][1]/*[local-name(.)='InputString'][1]

x g]:O,m1\0

 51Testing软件测试网+|'Zj;NB;Lox2M M

修改后/*[local-name(.)='FlightOrder']/*[local-name(.)='Class']=Business51Testing软件测试网xm:M2u)PF#Ha

 51Testing软件测试网$I4\8I`*m)rE;S


TAG:

 

评分:0

我来说两句

Open Toolbar