﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-qileilove-随笔分类-qtp</title><link>http://www.blogjava.net/qileilove/category/51345.html</link><description>不想做屌丝的码农，不是好项目经理！屌丝生涯从此开始！</description><language>zh-cn</language><lastBuildDate>Wed, 03 Dec 2014 05:44:50 GMT</lastBuildDate><pubDate>Wed, 03 Dec 2014 05:44:50 GMT</pubDate><ttl>60</ttl><item><title>QTP中的时间同步点问题解决</title><link>http://www.blogjava.net/qileilove/archive/2014/11/10/419854.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 10 Nov 2014 02:17:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/11/10/419854.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/419854.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/11/10/419854.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/419854.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/419854.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">一、什么是同步点</strong></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　同步点是指在一个<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>过程中，指示QuickTest等待应用程序中某个特定过程运行完成以后再运行下一步操作。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step.</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　测试过程中，如果需要指定QuickTest暂停运行一个测试或组件，直到特定的对象属性存在后才开始运行下一步，那么可以插入同步点来实现。例如以下几种情况：</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　判断进度条是否已经100%完成。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　判断某一状态消息的出现。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　等待某按钮状态变为可用。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　一个操作后，弹出一个消息对话框。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　等待窗口打开并提交数据。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　二、同步点方法</strong></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　默认等待时间</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Sync方法；</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Wait方法；</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　WaitProperty方法；</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Exist方法；</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">2.1 默认等待时间</strong></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　1）File&gt;&gt;&gt;Settings&gt;&gt;&gt;Run&gt;&gt;&gt;Object synchronization timeout:QTP默认对象识别同步时间为20S，可以手工更改。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　2）File&gt;&gt;&gt;Settings&gt;&gt;&gt;Web&gt;&gt;&gt;Browser navigation timeout:Web插件对于Web浏览器对象的默认同步时间为60s，可以手工更改。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　2.2 Sync</strong></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Syntax</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　object.Sync</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Example</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Browser("Mercury Tours").Sync '等待IE加载完成</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Browser("Mercury Tours").Page("Mercury Tours").Sync '等待页面加载完成</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Description</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Sync方法等待浏览器或页面加载完成后才进行下一步操作，Sync方法只能在WEB中使用，操作对象只有Browser（浏览器对象）和Page（页面对象）。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　注意：虽然Sync方法会使<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>等待到页面加载完成后，但无法判断页面是否加载成功，如果需要判断页面加载是否成功，可以通过判断页面中对象visible的属性值。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Browser("<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">Google</strong></u></a>").Page("Google").WebEdit("q").GetROProperty("visible")=true</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">　　2.3 Wait方法</strong></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Syntax</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　object.WaitProperty (PropertyName, PropertyValue, [TimeOut])</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Example</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Wait 10 或Wait(10)</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　Description</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　wait方法可设定指定的等待时间，时间单位为秒，但这个时间只能是固定的，即必须等到这个时间才能继续执行。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　注意：死等待有时候会浪费时间，有时候会因设定时间过短导致找不到对象。<br /><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;"><strong style="word-break: break-all; line-height: normal !important;">2.4 WaitProperty</strong></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　Syntax</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　object.WaitProperty (PropertyName, PropertyValue, [TimeOut])</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　Example</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　windows("XXX").dialog("XXXXXXXX").waitProperty "visible",true,50000</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　Description</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　WaitProperty方法是指当指定的属性出现后或是指定时间后指定的属性还未出现，再进行下一步操作。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　方法中的visible是属性，true是属性的值，50000为最长等待时间，单位为毫秒。即在最长等待时间内任意时刻visible的值为true了，脚本继续向下执行，否则直到等到最大等待时间，然后给出waring。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　注意：</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　1）如果超出最大等待时间，QTP报告中的结果是warning，而不是fail。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　2）该方法适用于除WinMenu对象（菜单对象）以外的所有标准Windows对象</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　<strong style="word-break: break-all; line-height: normal !important;">2.5 Exist</strong></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　Syntax</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　object.Exist([TimeOut])</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　Example</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　windows("XXX").dialog("XXXXXXXX").Exist(10)</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　Description</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　方法中的10的时间单位为秒。该方法与waitproperty方法类似，当程序执行到该语句时会去检查对象是否存在，若存在返回true，进入下一步；若10s内检查对象一直不存在返回flase，一般用于if语言中比较多。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　如果设置超时时间为0，如object.Exist 0，那么QTP不会等待，而是直接返回查找的结果（True或False）。</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　如果未设置超时时间，如object.Exist，那么超时时间为QTP默认的同步时间</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;">　　<strong style="word-break: break-all; line-height: normal !important;">学习心得：</strong>学习中遇到问题，不要急着四处询问，尝试使用自带的操作手册，往往有意外的收获，看看下面</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; font-size: 11.8181819915771px;"><a href="http://www.51testing.com/batch.download.php?aid=49254" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/11/14982672_201411071331271fk6T.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div></div> <div><div id="SL_button" class="ImTranslatorLogo" style="display: none; background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/imtranslator-s.png);"></div><div id="SL_shadow_translation_result2" style="display: none;"></div><div id="SL_shadow_translator" style="display: none;"><div id="SL_planshet" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/bg2.png) #f4f5f5;"><div id="SL_TB"><div id="bubblelogo" class="ImTranslatorLogo" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/imtranslator-s.png);"></div><table cellspacing="1" border="0" id="SL_tables"><tbody><tr><td class="SL_td" align="left" width="20%"><div id="SL_lng_from">English&nbsp;&#187;</div></td><td class="SL_td" align="left" width="20%"><select id="SL_lng_to"><option value="af">Afrikaans</option><option value="sq">Albanian</option><option value="ar">Arabic</option><option value="hy">Armenian</option><option value="az">Azerbaijani</option><option value="eu">Basque</option><option value="bn">Bengali</option><option value="be">Belarusian</option><option value="bg">Bulgarian</option><option value="ca">Catalan</option><option value="zh-CN">Chinese&nbsp;(Simp)</option><option value="zh-TW">Chinese&nbsp;(Trad)</option><option value="hr">Croatian</option><option value="cs">Czech</option><option value="da">Danish</option><option value="nl">Dutch</option><option value="en">English</option><option value="eo">Esperanto</option><option value="et">Estonian</option><option value="tl">Filipino</option><option value="fi">Finnish</option><option value="fr">French</option><option value="gl">Galician</option><option value="ka">Georgian</option><option value="de">German</option><option value="el">Greek</option><option value="gu">Gujarati</option><option value="ht">Haitian&nbsp;Creole</option><option value="iw">Hebrew</option><option value="hi">Hindi</option><option value="hu">Hungarian</option><option value="is">Icelandic</option><option value="id">Indonesian</option><option value="ga">Irish</option><option value="it">Italian</option><option value="ja">Japanese</option><option value="kn">Kannada</option><option value="ko">Korean</option><option value="lo">Lao</option><option value="la">Latin</option><option value="lv">Latvian</option><option value="lt">Lithuanian</option><option value="mk">Macedonian</option><option value="ms">Malay</option><option value="mt">Maltese</option><option value="no">Norwegian</option><option value="fa">Persian</option><option value="pl">Polish</option><option value="pt">Portuguese</option><option value="ro">Romanian</option><option value="ru">Russian</option><option value="sr">Serbian</option><option value="sk">Slovak</option><option value="sl">Slovenian</option><option selected="" value="es">Spanish</option><option value="sw">Swahili</option><option value="sv">Swedish</option><option value="ta">Tamil</option><option value="te">Telugu</option><option value="th">Thai</option><option value="tr">Turkish</option><option value="uk">Ukrainian</option><option value="ur">Urdu</option><option value="vi">Vietnamese</option><option value="cy">Welsh</option><option value="yi">Yiddish</option></select></td><td class="SL_td" width="13%" align="center">&nbsp;</td><td class="SL_td" width="8%" align="center"><div id="SL_TTS_voice" title="Listen to the translation" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/tts-voice.png);"></div></td><td class="SL_td" width="8%" align="center"><div id="SL_copy" title="Select text" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/copy_hand.png);"></div></td><td class="SL_td" width="8%" align="center"><div id="SL_bbl_font_patch" onclick="alert('Not available for dictionary');"></div><div id="SL_bbl_font" title="Font size" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/font-off.png);"></div></td><td class="SL_td" width="8%" align="center"><div id="SL_TH" title="Translation history" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/history.png);"></div></td><td class="SL_td" width="5%"></td><td class="SL_td" width="8%" align="right"><div id="SL_pin" title="Pin pup-up bubble" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/pin-off.png);"></div></td></tr></tbody></table></div></div><div id="SL_shadow_translation_result" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/bg.png) #ffffff;"></div><div id="SL_bbl_donate" title="Make a small contribution" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/donate2.png);"></div><div id="SL_Balloon_options" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/bg3.png) #f4f5f5;"><a href="chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/options-bbl.html" target="_blank" class="SL_options" title="Show options">Options</a>&nbsp;:&nbsp;<a href="chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/history.html" class="SL_options" title="Translation history" target="_blank">History</a>&nbsp;:&nbsp;<a href="http://about.imtranslator.net/add-ons/chrome-extension/" target="_blank" class="SL_options" title="ImTranslator Help">Help</a>&nbsp;:&nbsp;<a href="chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/feedback.html" class="SL_options" title="Feedback" target="_blank">Feedback</a></div><div id="SL_player"></div><div id="SL_alert100" style="background: url(chrome-extension://noaijdpnepcgjemiklgfkcfbkokogabh/img/util/bg2.png);">Text-to-speech function is limited to 100 characters</div></div></div><img src ="http://www.blogjava.net/qileilove/aggbug/419854.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-11-10 10:17 <a href="http://www.blogjava.net/qileilove/archive/2014/11/10/419854.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP书写程序技巧</title><link>http://www.blogjava.net/qileilove/archive/2014/10/17/418842.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 17 Oct 2014 07:29:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/10/17/418842.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/418842.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/10/17/418842.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/418842.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/418842.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">一、添加固定注释</strong></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　新建一TXT文档，将要添加的注释写在文档中</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　将文档名改为：ActionTemplate.mst</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　将文件放到<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>安装目录的dat文件夹中</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　设置好后，在QTP中每次新建一个<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>就会自动添加固定的注释</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; text-align: center; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=48833" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/10/14982672_201410161436341qu3z.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">二、调用外部vbs文件方法</strong></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　1.将通用函数写在一个vbs文件中，以供其他脚本调用</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　2.调用外部VBS文件中的通用函数的方法（二选一即可），设置完后在QTP中直接使用函数名进行调用：</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　1）通过在QTP中设置：file--&gt;settings--&gt;Resource--&gt;&#8220;添加VBS文件的路径&#8220;</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; text-align: center; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=48834" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/10/14982672_201410161436342hAU9.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; background-color: #ffffff;">　　2）在脚本中使用Executefile语句：Executefile "VBS文件路径"</div><div style="word-break: break-all; line-height: 21.6000022888184px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.8181819915771px; text-align: center; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=48835" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/10/14982672_201410161436343NGcy.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><img src ="http://www.blogjava.net/qileilove/aggbug/418842.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-10-17 15:29 <a href="http://www.blogjava.net/qileilove/archive/2014/10/17/418842.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VBS脚本启动QTP并运行测试</title><link>http://www.blogjava.net/qileilove/archive/2014/09/04/417666.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 04 Sep 2014 01:42:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/09/04/417666.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/417666.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/09/04/417666.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/417666.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/417666.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.6000003814697px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　使用vbs脚本启动<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>并运行<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>，startQTP.vbs</div><div style="word-break: break-all; line-height: 21.6000003814697px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612px; font-size: 12px; background-color: #dddddd;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">'************************************************************************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">'Description:</div><div style="word-break: break-all; margin: 10px 0px;">'</div><div style="word-break: break-all; margin: 10px 0px;">'This example opens a&nbsp;<a target="_self" style="word-break: break-all; color: #202859;"><u style="word-break: break-all;"><strong style="word-break: break-all;">test</strong></u></a>, configures run options and settings,</div><div style="word-break: break-all; margin: 10px 0px;">'runs the test, and then checks the results of the test run.</div><div style="word-break: break-all; margin: 10px 0px;">'</div><div style="word-break: break-all; margin: 10px 0px;">'Assumptions:</div><div style="word-break: break-all; margin: 10px 0px;">'There is no unsaved test currently open in QuickTest.</div><div style="word-break: break-all; margin: 10px 0px;">'For more information, see the example for the Test.SaveAs method.</div><div style="word-break: break-all; margin: 10px 0px;">'When QuickTest opens, it loads the add-ins required for the test.</div><div style="word-break: break-all; margin: 10px 0px;">'For more information, see the example for the Test.GetAssociatedAddins method.</div><div style="word-break: break-all; margin: 10px 0px;">'************************************************************************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">Dim qtApp 'As QuickTest.Application ' Declare the Application object variable</div><div style="word-break: break-all; margin: 10px 0px;">Dim qtTest 'As QuickTest.Test ' Declare a Test object variable</div><div style="word-break: break-all; margin: 10px 0px;">Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable</div><div style="word-break: break-all; margin: 10px 0px;">Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object</div><div style="word-break: break-all; margin: 10px 0px;">qtApp.Launch ' Start QuickTest</div><div style="word-break: break-all; margin: 10px 0px;">qtApp.Visible = False ' Make the QuickTest application visible</div><div style="word-break: break-all; margin: 10px 0px;">' Set QuickTest run options</div><div style="word-break: break-all; margin: 10px 0px;">qtApp.Options.Run.ImageCaptureForTestResults = "OnError"</div><div style="word-break: break-all; margin: 10px 0px;">qtApp.Options.Run.RunMode = "Fast"</div><div style="word-break: break-all; margin: 10px 0px;">qtApp.Options.Run.ViewResults = False</div><div style="word-break: break-all; margin: 10px 0px;">qtApp.Open "D:\NewTest\Scripts\BeforeGlobal\Login", False ' Open the test in read-only mode</div><div style="word-break: break-all; margin: 10px 0px;">' set run settings for the test</div><div style="word-break: break-all; margin: 10px 0px;">Set qtTest = qtApp.Test</div><div style="word-break: break-all; margin: 10px 0px;">qtTest.Settings.Run.IterationMode = "oneIteration" &nbsp;' Runs the test only once, using only the first row in the global Data Table</div><div style="word-break: break-all; margin: 10px 0px;">'qtTest.Settings.Run.IterationMode = "rngIterations" ' Run only iterations 2 to 4</div><div style="word-break: break-all; margin: 10px 0px;">'qtTest.Settings.Run.StartIteration = 2</div><div style="word-break: break-all; margin: 10px 0px;">'qtTest.Settings.Run.EndIteration = 4</div><div style="word-break: break-all; margin: 10px 0px;">qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to perform next step when error occurs</div><div style="word-break: break-all; margin: 10px 0px;">qtApp.Test.Settings.Web.BrowserNavigationTimeout = 60000 ' Configure other Web settings</div><div style="word-break: break-all; margin: 10px 0px;">Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object</div><div style="word-break: break-all; margin: 10px 0px;">qtResultsOpt.ResultsLocation = "D:\NewTest\Res1" ' Set the results location</div><div style="word-break: break-all; margin: 10px 0px;">qtTest.Run qtResultsOpt ' Run the test</div><div style="word-break: break-all; margin: 10px 0px;">'MsgBox qtTest.LastRunResults.Status ' Check the results of the test run</div><div style="word-break: break-all; margin: 10px 0px;">qtTest.Close ' Close the test</div><div style="word-break: break-all; margin: 10px 0px;">qtApp.Quit 'Close the QTP</div><div style="word-break: break-all; margin: 10px 0px;">Set qtResultsOpt = Nothing ' Release the Run Results Options object</div><div style="word-break: break-all; margin: 10px 0px;">Set qtTest = Nothing ' Release the Test object</div><div style="word-break: break-all; margin: 10px 0px;">Set qtApp = Nothing ' Release the Application object</div></td></tr></tbody></table></div><img src ="http://www.blogjava.net/qileilove/aggbug/417666.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-09-04 09:42 <a href="http://www.blogjava.net/qileilove/archive/2014/09/04/417666.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Lr11、QTP11破解时需要注意的问题</title><link>http://www.blogjava.net/qileilove/archive/2014/07/30/416314.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Wed, 30 Jul 2014 01:54:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/07/30/416314.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/416314.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/07/30/416314.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/416314.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/416314.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　虽然很早之前就成功装过这两个软件了。但是前阵子重装了系统再装这两个软件时却发现我又把破解的方法给忘了。后来从历史文档中搜索了好久才得到解决。想想这些还是需要总结，事情多了，难免忘记。也分享给需要的童鞋们。</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　LR11的破解方法</strong></div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　1)退出程序，把下载文件中的lm70.dll和mlr5lprg.dll覆盖掉..\HP\LoadRunner\bin下的这两个文件</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　2)注意，win7的话一定要以管理员身份运行启动程序，启动后，点击 configuration-&gt;loadrunner license，此时可能会有两个许可证信息存在，退出程序，点击deletelicense.exe文件，来删除刚才得许可证信息（即时原来没有lisense最好也运行一下）</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　3）再次打开程序， configuration-&gt;loadrunner license-&gt;new license，在弹出的输入框中输入license序列号AEABEXFR-YTIEKEKJJMFKEKEKWBRAUNQJU-KBYGB，点击确定，验证通过后，则破解成功！</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">QTP11的破解方法</strong></div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　1)安装成功后，手工创建：C:\Program Files\Common Files\Mercury Interactive下，</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　建立文件夹License Manager（这个很重要，必须要创建）</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　2)拷贝破解文件mgn-mqt82.exe至第一步创建的目录下。</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　3)运行破解文件，提示在C:\Program Files\Common Files\Mercury Interactive下创建了lservrc文件</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　4)用记事本打开lservrc，拷贝第一个#号前的一大串字符串。运行<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>，输入这串字符</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　5)安装QTP的<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">功能测试</strong></u></a>许可服务器安装程序（打开qtp11的安装包里边的）</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　6)删掉SafeNet Sentinel目录（C:\ProgramData\SafeNet Sentinel）</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　7)运行\HP\QuickTest Professional\bin中的instdemo.exe</div><img src ="http://www.blogjava.net/qileilove/aggbug/416314.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-07-30 09:54 <a href="http://www.blogjava.net/qileilove/archive/2014/07/30/416314.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在QTP中申明XPath</title><link>http://www.blogjava.net/qileilove/archive/2014/07/22/416065.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 22 Jul 2014 01:20:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/07/22/416065.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/416065.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/07/22/416065.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/416065.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/416065.html</trackback:ping><description><![CDATA[<span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　</span><strong style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">Example 1:<br style="word-break: break-all;" /></strong><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　&lt;body&gt;</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　&lt;h4&gt;John Smith&lt;input type=checkbox name="select" /&gt;&lt;/h4&gt;</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　&lt;body&gt;</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　&lt;h4&gt;Anne Anderson&lt;input type="checkbox" name="select" checked=true /&gt;&lt;/h4&gt;</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　In&nbsp;</span><a target="_self" style="word-break: break-all; color: #202859; line-height: normal; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">:</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　'Selecting John Smith</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　Browser("XPath").WebElement("xpath:=//h4[1]").Click</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　'Selecting Anne Anderson</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　Browser("XPath").WebElement("xpath:==/h4[contains(text(), 'Anne')]").Click)</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　</span><strong style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">Example 2:<br style="word-break: break-all;" /></strong><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　XPath:</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　1. (//tr[@class='row2']/td[1])[2]</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　2. (//td[contains(text(),'Address')])[2]</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　In QTP:</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　1. Browser("XPath").WebElement("xpath:=(//tr[@class='row2']/td[1])[2]").Click</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　2. Browser("XPath").WebElement("xpath:=(//td[contains(text(),'Address')])[2]").Click</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　</span><strong style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">Example 3:<br style="word-break: break-all;" /></strong><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　&lt;table id='table1'&gt;</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　&lt;tr class='row1' id=BPT&gt;</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　&lt;td&gt;View ID&lt;/td&gt;</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　&lt;td&gt;&lt;input type='button' value='Button 1' class='btn_blue' id='btnfirst'&gt;&lt;/td&gt;</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　&lt;/tr&gt;</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　In QTP:</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　'Selecting Button 1</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　Browser("XPath").WebButton("xpath:=//td/input[@id='btnfirst']").Click</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　'Select Button 1</span><br style="word-break: break-all; line-height: normal; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;" /><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 21.600000381469727px; background-color: #ffffff;">　　Browser("XPath").WebButton("xpath:=(//table[@id='table1']/*/*)[1]/*[2]/input").Click</span><img src ="http://www.blogjava.net/qileilove/aggbug/416065.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-07-22 09:20 <a href="http://www.blogjava.net/qileilove/archive/2014/07/22/416065.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP在webtable中查找指定字符</title><link>http://www.blogjava.net/qileilove/archive/2014/07/17/415919.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 17 Jul 2014 01:43:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/07/17/415919.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/415919.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/07/17/415919.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/415919.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/415919.html</trackback:ping><description><![CDATA[<h1><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">&#8217; 首先获取WebTable对象，然后通过ChildItem获取指定单元格中的链接对象，并单击该链接：</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; 获取WebTable对象</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　Set objTable = Browser("请登录 博都网").Page("我的<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">文章</strong></u></a>").WebTable("文章标题")</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　intRow = 2</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　intCol = 1</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; 通过ChildItem获取单元格中的链接对象</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　Set objLink = objTable.ChildItem(intRow, intCol, "Link" , 0)</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; 单击链接</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　objLink.click</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　_______________________________________________</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217;获取webtable的行数，并查找指定的内容</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　numRows = Browser("请登录 博都网_2").Page("我的文章").WebTable("文章标题").RowCount</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　For i=2 to numRows</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　title_text =Browser("请登录 博都网_2").Page("我的文章").WebTable("文章标题").GetCellData(i,1)</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　If trim(title_text) = trim(articleTitle) &nbsp;Then</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　reporter.ReportEvent 0,"<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>成功","文章列表显示新添加的文章标题"</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　Exit For</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　End If</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　Next</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217;如果table有很多页，数据不在第一页，怎么查找？</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217;&#8217;&#8217;&#8217;&#8217;&#8217;&#8217;&#8217;&#8217;&#8217;&#8217;Function : 在webTable中查找元素&#8217;&#8217;&#8217;&#8217;&#8217;&#8217;&#8217;&#8217;&#8217;</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　Function FindedItemInTable(pageObj1,WebTable_Obj1,searchStr,PageNum)</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; Finded ：标记是否从table里找到数据</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; currentPage:当前页；numRows：当前页的行数</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　Dim Finded,currentPage</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　Finded = false</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217;从第一页开始查找。</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　For currentPage = 1 to PageNum</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217;==================初始化：保证从第一页开始搜索==========================</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; If currentPage = 1 Then</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; &nbsp;pageObj.Link("pageLink").SetTOProperty "text",1</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; &nbsp;pageObj.Link("pageLink").SetTOProperty "href","javascript:forward(1)"</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; &nbsp;If &nbsp;pageObj.Link("text:=1","href:=javascript:forward(1)").Exist(1) Then</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; &nbsp; &nbsp; pageObj.Link("text:=1").Click</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; &nbsp;End If</div><div style="word-break: break-all; line-height: 21.600000381469727px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; background-color: #ffffff;">　　&#8217; End If<br /><div style="word-break: break-all; margin: 10px 0px;">　&#8217;============================================</div><div style="word-break: break-all; margin: 10px 0px;">　　If currentPage &gt;1 Then</div><div style="word-break: break-all; margin: 10px 0px;">　　pageObj.Link("pageLink").SetTOProperty "text",currentPage</div><div style="word-break: break-all; margin: 10px 0px;">　　pageObj.Link("pageLink").SetTOProperty "href","javascript:forward("&amp;currentPage&amp;")"</div><div style="word-break: break-all; margin: 10px 0px;">　　pageObj.Link("text:="&amp;currentPage).Click</div><div style="word-break: break-all; margin: 10px 0px;">　　pageObj.Sync</div><div style="word-break: break-all; margin: 10px 0px;">　　msgbox &nbsp;pageObj.GetROProperty("url")</div><div style="word-break: break-all; margin: 10px 0px;">　　End If</div><div style="word-break: break-all; margin: 10px 0px;">　　&#8217;获得当前页的行数，开始逐行搜索</div><div style="word-break: break-all; margin: 10px 0px;">　　numRows = WebTable_Obj.GetROProperty("rows")</div><div style="word-break: break-all; margin: 10px 0px;">　　msgbox numRows</div><div style="word-break: break-all; margin: 10px 0px;">　　For i=2 to numRows</div><div style="word-break: break-all; margin: 10px 0px;">　　ItemStr =Cstr(WebTable_Obj.GetCellData(i,1))</div><div style="word-break: break-all; margin: 10px 0px;">　　If trim(ItemStr) = trim(searchStr) &nbsp;Then</div><div style="word-break: break-all; margin: 10px 0px;">　　reporter.ReportEvent 0,"搜索成功","元素位于第"&amp;currentPage&amp;"页，第"&amp;i&amp;"行"</div><div style="word-break: break-all; margin: 10px 0px;">　　Finded = true</div><div style="word-break: break-all; margin: 10px 0px;">　　Exit For</div><div style="word-break: break-all; margin: 10px 0px;">　　End If</div><div style="word-break: break-all; margin: 10px 0px;">　　Next</div><div style="word-break: break-all; margin: 10px 0px;">　　&#8217;找到了，退出</div><div style="word-break: break-all; margin: 10px 0px;">　　If finded = true Then</div><div style="word-break: break-all; margin: 10px 0px;">　　Exit For</div><div style="word-break: break-all; margin: 10px 0px;">　　End If</div><div style="word-break: break-all; margin: 10px 0px;">　　Next</div><div style="word-break: break-all; margin: 10px 0px;">　　If finded = false Then</div><div style="word-break: break-all; margin: 10px 0px;">　　msgbox "没有找到数据！"</div><div style="word-break: break-all; margin: 10px 0px;">　　End If</div></div></h1><img src ="http://www.blogjava.net/qileilove/aggbug/415919.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-07-17 09:43 <a href="http://www.blogjava.net/qileilove/archive/2014/07/17/415919.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP脚本—测试参数限制</title><link>http://www.blogjava.net/qileilove/archive/2014/05/22/413956.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 22 May 2014 02:11:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/05/22/413956.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/413956.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/05/22/413956.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/413956.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/413956.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　以前一直觉得自己没有写代码的资质，太急于求成，以为一天就能写好几个功能，几千行代码，于是就没耐心了，没<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">心情</strong></u></a>学下去了....但是最近发现其实写代码是一个漫长的过程，都是在修修改改中成长起来的。于是今天试着慢慢用<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>测下参数限制，虽然代码量不多，其实也算不上编程，O(&#8745;_&#8745;)O哈哈~但也是个慢慢积累的过程。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　首先，我有一段登陆系统的<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>模块，可以把它设为可重用的，并且参数化必要的信息，比如登陆用户名密码等等，这些就不细说了。可以参见《QTP自动化测试实践》8.3节 Action测试输入的参数化，调用过程见上一篇关于action的<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">文章</strong></u></a>。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">现在我要测试参数的限制：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">　　第一步，必须要在当前项目下新建一个action，步骤如下：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　选择Insert|Call to New Action:</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; text-align: center; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=45928" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/05/14982672_201405201054031r8aa.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　然后在弹出框中填写新建action的name和description，可不可重用，以及新action的位置，这里我的参数检查功能是在登陆模块之后，所以选择第一个At the end of the&nbsp;<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">test</strong></u></a>。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; text-align: center; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=45929" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/05/14982672_201405201054032zeTD.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　第二步，既然2个action都是测试同一个软件，可以重用它们的对象库respositories，操作步骤是：</strong></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　先保存login这个action的对象库，后缀是&#8220;.tsr"，然后选择Resources|Associate Respositories，选定刚刚保存的对象库文件，然后下面的Available Action选择login模块，右边的Associated Action选择Test_Parameters模块：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; text-align: center; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=45930" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/05/14982672_201405201054033dd65.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　于是，在测试参数的模块中就可以直接使用login的对象库了。<span style="font-size: 11.818181991577148px; line-height: 21.60000228881836px; font-family: verdana, 'courier new';">　</span><strong style="font-size: 11.818181991577148px; font-family: verdana, 'courier new'; word-break: break-all; line-height: normal !important;">第三步，因为测试参数是一个繁杂的过程，有很多种组合方式</strong><span style="font-size: 11.818181991577148px; line-height: 21.60000228881836px; font-family: verdana, 'courier new';">，而且每个参数输入框都要求输入一遍，但是好在参数输入框的规则都是一样的，比如不能输入符号，字母，负数，小数，空格等等，除此之外还有范围限制，于是我就采用数据驱动测试的方法来做这个脚本。先写好输入参数的过程：</span></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 975px; font-size: 12px; background-color: #dddddd;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("MINS").Set &#8221;1&#8220;</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("MINX").Set &#8221;1&#8220;</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("MAXS").Set &#8221;2&#8220;</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("MAXX").Set &#8221;2&#8220;</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("IR").Set &#8221;1&#8220;</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("OR").Set &#8221;2&#8220;</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　然后根据数据驱动测试的步骤设置参数根据table中的值来输入，详情参见我博客《QTP：数据驱动测试》,Expert View的显示如下：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 975px; font-size: 12px; background-color: #dddddd;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("MINS").Set DataTable("minS", dtLocalSheet)</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("MINX").Set DataTable("minX", dtLocalSheet)</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("MAXS").Set DataTable("maxS", dtLocalSheet)</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("MAXX").Set DataTable("maxX", dtLocalSheet)</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("IR").Set DataTable("IR", dtLocalSheet)</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("App(1.0.1.0)").WinEdit("OR").Set DataTable("OR", dtLocalSheet)&lt;br&gt;Dialog("App(1.0.1.0)").WinButton("应用参数").Click &nbsp; &nbsp;' 点击开始应用参数</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　我设置了2种参数范围边界的数据，9种服务端会拒绝应用的参数组合，30种客户端限制的参数类型组合。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　<strong style="word-break: break-all;">第四步，对测试结果进行判断并显示在QTP生成的测试报告中：</strong></div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　开始我是这么写的：</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; font-size: 12px; background-color: #dddddd;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">If &nbsp; Dialog("App(1.0.1.0)").Dialog("提示").Exist(3) Then</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dialog("App(1.0.1.0)").Dialog("提示").WinButton("应用参数成功-确定").Click &nbsp; &nbsp;' 应用成功</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">reporter.ReportEvent micDone,"yes","前2个：可以应用成功"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">else</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">reporter.ReportEvent micFail, "yes"," 前2个：服务端拒绝应用"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">End If</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">If Dialog("App(1.0.1.0)").Dialog("错误").Exist(3) Then</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dialog("App(1.0.1.0)").Dialog("错误").WinButton("服务器不支持该参数-确定").Click</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">reporter.ReportEvent micDone,"server no","中间9个：服务端拒绝应用"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">else</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">reporter.ReportEvent micFail,"server no", "中间9个：服务端居然应用了"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">End If</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">If &nbsp;Dialog("App(1.0.1.0)").Dialog("警告").Exist(3) Then</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dialog("App(1.0.1.0)").Dialog("警告").WinButton("客户端不支持该参数-确定").Click</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">reporter.ReportEvent micDone,"client no","后30个：DTC拒绝应用"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">else</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">reporter.ReportEvent micFail,"client no", "后30个：DTC居然应用了"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">End If</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　运行之后发现，每一行参数的结果都有2个fail，因为我设置的三个主if是并列关系！符合其中一种情况之后，另外2种情况都会失败。</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　于是，我再写成这样的：</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; font-size: 12px; background-color: #dddddd;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">If &nbsp; Dialog("App(1.0.1.0)").Dialog("提示").Exist(3) Then</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dialog("App(1.0.1.0)").Dialog("提示").WinButton("应用参数成功-确定").Click &nbsp; &nbsp;' 应用成功</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">reporter.ReportEvent micDone,"yes","前2个：可以应用成功"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">elseif Dialog("App(1.0.1.0)").Dialog("错误").Exist(3) Then</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dialog("App(1.0.1.0)").Dialog("错误").WinButton("服务器不支持该参数-确定").Click</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">reporter.ReportEvent micDone,"server no","中间9个：服务端拒绝应用"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">elseif Dialog("App(1.0.1.0)").Dialog("警告").Exist(3) Then</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dialog("App(1.0.1.0)").Dialog("警告").WinButton("客户端不支持该参数-确定").Click</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">reporter.ReportEvent micDone,"client no","后30个：客户端拒绝应用"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">else</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">reporter.ReportEvent micFail, "fail"," 结果跟预期不一致"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">End If</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　现在如果全部测试通过，不会出现fail的情况，但是需要在测试报告中一层层点开，查看对于每个测试数据行的测试结果是不是符合以下描述：</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　1.前2个：可以应用成功</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　2.中间9个：服务端拒绝应用</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　3.后30个：客户端拒绝应用</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;"><a href="http://www.51testing.com/batch.download.php?aid=45931" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none;"><img src="http://www.51testing.com/attachments/2014/05/14982672_201405201054034lxyG.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　虽然上面的脚本避免了重复输入41种数据，但是后期的结果查看还是一个艰辛的过程，不知道QTP有没有把测试人员要求的结果描述统一到一个页面来的功能呢，有待挖掘。</div></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px; height: 21px; position: relative; width: 627.1875px;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; height: 21px; position: relative; width: 627.1875px; background-color: #ffffff;"></div><img src ="http://www.blogjava.net/qileilove/aggbug/413956.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-05-22 10:11 <a href="http://www.blogjava.net/qileilove/archive/2014/05/22/413956.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP校验数据库中数据后台项目</title><link>http://www.blogjava.net/qileilove/archive/2014/05/13/413601.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 13 May 2014 08:22:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/05/13/413601.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/413601.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/05/13/413601.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/413601.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/413601.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　数据校验功能后台主要包括两个类：QTPCommonServlet.java和QTPCommonDao.java</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　其中QTPCommonServlet.java为：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">package com.runqianapp.qtp;</div><div style="word-break: break-all; margin: 10px 0px;">import&nbsp;<a target="_self" style="word-break: break-all; color: #202859;"><u style="word-break: break-all;"><strong style="word-break: break-all;">java</strong></u></a>.io.PrintWriter;</div><div style="word-break: break-all; margin: 10px 0px;">import javax.servlet.http.HttpServletRequest;</div><div style="word-break: break-all; margin: 10px 0px;">import javax.servlet.http.HttpServletResponse;</div><div style="word-break: break-all; margin: 10px 0px;">import com.runqianapp.qtp.QTPCommonDao;</div><div style="word-break: break-all; margin: 10px 0px;">import com.geezn.exception.GeeznException;</div><div style="word-break: break-all; margin: 10px 0px;">import com.runqianapp.common.log.GEZLoggerManager;</div><div style="word-break: break-all; margin: 10px 0px;">import com.runqianapp.common.servlet.AbstractGezServlet;</div><div style="word-break: break-all; margin: 10px 0px;">/**</div><div style="word-break: break-all; margin: 10px 0px;">*&nbsp;<a target="_self" style="word-break: break-all; color: #202859;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>数据检查Servlet</div><div style="word-break: break-all; margin: 10px 0px;">* @author RAQ</div><div style="word-break: break-all; margin: 10px 0px;">*</div><div style="word-break: break-all; margin: 10px 0px;">*/</div><div style="word-break: break-all; margin: 10px 0px;">public class QTPCommonServlet extends AbstractGezServlet {</div><div style="word-break: break-all; margin: 10px 0px;">/**获取表中所有数据*/</div><div style="word-break: break-all; margin: 10px 0px;">private static final String GET_ALL_DATA = "getAllData";</div><div style="word-break: break-all; margin: 10px 0px;">/**检查删除操作结果*/</div><div style="word-break: break-all; margin: 10px 0px;">private static final String CHECK_DELETE_RESULT = "checkDeleteResult";</div><div style="word-break: break-all; margin: 10px 0px;">/**</div><div style="word-break: break-all; margin: 10px 0px;">* 重写service()方法</div><div style="word-break: break-all; margin: 10px 0px;">*/</div><div style="word-break: break-all; margin: 10px 0px;">public void service(HttpServletRequest request, HttpServletResponse response){</div><div style="word-break: break-all; margin: 10px 0px;">response.setContentType("text/html");</div><div style="word-break: break-all; margin: 10px 0px;">PrintWriter out = null;</div><div style="word-break: break-all; margin: 10px 0px;">try {</div><div style="word-break: break-all; margin: 10px 0px;">request.setCharacterEncoding("UTF-8");</div><div style="word-break: break-all; margin: 10px 0px;">response.setCharacterEncoding("UTF-8");</div><div style="word-break: break-all; margin: 10px 0px;">out = response.getWriter();</div><div style="word-break: break-all; margin: 10px 0px;">} catch (Exception e) {</div><div style="word-break: break-all; margin: 10px 0px;">GeeznException ge;</div><div style="word-break: break-all; margin: 10px 0px;">if(e instanceof GeeznException){</div><div style="word-break: break-all; margin: 10px 0px;">ge = (GeeznException) e;</div><div style="word-break: break-all; margin: 10px 0px;">}else{</div><div style="word-break: break-all; margin: 10px 0px;">ge = new GeeznException(QTPCommonDao.MODULE_QTP, GEZLoggerManager.LOGLEVEL_ERROR,"设置字符格式、获取输出对象时，发生错误", e, "{}");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">out.print(ge.getErrorMessageJson());</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">String action = request.getParameter("action");</div><div style="word-break: break-all; margin: 10px 0px;">if(GET_ALL_DATA.equals(action)){</div><div style="word-break: break-all; margin: 10px 0px;">String sql = request.getParameter("sql");</div><div style="word-break: break-all; margin: 10px 0px;">String sqlDateNumber = request.getParameter("sqlDateNumber");</div><div style="word-break: break-all; margin: 10px 0px;">String allDatas = "";</div><div style="word-break: break-all; margin: 10px 0px;">try {</div><div style="word-break: break-all; margin: 10px 0px;">allDatas = QTPCommonDao.getAllDatas(sql,sqlDateNumber);</div><div style="word-break: break-all; margin: 10px 0px;">} catch (GeeznException e) {</div><div style="word-break: break-all; margin: 10px 0px;">GeeznException ge;</div><div style="word-break: break-all; margin: 10px 0px;">if(e instanceof GeeznException){</div><div style="word-break: break-all; margin: 10px 0px;">ge = (GeeznException) e;</div><div style="word-break: break-all; margin: 10px 0px;">}else{</div><div style="word-break: break-all; margin: 10px 0px;">ge = new GeeznException(QTPCommonDao.MODULE_QTP, GEZLoggerManager.LOGLEVEL_ERROR,"得到表中数据时，发生错误", e, "{}");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">out.print(ge.getErrorMessageJson());</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">out.print(allDatas);</div><div style="word-break: break-all; margin: 10px 0px;">}else if(CHECK_DELETE_RESULT.equals(action)){</div><div style="word-break: break-all; margin: 10px 0px;">String sql = request.getParameter("sql");</div><div style="word-break: break-all; margin: 10px 0px;">boolean deleteResult = false;</div><div style="word-break: break-all; margin: 10px 0px;">try {</div><div style="word-break: break-all; margin: 10px 0px;">deleteResult = QTPCommonDao.checkDeleteResult(sql);</div><div style="word-break: break-all; margin: 10px 0px;">} catch (GeeznException e) {</div><div style="word-break: break-all; margin: 10px 0px;">GeeznException ge;</div><div style="word-break: break-all; margin: 10px 0px;">if(e instanceof GeeznException){</div><div style="word-break: break-all; margin: 10px 0px;">ge = (GeeznException) e;</div><div style="word-break: break-all; margin: 10px 0px;">}else{</div><div style="word-break: break-all; margin: 10px 0px;">ge = new GeeznException(QTPCommonDao.MODULE_QTP, GEZLoggerManager.LOGLEVEL_ERROR,"检查删除动作结果时，发生错误", e, "{}");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">out.print(ge.getErrorMessageJson());</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">out.print(deleteResult);</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">}</div></td></tr></tbody></table><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　QTPCommonDao.java为：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">package com.runqianapp.qtp;</div><div style="word-break: break-all; margin: 10px 0px;">import java.sql.*;</div><div style="word-break: break-all; margin: 10px 0px;">import com.geezn.exception.GeeznException;</div><div style="word-break: break-all; margin: 10px 0px;">import com.runqian.mis2.util.DBAccess;</div><div style="word-break: break-all; margin: 10px 0px;">import com.runqianapp.common.log.GEZLoggerManager;</div><div style="word-break: break-all; margin: 10px 0px;">/**</div><div style="word-break: break-all; margin: 10px 0px;">* QTP通用数据库操作类</div><div style="word-break: break-all; margin: 10px 0px;">* @author RAQ</div><div style="word-break: break-all; margin: 10px 0px;">*</div><div style="word-break: break-all; margin: 10px 0px;">*/</div><div style="word-break: break-all; margin: 10px 0px;">public class QTPCommonDao {</div><div style="word-break: break-all; margin: 10px 0px;">/**</div><div style="word-break: break-all; margin: 10px 0px;">* 用于存储表字段名称，各字段名称之间用&#8220;;&#8221;分隔</div><div style="word-break: break-all; margin: 10px 0px;">*/</div><div style="word-break: break-all; margin: 10px 0px;">public static StringBuffer columns = new StringBuffer();</div><div style="word-break: break-all; margin: 10px 0px;">/**</div><div style="word-break: break-all; margin: 10px 0px;">* 用于存储当前操作表名</div><div style="word-break: break-all; margin: 10px 0px;">*/</div><div style="word-break: break-all; margin: 10px 0px;">public static String tableName = "";</div><div style="word-break: break-all; margin: 10px 0px;">/**</div><div style="word-break: break-all; margin: 10px 0px;">* 用于日志输出，模块标识</div><div style="word-break: break-all; margin: 10px 0px;">*/</div><div style="word-break: break-all; margin: 10px 0px;">public static final String MODULE_QTP = "qtpModule";</div><div style="word-break: break-all; margin: 10px 0px;">/***</div><div style="word-break: break-all; margin: 10px 0px;">* 获取表字段名称及所有数据信息</div><div style="word-break: break-all; margin: 10px 0px;">* @param sql 用户输入的查询sql语句</div><div style="word-break: break-all; margin: 10px 0px;">* @param sqlDateNumber 查询数据条数(保留功能，目前暂不处理)</div><div style="word-break: break-all; margin: 10px 0px;">* @return 表字段名称及所有链接信息 如："short_link;...;link_name||/link1,...，百度@_@{};/link2,...,谷歌@_@{}"</div><div style="word-break: break-all; margin: 10px 0px;">* &nbsp; &nbsp; &nbsp; &nbsp; 表字段名称与表数据之间用"||"分隔，各表字段名称之间与各表数据之间用";"分隔，每条表数据内部用"#"和"@_@"分隔</div><div style="word-break: break-all; margin: 10px 0px;">* &nbsp; &nbsp; &nbsp; &nbsp; 其中"#"用来分隔表字段数据，"@_@"用来分隔表字段数据与json字符串</div><div style="word-break: break-all; margin: 10px 0px;">* @throws GeeznException</div><div style="word-break: break-all; margin: 10px 0px;">*/</div><div style="word-break: break-all; margin: 10px 0px;">public static synchronized String getAllDatas(String sql, String sqlDateNumber)</div><div style="word-break: break-all; margin: 10px 0px;">throws GeeznException {</div><div style="word-break: break-all; margin: 10px 0px;">getTableName(sql); &nbsp;//解析出表名</div><div style="word-break: break-all; margin: 10px 0px;">PreparedStatement pstmt = null;</div><div style="word-break: break-all; margin: 10px 0px;">DBAccess dba = null;</div><div style="word-break: break-all; margin: 10px 0px;">ResultSet rs = null;</div><div style="word-break: break-all; margin: 10px 0px;">StringBuffer allDatas = new StringBuffer(); &nbsp;//方法返回的字符串</div><div style="word-break: break-all; margin: 10px 0px;">try {</div><div style="word-break: break-all; margin: 10px 0px;">dba = new DBAccess();</div><div style="word-break: break-all; margin: 10px 0px;">rs = dba.executeQuery(sql);</div><div style="word-break: break-all; margin: 10px 0px;">ResultSetMetaData rsmd = rs.getMetaData();</div><div style="word-break: break-all; margin: 10px 0px;">int columnCount = rsmd.getColumnCount();</div><div style="word-break: break-all; margin: 10px 0px;">/** 每次请求处理之前，先对columns进行一次清空 */</div><div style="word-break: break-all; margin: 10px 0px;">columns = columns.delete(0, columns.length());</div><div style="word-break: break-all; margin: 10px 0px;">/** 在返回的字符串里添加表字段信息 */</div><div style="word-break: break-all; margin: 10px 0px;">for (int i = 1; i &lt;= columnCount; i++) {</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.append(rsmd.getColumnName(i)).append(";");</div><div style="word-break: break-all; margin: 10px 0px;">columns.append(rsmd.getColumnName(i)).append(";");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.deleteCharAt(allDatas.length() - 1);</div><div style="word-break: break-all; margin: 10px 0px;">columns.deleteCharAt(columns.length() - 1);</div><div style="word-break: break-all; margin: 10px 0px;">String[] column = columns.toString().split(";");</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.append("||");</div><div style="word-break: break-all; margin: 10px 0px;">/** 在返回的字符串里添加表数据信息 */</div><div style="word-break: break-all; margin: 10px 0px;">while (rs.next()) {</div><div style="word-break: break-all; margin: 10px 0px;">for (int i = 0; i &lt; column.length; i++) {</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.append(rs.getString(column[i])).append("#");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.deleteCharAt(allDatas.length() - 1);</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.append("@_@"); &nbsp;//以"@_@"符号分隔前台的数据字段信息和整条数据信息</div><div style="word-break: break-all; margin: 10px 0px;">/**生成每条数据的json字符串*/</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.append("{");</div><div style="word-break: break-all; margin: 10px 0px;">for (int i = 0; i &lt; column.length; i++) {</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.append("\"").append(column[i]).append("\"")</div><div style="word-break: break-all; margin: 10px 0px;">.append(":")</div><div style="word-break: break-all; margin: 10px 0px;">.append("\"").append(rs.getString(column[i])).append("\"")</div><div style="word-break: break-all; margin: 10px 0px;">.append(",");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.deleteCharAt(allDatas.length() - 1);</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.append("}");</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.append(";");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">allDatas.deleteCharAt(allDatas.length() - 1);</div><div style="word-break: break-all; margin: 10px 0px;">} catch(Exception e){</div><div style="word-break: break-all; margin: 10px 0px;">throw new GeeznException(QTPCommonDao.MODULE_QTP, GEZLoggerManager.LOGLEVEL_ERROR,"根据传入的sql获取数据时，发生错误", e,"{}");</div><div style="word-break: break-all; margin: 10px 0px;">} finally {</div><div style="word-break: break-all; margin: 10px 0px;">close(dba, pstmt, rs);</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">return allDatas.toString();</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">/**</div><div style="word-break: break-all; margin: 10px 0px;">* 从用户输入的sql语句中解析出表名并存入变量tableName中</div><div style="word-break: break-all; margin: 10px 0px;">* @param sql 用户输入的sql语句</div><div style="word-break: break-all; margin: 10px 0px;">*/</div><div style="word-break: break-all; margin: 10px 0px;">public static void getTableName(String sql){</div><div style="word-break: break-all; margin: 10px 0px;">if (sql.contains("where") || sql.contains("WHERE")) {</div><div style="word-break: break-all; margin: 10px 0px;">int start = 0;</div><div style="word-break: break-all; margin: 10px 0px;">int end = 0;</div><div style="word-break: break-all; margin: 10px 0px;">if (sql.contains("from")) {</div><div style="word-break: break-all; margin: 10px 0px;">start = sql.indexOf("from");</div><div style="word-break: break-all; margin: 10px 0px;">} else if (sql.contains("FROM")) {</div><div style="word-break: break-all; margin: 10px 0px;">start = sql.indexOf("FROM");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">if (sql.contains("where")) {</div><div style="word-break: break-all; margin: 10px 0px;">end = sql.indexOf("where");</div><div style="word-break: break-all; margin: 10px 0px;">} else if (sql.contains("WHERE")) {</div><div style="word-break: break-all; margin: 10px 0px;">end = sql.indexOf("WHERE");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">if (start == 0 || end == 0) {</div><div style="word-break: break-all; margin: 10px 0px;">System.out.println("解析表名失败");</div><div style="word-break: break-all; margin: 10px 0px;">} else {</div><div style="word-break: break-all; margin: 10px 0px;">tableName = sql.substring(start + 5, end);</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">} else {</div><div style="word-break: break-all; margin: 10px 0px;">int start = 0;</div><div style="word-break: break-all; margin: 10px 0px;">if (sql.contains("from")) {</div><div style="word-break: break-all; margin: 10px 0px;">start = sql.indexOf("from");</div><div style="word-break: break-all; margin: 10px 0px;">} else if (sql.contains("FROM")) {</div><div style="word-break: break-all; margin: 10px 0px;">start = sql.indexOf("FROM");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">if (start == 0) {</div><div style="word-break: break-all; margin: 10px 0px;">System.out.println("解析表名失败");</div><div style="word-break: break-all; margin: 10px 0px;">} else {</div><div style="word-break: break-all; margin: 10px 0px;">tableName = sql.substring(start + 5, sql.length());</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">/**</div><div style="word-break: break-all; margin: 10px 0px;">* 判断某条数据是否已被成功删除方法</div><div style="word-break: break-all; margin: 10px 0px;">* @param sql 查询删除数据的sql语句</div><div style="word-break: break-all; margin: 10px 0px;">* @return &nbsp;返回某条超链接是否已被成功删除 true：已被删除 false：没有被删除</div><div style="word-break: break-all; margin: 10px 0px;">* @throws GeeznException</div><div style="word-break: break-all; margin: 10px 0px;">*/</div><div style="word-break: break-all; margin: 10px 0px;">public static synchronized Boolean checkDeleteResult(String sql)throws GeeznException{</div><div style="word-break: break-all; margin: 10px 0px;">boolean flag = true; //方法返回的字符串</div><div style="word-break: break-all; margin: 10px 0px;">DBAccess dba = null;</div><div style="word-break: break-all; margin: 10px 0px;">ResultSet rs = null;</div><div style="word-break: break-all; margin: 10px 0px;">try{</div><div style="word-break: break-all; margin: 10px 0px;">dba = new DBAccess();</div><div style="word-break: break-all; margin: 10px 0px;">rs = dba.executeQuery(sql);</div><div style="word-break: break-all; margin: 10px 0px;">while(rs.next()){</div><div style="word-break: break-all; margin: 10px 0px;">flag = false;</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">}catch(Exception e){</div><div style="word-break: break-all; margin: 10px 0px;">throw new GeeznException(QTPCommonDao.MODULE_QTP, GEZLoggerManager.LOGLEVEL_ERROR,"判断某条数据是否已被成功删除时，发生错误", e,"{}");</div><div style="word-break: break-all; margin: 10px 0px;">}finally{</div><div style="word-break: break-all; margin: 10px 0px;">close(dba, null, rs);</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">return flag;</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">/**关闭所有连接</div><div style="word-break: break-all; margin: 10px 0px;">* @throws GeeznException</div><div style="word-break: break-all; margin: 10px 0px;">*/</div><div style="word-break: break-all; margin: 10px 0px;">private static void close(DBAccess dba,Statement ps,ResultSet rs) throws GeeznException{</div><div style="word-break: break-all; margin: 10px 0px;">try{</div><div style="word-break: break-all; margin: 10px 0px;">if(rs!=null){</div><div style="word-break: break-all; margin: 10px 0px;">rs.close();</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">if(ps!=null){</div><div style="word-break: break-all; margin: 10px 0px;">ps.close();</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">if(dba!=null){</div><div style="word-break: break-all; margin: 10px 0px;">dba.close();</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">}catch(Exception e){</div><div style="word-break: break-all; margin: 10px 0px;">throw new GeeznException(QTPCommonDao.MODULE_QTP, GEZLoggerManager.LOGLEVEL_ERROR,"关闭所有连接时，发生错误", e,"{}");</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">}</div><div style="word-break: break-all; margin: 10px 0px;">}</div></td></tr></tbody></table></div></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; height: 21px; position: relative; width: 627.1875px;"></div><img src ="http://www.blogjava.net/qileilove/aggbug/413601.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-05-13 16:22 <a href="http://www.blogjava.net/qileilove/archive/2014/05/13/413601.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP处理各类鼠标事件fireEvent</title><link>http://www.blogjava.net/qileilove/archive/2014/05/04/413210.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Sun, 04 May 2014 05:00:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/05/04/413210.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/413210.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/05/04/413210.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/413210.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/413210.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">在做<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">web</strong></u></a><a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>时，页面上的HTML标签会包含各类事件：单击（onclick）、双击(onDblClick)、光标聚集（OnBlur）、onchange、onfocus、onmousedown、onmouseup、onmouseover、onmouseout、onsubmit、onreset、onpropertychange等。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　在用<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>录制时，有可能会有一些事件录制不到。这时候你可以进行一些设置，QTP/tools/Web Event Recording Configuration/custom settings/event/add就可以添加你想要录制下来的事件啦。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　当然，这篇<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">文章</strong></u></a>的主题并不是上述这些。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　先描述一下我的问题，项目中碰到一个列表控件，是采用ligerUI做的，双击列表中的一行，会读到这一行的内容，然后把数据赋给页面的其他标签，还包括一些隐藏域。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　首先，我在录制的时候发现双击事件录不到（上述Web Event Recording Configuration已经设置好），于是采用低级别录制，双击事件顺利录制到。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　接着，在回放的时候，发现双击事件失效，并没有如预期中的，我双击一个项，然后页面别的元素获取到他的值。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　我的第一个操作是，因为知道整个页面实现的逻辑是，获取到每一项的唯一标志符后，把这个值赋给页面的一个隐藏域，然后后续的<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">工作</strong></u></a>就都可以顺利进行了。因为这里涉及到隐藏域的问题，我们知道QTP采用的是对象识别的模式，意识就是，他只能识别他看的到的，在表面上显示出来的对象。这里采用DOM对象的方法，DOM是直接从源代码（HTML页面）获取对象。所以页面上的各种隐藏域，各种可以通过标签、ID、属性等获取到的对象就可以很顺利的在QTP中读取到。DOM对象也很简单，只需要在你想要识别的对象的父对象后面加上&#8220; .Object &#8221;，然后就可以通过getElementById("id")、document.getElementById("id")、getElementsByName("html tag")等各种js获取对象的方法来对页面为所欲为了。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　比如这里，我的实现代码就变成了：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">1 set obj = &nbsp;Browser("Browser").Page("Page").Object.getElementById("verifyID")</div><div style="word-break: break-all; margin: 10px 0px;">2 obj.value = "0101002699"</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　这个只是很肤浅的解决了问题，但页面上该显示正确值的地方的值还是空的。那就是说还得弄一个能真正解决该问题的方法。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　现在我们就引入了fireevent方法。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　fireevent是JS中的一个方法，以下摘自MSDN的解释</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=45587" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/04/14982672_201404301113301xRH4.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　fireevent执行的效果就是&#8220;等同于&#8221;在目标元素上进行了相关操作。可以模拟各种包括单击在内的，文章一开头就列出来的各种操作。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　那我上面遇到的问题的解决办法就是：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Set list = &nbsp;Browser("Browser").Page("Page").WebElement("list").Object</div><div style="word-break: break-all; margin: 10px 0px;">list.document.getElementById("maingrid4|2|r1001").fireevent("ondblclick")</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　这样，我想要的双击事件的回放问题，就顺利解决啦。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; height: 21px; position: relative; width: 627.1875px;"></div><img src ="http://www.blogjava.net/qileilove/aggbug/413210.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-05-04 13:00 <a href="http://www.blogjava.net/qileilove/archive/2014/05/04/413210.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP自动化测试-TXT文件操作</title><link>http://www.blogjava.net/qileilove/archive/2014/04/15/412441.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 15 Apr 2014 02:55:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/04/15/412441.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/412441.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/04/15/412441.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/412441.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/412441.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　创建文本文件</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Set bjFile = objFSO.CreateTextFile("C:\FSOScriptLog.txt")</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　检察文件是否存在</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; margin: 10px 0px;">If objFSO.FileExists("C:\FSOScriptLog.txt") Then</div><div style="word-break: break-all; margin: 10px 0px;">Set bjFolder = objFSO.GetFile("C:\FSOScriptLog.txt")</div><div style="word-break: break-all; margin: 10px 0px;">Else</div><div style="word-break: break-all; margin: 10px 0px;">MsgBox "File does not exist."</div><div style="word-break: break-all; margin: 10px 0px;">End If</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　删除文本文件</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　objFSO.DeleteFile("C:\FSOScriptLog.txt")</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">移动</strong></u></a>文件</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　objFSO.MoveFile "C:\FSOScriptLog.txt" , "D:\"</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　复制文件</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　objFSO.CopyFile "C:\FSOScriptLog.txt" , "D:\"</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　重命名文件</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　objFSO.MoveFile "C:\FSO\ScriptLog.txt" , "C:\FSO\BackupLog.txt"</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　读取全部内容</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Const ForReading = 1</div><div style="word-break: break-all; margin: 10px 0px;">Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; margin: 10px 0px;">Set bjFile = objFSO.OpenTextFile("C:ScriptsTest.txt", ForReading)</div><div style="word-break: break-all; margin: 10px 0px;">strContents = objFile.ReadAll</div><div style="word-break: break-all; margin: 10px 0px;">Wscript.Echo strContents</div><div style="word-break: break-all; margin: 10px 0px;">objFile.Close</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　一行行的读取文本文件内容</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Const ForReading = 1</div><div style="word-break: break-all; margin: 10px 0px;">Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; margin: 10px 0px;">Set bjTextFile = objFSO.OpenTextFile ("C: \ScriptsTest.txt", ForReading)</div><div style="word-break: break-all; margin: 10px 0px;">Do Until objTextFile.AtEndOfStream</div><div style="word-break: break-all; margin: 10px 0px;">strComputer = objTextFile.ReadLine</div><div style="word-break: break-all; margin: 10px 0px;">Wscript.Echo strComputer</div><div style="word-break: break-all; margin: 10px 0px;">Loop</div><div style="word-break: break-all; margin: 10px 0px;">objTextFile.Close</div></td></tr></tbody></table><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　追加文本文件一行内容</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Const ForAppending = 8</div><div style="word-break: break-all; margin: 10px 0px;">Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; margin: 10px 0px;">Set bjTextFile = objFSO.OpenTextFile ("C:\ScriptsTest.txt ", ForAppending, True)</div><div style="word-break: break-all; margin: 10px 0px;">objTextFile.WriteLine("追加的内容")</div><div style="word-break: break-all; margin: 10px 0px;">objTextFile.Close</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　有用的几个函数：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　替换：将Jim替换成James。</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　strNewText = Replace(strText, "Jim ", "James ")</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　用逗号分隔字符串：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　arrpath=split(strDN,",")</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　wscript.echo arrpath(0)</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　读取文本文件指定的行内容（读第四行内容存到strLine变量中）</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Const ForReading = 1</div><div style="word-break: break-all; margin: 10px 0px;">Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; margin: 10px 0px;">Set bjTextFile = objFSO.OpenTextFile("C:\ScriptsTest.txt ", ForReading)</div><div style="word-break: break-all; margin: 10px 0px;">For i = 1 to 3</div><div style="word-break: break-all; margin: 10px 0px;">objTextFile.ReadLine</div><div style="word-break: break-all; margin: 10px 0px;">Next</div><div style="word-break: break-all; margin: 10px 0px;">strLine = objTextFile.Readline</div><div style="word-break: break-all; margin: 10px 0px;">MsgBox strLine</div><div style="word-break: break-all; margin: 10px 0px;">objTextFile.Close</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　查看文件属性</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; margin: 10px 0px;">Set bjFile = objFSO.GetFile("c:\ScriptsTest.txt")</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Date created: " &amp; objFile.DateCreated</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Date last accessed: " &amp; objFile.DateLastAccessed</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Date last modified: " &amp; objFile.DateLastModified</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Drive: " &amp; objFile.Drive</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Name: " &amp; objFile.Name</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Parent folder: " &amp; objFile.ParentFolder</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Path: " &amp; objFile.Path</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Short name: " &amp; objFile.ShortName</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Short path: " &amp; objFile.ShortPath</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Size: " &amp; objFile.Size</div><div style="word-break: break-all; margin: 10px 0px;">msgbox "Type: " &amp; objFile.Type</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　修改文件属性</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Set bjFSO = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; margin: 10px 0px;">Set bjFile = objFSO.GetFile("C:\ScriptsTest.txt")</div><div style="word-break: break-all; margin: 10px 0px;">If objFile.Attributes AND 1 Then</div><div style="word-break: break-all; margin: 10px 0px;">objFile.Attributes = objFile.Attributes XOR 1</div><div style="word-break: break-all; margin: 10px 0px;">End If</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">　　写入文本文件</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Const ForWriting=2</div><div style="word-break: break-all; margin: 10px 0px;">Set bj=createobject("scripting.filesystemobject")</div><div style="word-break: break-all; margin: 10px 0px;">Set bjfile=obj.opentextfile("C:\ScriptsTest.txt", ForWriting)</div><div style="word-break: break-all; margin: 10px 0px;">objfile.write("This is line 1.")</div><div style="word-break: break-all; margin: 10px 0px;">objfile.writeline("This is line2.")</div><div style="word-break: break-all; margin: 10px 0px;">objfile.close</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; font-size: 11.818181991577148px;">版权声明：本文出自 wpt1987 的51Testing软件测试博客：http://www.51testing.com/?365260</div></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; height: 21px; position: relative; width: 627.1875px;"></div><img src ="http://www.blogjava.net/qileilove/aggbug/412441.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-04-15 10:55 <a href="http://www.blogjava.net/qileilove/archive/2014/04/15/412441.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP批量执行并发邮件</title><link>http://www.blogjava.net/qileilove/archive/2014/04/10/412184.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 10 Apr 2014 02:45:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/04/10/412184.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/412184.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/04/10/412184.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/412184.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/412184.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Option Explicit</div><div style="word-break: break-all; margin: 10px 0px;">'*****************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">'脚本说明：公共变量声明，路径根据实际环境修改</div><div style="word-break: break-all; margin: 10px 0px;">'*****************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">Dim ReportLocation '报告存放路径</div><div style="word-break: break-all; margin: 10px 0px;">ReportLocation = "D:\project\QTP\qtpscript\"</div><div style="word-break: break-all; margin: 10px 0px;">Dim QtpLocation 'Qtp安装路径</div><div style="word-break: break-all; margin: 10px 0px;">QtpLocation = "D:\softwaretesting\Mercury Interactive\QuickTest Professional\bin\QTPro.exe"</div><div style="word-break: break-all; margin: 10px 0px;">'*****************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">'脚本说明：启动<a target="_self" style="word-break: break-all; color: #202859;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a></div><div style="word-break: break-all; margin: 10px 0px;">'*****************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">Dim WshShell,oExec</div><div style="word-break: break-all; margin: 10px 0px;">set WshShell = WScript.CreateObject("WScript.Shell")</div><div style="word-break: break-all; margin: 10px 0px;">Set Exec = WshShell.Exec (QtpLocation)</div><div style="word-break: break-all; margin: 10px 0px;">Set WshShell = Nothing</div><div style="word-break: break-all; margin: 10px 0px;">WScript.Sleep 60000 '等待1分钟</div><div style="word-break: break-all; margin: 10px 0px;">'*****************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">'脚本说明：判断文件是否存在，存在删除</div><div style="word-break: break-all; margin: 10px 0px;">'*****************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">Dim oFSO</div><div style="word-break: break-all; margin: 10px 0px;">' 创建一个文件系统对象</div><div style="word-break: break-all; margin: 10px 0px;">set FSO = CreateObject ("Scripting.FileSystemObject")</div><div style="word-break: break-all; margin: 10px 0px;">CheckFileExists(ReportLocation)</div><div style="word-break: break-all; margin: 10px 0px;">Function CheckFileExists (FilePath)</div><div style="word-break: break-all; margin: 10px 0px;">FilePath = FilePath &amp;"<a target="_self" style="word-break: break-all; color: #202859;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>结果1.html"</div><div style="word-break: break-all; margin: 10px 0px;">' 检查文件是否存在，如果存在删除</div><div style="word-break: break-all; margin: 10px 0px;">CheckFileExists = oFSO.FileExists(FilePath)</div><div style="word-break: break-all; margin: 10px 0px;">'MsgBox CheckFileExists</div><div style="word-break: break-all; margin: 10px 0px;">If (CheckFileExists = true) Then</div><div style="word-break: break-all; margin: 10px 0px;">oFSO.DeleteFile (FilePath)</div><div style="word-break: break-all; margin: 10px 0px;">End if</div><div style="word-break: break-all; margin: 10px 0px;">End Function</div><div style="word-break: break-all; margin: 10px 0px;">'*****************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">'脚本说明：批量执行脚本并生成摘要报告</div><div style="word-break: break-all; margin: 10px 0px;">'*****************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">Dim oMTM</div><div style="word-break: break-all; margin: 10px 0px;">' 创建 Multi&nbsp;<a target="_self" style="word-break: break-all; color: #202859;"><u style="word-break: break-all;"><strong style="word-break: break-all;">Test</strong></u></a>&nbsp;Manager 对象</div><div style="word-break: break-all; margin: 10px 0px;">Set MTM = CreateObject("MultiTestManager.Application")</div><div style="word-break: break-all; margin: 10px 0px;">oMTM.Visible = True</div><div style="word-break: break-all; margin: 10px 0px;">' 修改运行时的默认设置</div><div style="word-break: break-all; margin: 10px 0px;">Dim oRunSettings</div><div style="word-break: break-all; margin: 10px 0px;">Set RunSettings = oMTM.Preferences.RunSettings</div><div style="word-break: break-all; margin: 10px 0px;">oRunSettings.Iterations = 1</div><div style="word-break: break-all; margin: 10px 0px;">oRunSettings.CloseQuickTest = True</div><div style="word-break: break-all; margin: 10px 0px;">'打开注释启用定时调度</div><div style="word-break: break-all; margin: 10px 0px;">'oRunSettings.ScheduleRun = True</div><div style="word-break: break-all; margin: 10px 0px;">'oRunSettings.Day = 3</div><div style="word-break: break-all; margin: 10px 0px;">'oRunSettings.Month = 12</div><div style="word-break: break-all; margin: 10px 0px;">'oRunSettings.Year = 2009</div><div style="word-break: break-all; margin: 10px 0px;">'oRunSettings.Second = 00</div><div style="word-break: break-all; margin: 10px 0px;">'oRunSettings.Minute = 55</div><div style="word-break: break-all; margin: 10px 0px;">'oRunSettings.Hour = 15</div><div style="word-break: break-all; margin: 10px 0px;">' 修改报告的默认设置</div><div style="word-break: break-all; margin: 10px 0px;">Dim oReportSettings</div><div style="word-break: break-all; margin: 10px 0px;">Set ReportSettings = oMTM.Preferences.ReportSettings</div><div style="word-break: break-all; margin: 10px 0px;">oReportSettings.CreateReport = True</div><div style="word-break: break-all; margin: 10px 0px;">oReportSettings.OverwriteReport = False</div><div style="word-break: break-all; margin: 10px 0px;">oReportSettings.DefaultLocation = False</div><div style="word-break: break-all; margin: 10px 0px;">oReportSettings.ReportLocation = ReportLocation '报告存放路径</div><div style="word-break: break-all; margin: 10px 0px;">oReportSettings.ReportName = "测试结果"</div><div style="word-break: break-all; margin: 10px 0px;">oReportSettings.ViewReport = True</div><div style="word-break: break-all; margin: 10px 0px;">'批量执行脚本：脚本的目录，是否执行，执行结果存放位置</div><div style="word-break: break-all; margin: 10px 0px;">oMTM.AddTestScript. "D:\project\QTP\qtpscript\rarTest", True,ReportLocation</div><div style="word-break: break-all; margin: 10px 0px;">'oMTM.AddTestScript. "D:\project\QTP\qtpscript\rarTest", True,ReportLocation 根据脚本进行添加</div><div style="word-break: break-all; margin: 10px 0px;">' 运行脚本</div><div style="word-break: break-all; margin: 10px 0px;">oMTM.Run</div><div style="word-break: break-all; margin: 10px 0px;">while ( oMTM.IsRunning )</div><div style="word-break: break-all; margin: 10px 0px;">Wend</div><div style="word-break: break-all; margin: 10px 0px;">oMTM.Quit</div><div style="word-break: break-all; margin: 10px 0px;">Set RunSettings = Nothing</div><div style="word-break: break-all; margin: 10px 0px;">Set ReportSettings = Nothing</div><div style="word-break: break-all; margin: 10px 0px;">Set MTM = Nothing</div></td></tr></tbody></table><table align="center" style="word-break: break-all; color: #333333; font-size: 12px; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">'*****************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">'脚本说明：将运行结果发送邮件</div><div style="word-break: break-all; margin: 10px 0px;">'*****************************************************************</div><div style="word-break: break-all; margin: 10px 0px;">Dim SendTo, Subject, Body, Attachment</div><div style="word-break: break-all; margin: 10px 0px;">'SendTo ="test@163.com;test1@163.com" '发送多个邮箱以分号分割</div><div style="word-break: break-all; margin: 10px 0px;">SendTo ="test@163.com"</div><div style="word-break: break-all; margin: 10px 0px;">Subject ="自动化测试结果"</div><div style="word-break: break-all; margin: 10px 0px;">Body ="自动化测试结果"</div><div style="word-break: break-all; margin: 10px 0px;">Attachment =ReportLocation&amp;"测试结果1.html"</div><div style="word-break: break-all; margin: 10px 0px;">'SendMail SendTo, Subject, Body, Attachment</div><div style="word-break: break-all; margin: 10px 0px;">Function SendMail(SendTo, Subject, Body, Attachment)</div><div style="word-break: break-all; margin: 10px 0px;">Dim ol,Mail</div><div style="word-break: break-all; margin: 10px 0px;">Set l=CreateObject("Outlook.Application")</div><div style="word-break: break-all; margin: 10px 0px;">Set Mail=ol.CreateItem(0)</div><div style="word-break: break-all; margin: 10px 0px;">Mail.to=SendTo</div><div style="word-break: break-all; margin: 10px 0px;">Mail.Subject=Subject</div><div style="word-break: break-all; margin: 10px 0px;">Mail.Body=Body</div><div style="word-break: break-all; margin: 10px 0px;">If (Attachment &lt;&gt; "") Then</div><div style="word-break: break-all; margin: 10px 0px;">Mail.Attachments.Add(Attachment)</div><div style="word-break: break-all; margin: 10px 0px;">End If</div><div style="word-break: break-all; margin: 10px 0px;">' Mail.display '邮件显示</div><div style="word-break: break-all; margin: 10px 0px;">Mail.Send</div><div style="word-break: break-all; margin: 10px 0px;">ol.Quit</div><div style="word-break: break-all; margin: 10px 0px;">Set Mail = Nothing</div><div style="word-break: break-all; margin: 10px 0px;">Set l = Nothing</div><div style="word-break: break-all; margin: 10px 0px;">End Function</div></td></tr></tbody></table><br /></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; height: 21px; position: relative; width: 627.1875px;"></div><img src ="http://www.blogjava.net/qileilove/aggbug/412184.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-04-10 10:45 <a href="http://www.blogjava.net/qileilove/archive/2014/04/10/412184.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP VBScript RegExp对象的运用</title><link>http://www.blogjava.net/qileilove/archive/2014/04/09/412126.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Wed, 09 Apr 2014 02:31:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/04/09/412126.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/412126.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/04/09/412126.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/412126.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/412126.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　下面来讲讲RegExp对象：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Vbs提供了针对正则表达式的一个非常实用的类，就是RegExp</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Global属性：代表全局匹配</div><div style="word-break: break-all; margin: 10px 0px;">IgnoreCase属性：大小写忽略</div><div style="word-break: break-all; margin: 10px 0px;">Pattern属性：正则表达式</div><div style="word-break: break-all; margin: 10px 0px;">Execute方法：匹配搜索，返回匹配结果集合</div><div style="word-break: break-all; margin: 10px 0px;">Replace方法：匹配代替，返回替代匹配结果</div><div style="word-break: break-all; margin: 10px 0px;">Test方法：<a target="_self" style="word-break: break-all; color: #202859;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>匹配，返回布尔类型</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　下面举几个实例：</div><div style="word-break: break-all; line-height: 21.60000228881836px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">'判断正则匹配是否正确</div><div style="word-break: break-all; margin: 10px 0px;">'msgbox (IsRegMatch("a123","http://www.123.456.com"))</div><div style="word-break: break-all; margin: 10px 0px;">Function IsRegMatch(patrn,str)</div><div style="word-break: break-all; margin: 10px 0px;">Dim regEx</div><div style="word-break: break-all; margin: 10px 0px;">Set regEx = New RegExp</div><div style="word-break: break-all; margin: 10px 0px;">regEx.Pattern = patrn</div><div style="word-break: break-all; margin: 10px 0px;">regEx.IgnoreCase = False</div><div style="word-break: break-all; margin: 10px 0px;">IsRegMatch = regEx.Test(str)</div><div style="word-break: break-all; margin: 10px 0px;">Set regEx = nothing</div><div style="word-break: break-all; margin: 10px 0px;">End Function</div><div style="word-break: break-all; margin: 10px 0px;">'替换匹配字符串</div><div style="word-break: break-all; margin: 10px 0px;">'msgbox (ReplaceRegMatch("9","loader runner 9.0, qtp 9.0","10"))</div><div style="word-break: break-all; margin: 10px 0px;">Function ReplaceRegMatch(patrn,str,replaceStr)</div><div style="word-break: break-all; margin: 10px 0px;">Dim regEx</div><div style="word-break: break-all; margin: 10px 0px;">Set regEx = New RegExp</div><div style="word-break: break-all; margin: 10px 0px;">regEx.Pattern = patrn</div><div style="word-break: break-all; margin: 10px 0px;">regEx.IgnoreCase = False</div><div style="word-break: break-all; margin: 10px 0px;">regEx.Global = True &nbsp; 'false的时候只会替换第一个匹配的字符串。若为true则会替换所有匹配的字符串</div><div style="word-break: break-all; margin: 10px 0px;">ReplaceRegMatch = regEx.Replace(str,replaceStr)</div><div style="word-break: break-all; margin: 10px 0px;">End Function</div><div style="word-break: break-all; margin: 10px 0px;">'返回匹配内容</div><div style="word-break: break-all; margin: 10px 0px;">'returnRegMatch "qtp .","qtp 1 qtp 2 qtp3 qtp 4"</div><div style="word-break: break-all; margin: 10px 0px;">Function ReturnRegMatch(patrn,str)</div><div style="word-break: break-all; margin: 10px 0px;">Dim regEx,matches,match</div><div style="word-break: break-all; margin: 10px 0px;">Set regEx = New RegExp</div><div style="word-break: break-all; margin: 10px 0px;">regEx.Pattern = patrn</div><div style="word-break: break-all; margin: 10px 0px;">regEx.IgnoreCase = true</div><div style="word-break: break-all; margin: 10px 0px;">regEx.Global = true &nbsp;'打开全局搜索</div><div style="word-break: break-all; margin: 10px 0px;">Set matches = regEx.Execute(str)</div><div style="word-break: break-all; margin: 10px 0px;">For Each match in matches</div><div style="word-break: break-all; margin: 10px 0px;">print cstr(match.firstIndex) + " " + match.value + " " + cstr(match.length)</div><div style="word-break: break-all; margin: 10px 0px;">Next</div><div style="word-break: break-all; margin: 10px 0px;">End Function</div></td></tr></tbody></table></div><img src ="http://www.blogjava.net/qileilove/aggbug/412126.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-04-09 10:31 <a href="http://www.blogjava.net/qileilove/archive/2014/04/09/412126.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Windows 7上QTP11破解方法</title><link>http://www.blogjava.net/qileilove/archive/2014/03/27/411568.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 27 Mar 2014 08:56:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/03/27/411568.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/411568.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/03/27/411568.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/411568.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/411568.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">　QTP11破解方法：</strong></div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　1.准备文件</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　注册机mgn-mqt82.exe</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　2.安装QTP11</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　3.运行注册机mgn-mqt82.exe</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　如果运行mgn-mqt82.exe 没有反应-,请注意关掉暂时关掉杀毒软件</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　根据路径&#8220;C:\Program Files\Common Files\Mercury Interactive\License Manager\lservrc&#8221;</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">　　以上方法是网上9.2 的破解方法， 以下是11的破解方法，同时适用QTP10.0，只不过以下方法破解10.0可以无时间限制，而11只能适用15天或者30天 。如果11的License到期了，可以使用此方法再次重新破解，不需要重装，即可再次使用15-30天。</strong></div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　1.找到lservrc文件，将它剪切至桌面，或者是别的文件夹，注意一定是剪切。</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　2.运行<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>&nbsp;11</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　或者</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　4.点击Install License，选择Seat license,因为QTP10和QTP11都采用了两种license ,单机版的和服务器并发的，</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　我们破解的是单机许可。</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　5.点击下一步</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　用记事本打开前面注册机生产的lservrc文件，会看到有4个许可密钥，复制任意一条密钥，从开头至#号结束，</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　粘贴至窗口的文本框中，点击下一步，如果提示该密钥已经安装，何以选择另外一条安装，如果仍然提示，</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　请注意检查第三步lservrc文件是否移走了，</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　点击下一步</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　6.安装完成，启动QTP</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">插件破解方法：</strong></div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　1.net插件安装</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　将下载下来的插件进行解压缩到目录qtp92-net-addin中，进入该目录，点击setup.exe，直接默认安装，到最后，把&#8220;立即注册&#8221;取消，安装完毕。重新启动qtp，会发现插件已经存在，但是显示灰色，不可选，状态为no license。</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　2.破解.net插件</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　（1）进入注册表，将HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive备份</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　（2）找到HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Add-In Manager\WPF，将名称为&#8220;默认&#8221;的键值修改为&#8220;QTCoreAddin&#8221;，再将&#8220;ProgID&#8221;的键值修改为 &#8220;Mercury.AddinBaseObj&#8221;</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　（3）找到HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Add-In Manager\WinForms，将将名称为&#8220;默认&#8221;的键值修改为&#8220;QTCoreAddin&#8221;，再将&#8220;ProgID&#8221;的键值修改为 &#8220;Mercury.AddinBaseObj&#8221;</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　（4）关闭注册表，重启软件，发现.net和wpf插件的状态变为built in状态，经过验证，可以正常使用</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　3.破解<a target="_self" style="word-break: break-all; color: #202859; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">java</strong></u></a>插件</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　（1）进入注册表，将HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive备份</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　（2）找到HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Add-In Manager\java，将名称为&#8220;默认&#8221;的键值修改为&#8220;QTCoreAddin&#8221;，再将&#8220;ProgID&#8221;的键值修改为 &#8220;Mercury.AddinBaseObj&#8221;</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　（3）关闭注册表，重启软件，发现java插件的状态变为built in状态，经过验证，可以正常使用</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　4.破解webservice插件</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　（1）进入注册表，将HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive备份</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　（2）找到HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Add-In Manager\webservice，将名称为&#8220;默认&#8221;的键值修改为&#8220;QTCoreAddin&#8221;，再将&#8220;ProgID&#8221;的键值修改为 &#8220;Mercury.AddinBaseObj&#8221;</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　（3）关闭注册表，重启软件，发现webservice插件的状态变为built in状态，经过验证，可以正常使用</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">QTP11 30天试用期到后的破解新方法</strong></div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　1. 找到 C:\ProgramData\SafeNet Sentinel 目录，更名或者删除.2. 找到 QTP11 安装目录下bin子目录，如 C:\Program Files (x86)\HP\QuickTest Professional\bin，执行.(win7以管理员权限执行.) 此方法win7 64bit 可行. 以上两点无法破解，个人用的是win 7 家庭普通版，64bit的，但运行instdemo.exe 后，C:\ProgramData\SafeNet Sentinel重新生成Sentinel RMS Development Kit，重启qtp 11还是提示还有30天后过期~!</div><img src ="http://www.blogjava.net/qileilove/aggbug/411568.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-03-27 16:56 <a href="http://www.blogjava.net/qileilove/archive/2014/03/27/411568.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP中weblist自动选择的方法推荐</title><link>http://www.blogjava.net/qileilove/archive/2014/02/10/409648.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 10 Feb 2014 02:02:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/02/10/409648.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/409648.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/02/10/409648.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/409648.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/409648.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　这里先来推荐一个在<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>中实现weblist自动化选择的一种方法，推荐的理由是网上的方法很多不可行，或是太过于复杂。其实事情往往很简单，只是思考他的人总是会认为它很复杂，所以才有了那么多复杂的事。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">废话不多说，来讲原理：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　由于本台本本上没有具体的代码，所以只有用记忆外加口头来描述如何进行weblist自动化的选择</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">一般我们录制一个weblist的选择，大体会是下面这样：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　browser(一个页面).page(一个页面).frame(一个框架).weblist(一个下拉选择表).select 具体值</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　对于weblist，一般来说用Objectspy来查看，一般情况下会在属性名为"all items"之类的属性下，对应有"值1；值2；值3...."。这里，我们可以使用这个完整的值段来进行自动选择的参考取值。我们首先可以使用getROproperty("all items")的方式来取出该值段，随后我们需要解决的就是如何把这个完整的值段分成若干份然后存入一个数组变量来供我们使用。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　相信大部分的读者已经想到了使用split函数来对这个完整的值段来进行分割了吧！没错，我们使用的正是这个帅气的函数，我们可以像这样写split(browser(一个页面).page(一个页面).frame(一个框架).weblist(一个下拉选择表).getROproperty("all items"),";",-1,1)的方式来获得这个值段中每一小块我们需要的是值（关于split函数不明白的我就不做阐述了，请不懂的童鞋参考网上的资料哦～～）分割了以后，我们可以把它存入一个数组变量中，然后剩下所需做的就是如何对该数组进行随机选择其值了。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　在QTP中，我们可以使用Randomnumber(下界,上界)来进行随机取值,不过剩下最关键的是我们如何获得该数组的上界呢?说到这里就很简单了~那就是ubound函数!没错,一个小小的函数就成为了我们做自动取值的关键~(说到这里是不是有点觉得复杂的事情其实是很简单的呢?)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　下面我们这样做:</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Dim rand_select</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　rand_select=split browser(一个页面).page(一个页面).frame(一个框架).weblist(一个下拉选择表).getROproperty("all items"),";",-1,1</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　browser(一个页面).page(一个页面).frame(一个框架).weblist(一个下拉选择表).select randomnumber(0,ubound(rand_select))</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　这样,我们就很简单的实现了weblist的自动化选择了!</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">版权声明：本文出自 ftdtest 的51Testing软件测试博客：http://www.51testing.com/?15001542</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">原创作品，转载时请务必以超链接形式标明本文原始出处、作者信息和本声明，否则将追究法律责任。</div><img src ="http://www.blogjava.net/qileilove/aggbug/409648.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-02-10 10:02 <a href="http://www.blogjava.net/qileilove/archive/2014/02/10/409648.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP错误处理机制</title><link>http://www.blogjava.net/qileilove/archive/2014/01/29/409428.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Wed, 29 Jan 2014 02:47:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/01/29/409428.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/409428.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/01/29/409428.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/409428.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/409428.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">　1. 概述</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　本文针对<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>提供的运行时错误处理机制进行详细描述。内容包括各种错误处理方式的功能的介绍，各种机制的作用范围的分析，以及错误处理机制同时作用时的优先级别的分析。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">2. 三种错误处理方式介绍</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Quick Test Professional 中有三种错误处理机制，在这里定义为：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　全局错误响应： Test Setting 中Run 设置</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　VBScript On Error 错误处理: On Error Resume Next</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　错误恢复场景： Recovery Scenarios</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">2.1 全局错误响应</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　全局错误响应在Test Setting 的Run 选项中进行设置：【File】&#8212;&gt;【Settings】&#8212;&gt;【Run】&#8212;&gt;【When error occurs during run session】</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　QTP四种全局错误响应设置选项如下：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　pop up message box： Quick Test 在出现错误时显示一个错误消息对话框</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　process to next action iteration:Quick Test 出现错误时继续下一个Action 循环</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　stop run： Quick Test 在出现错误时停止<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　process to next step：Quick Test 在出现错误时跳过错误语句，继续下一步骤</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　全局错误响应是QTP 的系统缺省错误处理，就是说当没有使用其他错误处理方式时，系统会自动调用在这里指定的方式进行错误处理</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　2.2 VBScript 的On Error 错误处理方式</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　由于QTP 使用了VBScript 作为脚本语言，自然地，VBScrip 的错误处理方式在QTP 中都适用。在VBScript中，与错误处理相关的三者为：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　On Error Resume Next 语句</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　On Error GoTo 0 语句</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Err 对象</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　2.2.1 On Error Resume Next</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　一旦这个语句已被处理，脚本引擎将继续运行后面的程序，而不理会已经发现的任何错误。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">2.2.2 On Error GoTo 0</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　使用On Error Goto 0 语句恢复缺省的错误处理行为。在运行这个语句后，发生的运行期错误将导致缺省错误处理。在QTP 中，缺省错误处理就是全局错误响应。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">2.2.3 Err 对象</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Err 对象重要的属性有三个：Number, Source, Description,分别是错误号，错误来源，错误描述.Err 对象会在运行时错误发生的时候赋予新的值，旧的值会被舍弃。Err 对象不会受到函数调用的影响，它完全是全局的。Err 对象可以用Clear 方法清空，任何时候调用On Error Resume Next 或者On Error GoTo 0 的时候，都会清空Err 对象。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　2.3 恢复场景Recovery Scenarios</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Resources_Recovery Scenarios Manager&#8230;可以创建恢复场景。具体请参考帮助文档，这里只是说明对于运行错误的处理。在恢复场景中触发事件TriggerEvent 中的一个选项是Test Run Error，表示在运行过程中遇到错误时所采取的恢复处理方式。我们看一看下面对哪几种错误进行恢复处理，即错误恢复的触发条件：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">　　Any Error</div><div style="word-break: break-all; margin: 10px 0px;">　　Item in list or menu is not unique</div><div style="word-break: break-all; margin: 10px 0px;">　　Item in list or menu not found</div><div style="word-break: break-all; margin: 10px 0px;">　　More than one object responds to the physical description</div><div style="word-break: break-all; margin: 10px 0px;">　　Object is disable</div><div style="word-break: break-all; margin: 10px 0px;">　　Object not found</div><div style="word-break: break-all; margin: 10px 0px;">　　Object not visible</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　恢复处理(Recovery Operation)有以下几种方式：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">　　Keyboard or mouse operation</div><div style="word-break: break-all; margin: 10px 0px;">　　Close application process</div><div style="word-break: break-all; margin: 10px 0px;">　　Function call</div><div style="word-break: break-all; margin: 10px 0px;">　　Restart Microsoft&nbsp;<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">Windows</strong></u></a></div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　从恢复场景的触发条件可以看出，所有错误处理都是针对测试对象发生的错误而言的（Any Error 指列表中所有的其他错误类型），它并不处理被零除、非法赋值，内存分配错误等等VBScript 的运行时错误。这是和其它两种错误处理方式不同之处。为了说明这一点，我们不妨再看看Recovery Operation 中OperationType 如果选择Function Call，函数原型定义如下所示，所有的函数参数都必须包含有被测对象，触发函数必须遵循原型定义，否则函数无法执行。<br /><br /><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">再来看错误恢复的后处理方式(Post-Recovery Test Run Options)有以下几种：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">　　Repeat current step and continue</div><div style="word-break: break-all; margin: 10px 0px;">　　Proceed to next step</div><div style="word-break: break-all; margin: 10px 0px;">　　Proceed to next action or component iteration</div><div style="word-break: break-all; margin: 10px 0px;">　　Proceed to next test iteration</div><div style="word-break: break-all; margin: 10px 0px;">　　Restart current test run</div><div style="word-break: break-all; margin: 10px 0px;">　　Stop the test run</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　我们看到Proceed to next step/ Proceed to next action or component iteration/ Stop the test run这三种方式在全局错误处响应理方式中也是存在的，Proceed to next step 这种方式更是和On ErrorResume Next 处理方式也是相同的。稍后会就此作进一步叙述。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">3. 三种错误处理方式的作用域</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　本节阐述三种错误处理方式的作用范围，为了方便比较说明，这里假设三种错误处理方式为：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　&#183; 全局错误响应： Process to next step</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　&#183; VBScript 错误处理： On Error Resume Next</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　&#183; 错误恢复后处理方式： Proceed to next step</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　因为这三种处理方式效果一样，以后没有特殊说明，都采用以上设置，可以方便比较</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">3.1 全局错误响应</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　原则： 对该test 中的所有Action 均生效。也就是说在Action 里没有其他错误处理方式的时候，脚本运行过程中遇到的错误都会按照全局错误响应的设置进行处理</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　3.1.1 对 Action 中直接定义的函数：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　对所有函数生效。如下例，如果全局错误响应设置成process to next step 函数testA 中的被零除语句 i=1/0 会跳过，三个msgbox 均可以执行。错误代码会逐级返回。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">3.1.2 对用ExecuteFile 引入的函数：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　与Action 中直接定义的函数处理方式完全一样</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">3.1.3 对于Function Library 中定义的函数</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　与Action 中直接定义的函数处理方式基本一致，对所有函数生效。但不同的是，对于错误代码，只能在Function Library 中传递，而不会传递到Action 中来。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　3.1.4 对于Action 的嵌套调用</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　如之前所述，对Test 中的所有Action 均生效，自然嵌套调用的Action 也不例外。同Function Library一样，错误码只能在Action 内部传递，也就是说被调用Action 中产生的错误码不能传递到调用Action 中去。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　3.2 VBScript 的On Error 错误处理方式</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　原则： 只对语句所在函数或Action 中该语句之后的代码生效，对子函数，调用Action 均无效。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;"><strong style="word-break: break-all; line-height: normal !important;">　　3.2.1 对 Action 中直接定义的函数：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　函数中错误抛出，不会继续执行错误代码。一个错误在函数/子程序中出现时，如果没有运行On Error Resume Next 语句，那么错误将被交给调用它的环境，这个过程一直重复到找到运行On Error Resume Next 语句的环境继续运行，或者找到缺省的脚本错误处理器。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　3.2.2 对用ExecuteFile 引入的函数：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　与对Action 中直接定义的函数的处理完全一致</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　3.2.3 对于Function Library 中定义的函数</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　Function Library 中定义的函数遇到错误抛出，执行系统缺省错误处理</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">3.2.4 对于Action 的嵌套调用</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　被调用Action 中的语句遇到错误抛出，执行系统缺省错误处理</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　3.3 错误恢复场景 Recovery Scenarios</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　原则： 任何函数调用和Action 中，只要满足触发条件，就会触发错误恢复处理和后处理</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　前面讲过，错误恢复场景的触发条件是以下6 种</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">　　Item in list or menu is not unique</div><div style="word-break: break-all; margin: 10px 0px;">　　Item in list or menu not found</div><div style="word-break: break-all; margin: 10px 0px;">　　More than one object responds to the physical description</div><div style="word-break: break-all; margin: 10px 0px;">　　Object is disable</div><div style="word-break: break-all; margin: 10px 0px;">　　Object not found</div><div style="word-break: break-all; margin: 10px 0px;">　　Object not visible</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　对于VBScript 的其他运行时错误，并不会触发错误恢复场景，当然也不存在错误恢复处理及后处理。但一旦在任何函数或者action 中满足触发条件，都会进行错误恢复处理及后处理，也就是说，其作用范围为所有Action 和函数/子程序中。当错误恢复完成后（包括错误处理及后处理），错误会被清0。如果错误恢复的后处理方式为Proceed to next step，处理完成后再次碰到VBScript 错误时如何处理呢？如新产生错误并不能满足触发条件，则原错误恢复中设置后处理方式不会继续生效，此时会遵循缺省错误响应或其他指定的错误处理。值得注意的是，如果错误恢复的后处理方式为Repeat current step and continue 或者Restart currenttest run，再次运行到该语句仍重复同样的错误，可能会导致死循环。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">4. 三种错误处理方式的优先级别</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　错误恢复场景中的错误处理优先级最高 (Recovery Operation)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　On Error Resume Next 优先级次之</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　错误恢复场景中的后处理方式优先级别再次之 (Post-Recovery Test Run Options)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　缺省错误响应优先级别最低</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　也就是说，只要满足恢复场景的触发条件，就会进行错误恢复处理(Recovery Operation)。但是其后处理方式的优先级别和错误恢复处理的优先级别是不同的。如果触发错误恢复处理的语句之前有On ErrorResume Next，就不会执行错误恢复后处理中所定义的处理方式。当没有找到以上任何错误处理方式的定义时，才执行缺省错误处理。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　注意： On Error GoTo 0 其实就是指采用缺省错误处理，不可和On Error Resume Next 处理的优先级别等同起来。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">5. 自动化框架测试与实践</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;"><strong style="word-break: break-all; line-height: normal !important;">　　5.1错误处理模式三种测试设计技术</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　为了解决传统错误处理模式的不足，现在错误处理的技术往往采取如下的手段。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　图片处理技术</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　伪视频技术</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　视频技术</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">5.1.1图片处理技术</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　图片处理技术主要是基于原先的图片截图上进行扩展的，只要的目的是采取简便的方式来展示错误信息的显示，一般的操作过程如下：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　出现错误的时候开始截屏</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　记录错误的控件的位置</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　在图片上标示控件</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　在控件附近标示错误的信息</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　这样设计的目的就是希望方便测试人员或者开发人员能够很方便的了解导致程序出错的过程，接下来我会针对图片处理技术来进行实践。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　5.1.2伪视频技术</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　伪视频的技术是为了展现因为测试过程而导致出现错误的现象。它所实现的过程是采取对每个操作过程的截屏，然后生成Gif格式的文件，类似一个动画的效果。伪视频的技术操作过程如下:</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　自动化测试脚本在运行之初，初始化一段缓冲区来保存即将捕获的截图</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　自动化测试脚本按照顺序进行逻辑顺序执行</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　&#8220;伪视频程序&#8221;也在按照一定的频率进行截图处理，并把图片保存在缓冲区</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　如果缓冲区达到最大容量，尽早的截图将会被新的图片代替</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　一旦错误出现，自动化脚本通知&#8220;伪视频程序&#8221;，&#8220;伪视频程序&#8221;将手机缓冲区的截图，然后形成动态图片</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　脚本运行停止</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">5.1.3视频技术</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　这是个真正的屏幕录制技术，采取的是自动化测试执行与屏幕录制平台操作的过程， 来录制自动化测试的一个过程。但是这个技术最大的问题在于，需要的空间比较大，如果空间小的话，就将会导致出错的过程难以有效地展现.</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;"></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px; height: 21px; position: relative; width: 627.1875px;"></div></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; height: 21px; position: relative; width: 627.1875px;"></div><img src ="http://www.blogjava.net/qileilove/aggbug/409428.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-01-29 10:47 <a href="http://www.blogjava.net/qileilove/archive/2014/01/29/409428.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP中使用自定义vbs类</title><link>http://www.blogjava.net/qileilove/archive/2014/01/20/409121.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 20 Jan 2014 02:10:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/01/20/409121.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/409121.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/01/20/409121.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/409121.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/409121.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　发现直接在resource中加载含有calss的vbs文件，<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>无法识别类，导致脚本中无法new类对象。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">解决办法有四种：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　1、直接在action脚本中定义类，然后action中任何地方都可以实例化类</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　2、用executefile引入类定义文件，然后action中任何地方都可以实例化类</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　3、在function lib中定义类，并实例化类，然后再action中直接使用类实例</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　4、在function lib中定义类，并定义一个实例化类的函数，然后再action中调用该函数对类进行实例化</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　补充：第四种实现方法如下：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　把vbs文件加载到Resources中后，我用以下方法绕过QTP不识别导入的vbs文件中的类的问题。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">在放置class(类)的vbs文件中，放置以下函数：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">------------------------------------------------------------------------------------------------------------------</div><div style="word-break: break-all; margin: 10px 0px;">'</div><div style="word-break: break-all; margin: 10px 0px;">'* 功能：由于QTP不识别导入的VBS文件中的类，因此定义此函数来返回相应的对象</div><div style="word-break: break-all; margin: 10px 0px;">'* 输入参数：className &nbsp;：要建立对象的类名</div><div style="word-break: break-all; margin: 10px 0px;">'* 返回值：返回类对象</div><div style="word-break: break-all; margin: 10px 0px;">'* 编写人： &nbsp;chenyb</div><div style="word-break: break-all; margin: 10px 0px;">'* 编写日期：2008-10-16</div><div style="word-break: break-all; margin: 10px 0px;">'* 其他说明：以下只是方法，根据需要再扩展</div><div style="word-break: break-all; margin: 10px 0px;">'</div><div style="word-break: break-all; margin: 10px 0px;">Public Function newClass(className)</div><div style="word-break: break-all; margin: 10px 0px;">Dim strSentence,obj</div><div style="word-break: break-all; margin: 10px 0px;">strSentence = strSentence &amp; "set obj = New " &amp; className '创建对象</div><div style="word-break: break-all; margin: 10px 0px;">Execute strSentence &nbsp;'执行字符串语句</div><div style="word-break: break-all; margin: 10px 0px;">Set newClass = obj &nbsp; '返回对象</div><div style="word-break: break-all; margin: 10px 0px;">End Function</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">参考QTP下vbs伪类构造器的设计：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　有一段时间没上博客了，不过博客还是不能拖呢，每每在我快要放弃的时候总会有许多网友在告诉我该更新了，我们等着你的讲座，虽然讲座写到后来已经有些疲倦，但有了你们的支持，我还会一直继续，讲座还会一直继续。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　进入正题，今天要讲的内容与VBS类关联比较密切，在看本次讲座之前建议大家首先熟悉一下类的组成, 这样对于<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">学习</strong></u></a>本次讲座内容会比较轻松。如果平时在<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">自动化测试</strong></u></a>过程中经常使用类的朋友应该会清楚，在Resources中引用带有类的vbs函数库之后，是不可以直接在QTP脚本编辑器中直接进行类的初始化的。具体我们来看下例子。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">1.首先我们编写一个vbs函数库，脚本如下：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Class ExcelClass</div><div style="word-break: break-all; margin: 10px 0px;">Sub t1()</div><div style="word-break: break-all; margin: 10px 0px;">MsgBox "t1"</div><div style="word-break: break-all; margin: 10px 0px;">End Sub</div><div style="word-break: break-all; margin: 10px 0px;">Sub t2()</div><div style="word-break: break-all; margin: 10px 0px;">MsgBox "t2"</div><div style="word-break: break-all; margin: 10px 0px;">End Sub</div><div style="word-break: break-all; margin: 10px 0px;">End Class</div></td></tr></tbody></table>　　<strong style="word-break: break-all; line-height: normal !important;">2.在QTP的File --&gt; Settings --&gt; Resources中引用此函数库</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=44139" target="_blank" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><font color="#202859"><span style="line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/01/14982672_201401171615581jFBB.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></span></font><br /><br /></a><a href="http://www.51testing.com/batch.download.php?aid=44139" target="_blank" sl-processed="1"><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　3.我们知道创建一个类的实例方法是通过以下方式来进行的</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　Set 实例名 = New 类名</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　此时如果直接在QTP中进行创建类的话会直接报错：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　Set eom &nbsp;= new ExcelClass</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　eom.t1</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=44140" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/01/14982672_20140117161558252sq.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　4.那么对于以上这种情况，我们一般所采用的方式是在函数库中建立一个函数，让此函数返回这个类的实例化。</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Class ExcelClass</div><div style="word-break: break-all; margin: 10px 0px;">Sub t1()</div><div style="word-break: break-all; margin: 10px 0px;">MsgBox "t1"</div><div style="word-break: break-all; margin: 10px 0px;">End Sub</div><div style="word-break: break-all; margin: 10px 0px;">Sub t2()</div><div style="word-break: break-all; margin: 10px 0px;">MsgBox "t2"</div><div style="word-break: break-all; margin: 10px 0px;">End Sub</div><div style="word-break: break-all; margin: 10px 0px;">End Class</div><div style="word-break: break-all; margin: 10px 0px;">'定义ExcelClass的无参构造</div><div style="word-break: break-all; margin: 10px 0px;">Function NewExcelClass</div><div style="word-break: break-all; margin: 10px 0px;">Set NewExcelClass = new ExcelClass</div><div style="word-break: break-all; margin: 10px 0px;">End Function</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">5. 接着在QTP脚本编辑区中直接把这个函数返回就可以使用了</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Set eom &nbsp;= NewExcelClass</div><div style="word-break: break-all; margin: 10px 0px;">eom.t1</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　思考：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　是否可以按照如图所示的方式把New ExcelClass作为函数名进行编写呢，这样我们就可以直接在QTP脚本区中进行new一个类出来，是不是更加直观呢，这一块我们会留到下一讲进行讲解。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><a href="http://www.51testing.com/batch.download.php?aid=44141" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/01/14982672_201401171615583fVcA.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">总结：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　这一讲内容比较基础，主要还是为了照顾一些新人，下一讲我们会继续深入讲解类构造器，主要会涉及到带参构造器的设计模式，请大家期待。</div></a></div><img src ="http://www.blogjava.net/qileilove/aggbug/409121.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-01-20 10:10 <a href="http://www.blogjava.net/qileilove/archive/2014/01/20/409121.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>让你的QTP在运行过程中“收入自如”</title><link>http://www.blogjava.net/qileilove/archive/2014/01/13/408836.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 13 Jan 2014 02:58:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/01/13/408836.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/408836.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/01/13/408836.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/408836.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/408836.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;">　我们在运行<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>批处理时，不需要把QTP的主界面显示出来，以免它阻碍了你的操作视线，那下面介绍二个函数方便你的QTP在运行过程中&#8220;收入自如&#8221;：</div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;">　　'让QTP运行时保持最小化</div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Public Sub QTP_Small()</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dim objQTPWin</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set objQTPWin = GetObject("" , "QuickTest.Application")</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">objQTPWin.WindowState = "Minimized"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set objQTPWin = Nothing</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">End Sub</div></td></tr></tbody></table></div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;">　　'恢复QTP窗口</div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Public Sub QTP_Big()</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dim objQTPWin</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set objQTPWin = GetObject("" , "QuickTest.Application")</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">objQTPWin.WindowState = "Restored"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set objQTPWin = Nothing</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">End Sub</div></td></tr></tbody></table></div><img src ="http://www.blogjava.net/qileilove/aggbug/408836.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-01-13 10:58 <a href="http://www.blogjava.net/qileilove/archive/2014/01/13/408836.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[PLAYING QTP] Part2—Record</title><link>http://www.blogjava.net/qileilove/archive/2014/01/10/408754.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 10 Jan 2014 01:38:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/01/10/408754.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/408754.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/01/10/408754.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/408754.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/408754.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">　　PART &#8211; 02</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">　　RECORD</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　&#8220;录制&#8221;是<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>的一个最基本的功能，<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>人员在什么都不会的情况下，通过录制，就能完成一个简单的线性测试脚本。方便，快捷。但是带来的问题是，很多人在接触自动化的时候，也就了解到了自动化是靠的&#8220;录制&#8221;而成。尤其是开发，或是不懂自动化的测试领导。瞬间你个<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">自动化测试</strong></u></a>人员的高大上的光环消失。（一把眼泪一把鼻涕的血泪史啊）</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　OK，言归正传，录制其实能说的不多，就和录音一样，点击录制，然后进行你的测试，然后，一段脚本生成，简单快捷。但是建议大家尽量不要使用录制，尽量手动添加对象到对象库，然后拖动至专家视图，进行编辑。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　关于优缺点</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">使用纯录制，会有以下，问题：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　漏步骤。对一些识别的不好的控件，QTP会显示出现无法录制的情况，后来回放失败，还得一个个查是少了哪个步骤。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　对象凌乱。如果你在一个页面上分两次录制，有可能出现 object 、object_2、object_3 的情况，其实属性都一样，其实都是一个东西，但是却记录了很多多余的分支。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　名称过长。有的网页的标题很长，录制下来的脚本会把脚本拉的很长，比如录制51testing首页的一个控件后，脚本为：Browser(&#8220;51Testing软件测试网-中国<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">软件测试</strong></u></a>人的精神家园&#8221;).Page(&#8220;51Testing软件测试网-中国软件测试人的精神家园&#8221;).WebElement(&#8220;今日热点&#8221;).Click</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　控件不明确。有时候开发图省事，不会对每个控件做很详细的属性描述，造成脚本出现大量WebEdit1、WebEdit2、WebEdit3&#8230;&#8230; WebEdit20之类的现象，如果使用录制，你会发现你的脚本几乎没有可读性而言，必须一个个控件重新定位才能确认。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">当然了，也不是没有优点：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　简单</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　支持低级录制</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　综上所述，建议大家手动编写脚本。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　然后看一下关于录制的相关设置：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　在 Tools 下的 Web Event Recording Configuration 可以对录制的等级进行设置，但是只对于BS架构的系统才能产生作用。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=43928" target="_blank" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/01/14982672_201401071535071UVXV.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Basic等级下，是不会对鼠标在某对象上停留2秒的情况录制出效果的。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　在Options中还有些其他设置，根据自己的需要进行录制设置。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=43929" target="_blank" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/01/14982672_201401071535072i2xM.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　首次录制会出现Record and Run Settings，这里的作用就是在回放时，会自动打开某个网页或启动某个应用软件，我个人不喜欢用设置，所以，选择第一项。如需要启动IE或应用软件，可以使用脚本：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　CODE:</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　SystemUtil.Run "iexplore.exe" , "http://www.baidu.com"</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px; text-align: center;"><a href="http://www.51testing.com/batch.download.php?aid=43930" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/01/14982672_2014010715350734zrt.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　在录制状态下，工具栏的这两个按钮会亮起，前者是 模拟录制 ，后者是 低级录制。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px; text-align: center;"><a href="http://www.51testing.com/batch.download.php?aid=43931" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/01/14982672_201401071535074ayvw.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　前者录制下一堆鼠标的行动动作，并生成一句：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　CODE:</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　Desktop.RunAnalog "Track1"</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　后者会记录下很多的坐标，比如：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　CODE:</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Click 1159,568</div><div style="word-break: break-all; margin: 10px 0px;">Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Click 627,205</div><div style="word-break: break-all; margin: 10px 0px;">Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Type "423"</div><div style="word-break: break-all; margin: 10px 0px;">Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Type "234234"</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　OK，关于Record的东西就聊到这里，没有什么难点。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px;">　　最后来回顾一下说的几点吧：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-size: 11.818181991577148px; text-align: center;"><a href="http://www.51testing.com/batch.download.php?aid=43932" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/01/14982672_201401071535075DNMy.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div></a></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">相关<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">文章</strong></u></a>：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/index.php?action-viewnews-itemid-856834-php-1" target="_blank" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;">[PLAYING QTP] PART 01&#8212;BEGINNING</a></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; height: 21px; position: relative; width: 627.1875px;"></div><img src ="http://www.blogjava.net/qileilove/aggbug/408754.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-01-10 09:38 <a href="http://www.blogjava.net/qileilove/archive/2014/01/10/408754.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>让你的自动化测试更加“自动化”</title><link>http://www.blogjava.net/qileilove/archive/2014/01/09/408720.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 09 Jan 2014 02:42:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/01/09/408720.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/408720.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/01/09/408720.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/408720.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/408720.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;">　前段时间，老板要求每天包括晚上要在不同的压力下，且不断重复地运行smoke&nbsp;<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">test</strong></u></a>.但是晚上我们不可能就自己动手让我们的<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>的运行，而且就算是白天也不可能做到在某一个时间点上，自己手动来运行<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">自动化测试</strong></u></a>。</div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;">　　那该怎么办呢？可以考虑用Window自带的Schedule来定时触发我们的QTP。但是schedule是无法直接去打开QTP或者去运行VBS，那又该怎么办？我是用下的解决方法与大家共享：</div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;">　　Schedule -&gt; Bat -&gt; VBS -&gt; QTP主函数 -&gt; VBScripts.具体代码如下：</div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;">　　<strong style="word-break: break-all;">Bat:</strong></div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;">　　------------------------------------</div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">taskkill /im &nbsp;EXCEL.EXE /f</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">taskkill /im &nbsp;wscript.exe /f</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">taskkill /im &nbsp;QTPro.exe /f</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">taskkill /im &nbsp;QTAutomationAgent.exe /f</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">ping -n 3 127.1&gt;nul</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">start C:\AutoTest\TA_AutomationTest\C955\3_QTPScript\0_MainScript\LaunchLoopTest.vbs</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">****************************************************************************</div></td></tr></tbody></table></div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;">　　<strong style="word-break: break-all;">LaunchLoopTest.vbs:</strong></div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;">　　----------------------</div><div style="word-break: break-all; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; line-height: normal !important;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dim qtApp</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dim qtTest</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dim qtResultsOpt</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Dim GenerateDateTime,TestResult,BakTestResult</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">GenerateDateTime =Replace(FormatDateTime(Date(),2),"/","_") &amp; "-" &amp; Replace(FormatDateTime(Time(),3),":","_") &nbsp; '自定义一个获取当前时间的字符串</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">TestResult = "C:\AutoTest\TA_AutomationTest\1_Report\ExcelReport\Test_Result.xls" '获得测试结果</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">BakTestResult &nbsp;= "C:\AutoTest\TA_AutomationTest\1_Report\ExcelReport\Test_Result" &amp; GenerateDateTime &amp; ".xls"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set qtApp = CreateObject("QuickTest.Application") ' 建立QTP的应用对象</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">qtApp.Launch ' Start QuickTest</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">qtApp.Visible = True ' 让QTP运行过程可见</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">' 设置当运行过程中如果出错，抓图。</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">qtApp.Options.Run.ImageCaptureForTestResults = "OnError"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">' 快速运行。</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">qtApp.Options.Run.RunMode = "Fast"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">qtApp.Options.Run.ViewResults = False</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">qtApp.Open "C:\AutoTest\TA_AutomationTest\C955\3_QTPScript\0_MainScript\MainScript2", True ' 以只读的方式开打开QTP主函数</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">' 为Test设置运行</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set qtTest = qtApp.Test</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' 建立测试结果</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">qtResultsOpt.ResultsLocation = "C:\AutoTest\TA_AutomationTest\1_Report\" &amp; GenerateDateTime ' 建立起QTP自动的测试结果路径</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">'qtResultsOpt.ResultsLocation = "D:\temp2\res1"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">qtTest.Run qtResultsOpt ' 运行QTP主函数</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">qtTest.Close ' 关闭主函数</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">qtApp.Quit &nbsp;' 退出</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set qtResultsOpt = Nothing ' 释放对象</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set qtTest = Nothing</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set qtApp = Nothing</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set fso = CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">fso.MoveFile TestResult, BakTestResult &nbsp; '备份当前运行完脚本后的测试结果</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set fso = Nothing</div></td></tr></tbody></table></div><img src ="http://www.blogjava.net/qileilove/aggbug/408720.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-01-09 10:42 <a href="http://www.blogjava.net/qileilove/archive/2014/01/09/408720.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP中关于对webelement的处理</title><link>http://www.blogjava.net/qileilove/archive/2014/01/09/408717.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 09 Jan 2014 02:23:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/01/09/408717.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/408717.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/01/09/408717.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/408717.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/408717.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　相信大家对于qtp中的控件的识别都绞尽脑汁了吧。有时间没有必要对所有类型的控件都纠结的。比如一定情况下的webelement控件。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　由于开发的框架千差万别，就拿我们公司的框架来说，webelement的操作没有必要去考虑，因为只是由于架构中布局的考虑才有的。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　甚至有些webtable类型的控件也是如此。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　如下图的 正常用户操作要单击左侧menu中的企业业务才能看到外发加工的业务，进而找到外发加工业务双击才能进入外发加工业务的操作界面，而我们可以根据</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　控件识别的原理不需要对webelement进行考虑 只需要3层识别思路即可：代码形式如下：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Browser(xxx).Page(xxx).Frame(xxx).Link(&#8220;外发加工").Click</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=43893" target="_blank" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2014/01/14982672_201401061109251cn4H.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">版权声明：本文出自 ftdtest 的51Testing软件测试博客：http://www.51testing.com/?15001542</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">原创作品，转载时请务必以超链接形式标明本文原始出处、作者信息和本声明，否则将追究法律责任。</div><img src ="http://www.blogjava.net/qileilove/aggbug/408717.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-01-09 10:23 <a href="http://www.blogjava.net/qileilove/archive/2014/01/09/408717.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP的对象识别技术</title><link>http://www.blogjava.net/qileilove/archive/2014/01/03/408430.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 03 Jan 2014 05:40:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2014/01/03/408430.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/408430.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2014/01/03/408430.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/408430.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/408430.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　在我们在做自动化的时候，经常会遇到的一种情况就是，在同一个页面里， 出现相同类型和名称的对象时，一般需要依赖额外的属性来区分这些相同的对象。</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　在<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>&nbsp;里共有3类这样的顺序标识。</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　<strong style="word-break: break-all;">1. 顺序标识(Ordinal Indentifiers):</strong>[location \ Index \ CreationTime] &nbsp; 其中CreationTime 仅适用于Browser对象</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　这些顺序标识一般用在描述性编程里面 例如:</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">'采用Location 是 按对象位置的从上到下的</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Browser("").Page("").WebEdit("name:=qtp","location:=2").Set "Eric_1991"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">'采用Index 是按对象的位置从左到右的</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Browser("").Page("").WebEdit("name:=qtp","index:=3").Set "Eric_1991"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">'CreationTime 顺序标识仅能用在Browse对象， 按浏览器的进程产生的时间先后顺序排列</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">SystemUtil.Run "iexplore.exe", "http://www.HP.com" '这个时候CreationTime 的值是0</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">SystemUtil.Run "iexplore.exe", "http://www.baidu.com" &nbsp;'这个时候CreationTiem的值是1</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Browser("creationtime:=").Highlight '高亮显示的是HP.com的浏览器</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Browser（"creationtime:="）.Highlight '高亮显示的是baidu.com的浏览器'</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　QTP 在碰到对象识别问题的时候，会尝试应用智能识别(Smart Identification)。 如果智能识别能定位到对象，那么脚本就继续运行，否则就会提示错误</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　在 对象的智能识别设置 &nbsp;Base Filter Properties &nbsp;里会进行第一乱的 对象属性的匹配，如果Base Filter Properties 里面的属性不能够定位到该对象，那么QTP就会到该对象的Optional Filter Properties 里面的属性进行逐个去匹配 ，直到能定位到该对象位置， 否则就会发生对象找不到的错误</div></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff; height: 21px; position: relative; width: 627.1875px;"></div><img src ="http://www.blogjava.net/qileilove/aggbug/408430.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2014-01-03 13:40 <a href="http://www.blogjava.net/qileilove/archive/2014/01/03/408430.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在QTP Test中利用vbs和cmd实现重新启动QTP</title><link>http://www.blogjava.net/qileilove/archive/2013/12/24/407957.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 24 Dec 2013 03:40:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2013/12/24/407957.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/407957.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2013/12/24/407957.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/407957.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/407957.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　连续长时间执行过<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>或使用QC连续长时间调用QTP的朋友应该会知道，QTP在长时间执行过程中会产生内存泄露。而QTP自身也有一个工具Remote Agent来实现每执行N次来重新启动<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;"></strong></u></a><u style="word-break: break-all; line-height: normal !important;"><strong style="word-break: break-all;"><a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>工具</strong></u>释放内存。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　但是，不知道是不是我用破解版的原因，如果使用RunTest来调用QC执行QTP时，这个设置的Remote Agent会使得测试失败，并卡死在某一步。所以在这里需要进行手动清理QTP长时间运行过程中产生的内存泄露。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　在这里，我所知的清理内存有两种方式，一种是利用一些内存清理工具，一种是通过脚本控制QTP重新启动。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　首先说说内存清理工具。今天在群里下到了一个兄弟共享的内存清理工具memempty.exe，它可以进行定时清理。但是由于QTP执行每个<a href="" target="_self" sl-processed="1" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">Test</strong></u></a>的时间都不相同，并且QTP在执行过程中，这个工具也无法有效的清理干净内存部分。对这些不是很懂，点下就行了，免得出丑。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　使用脚本控制，这里我用的是创建外部vbs并通过cmd命令来执行的方式实现的，脚本如下：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">dim restartcode</div><div style="word-break: break-all; margin: 10px 0px;">set?fso?=?CreateObject("Scripting.FileSystemObject")</div><div style="word-break: break-all; margin: 10px 0px;">set?file?=?fso.CreateTextFile("D:\RestartQTP.vbs")</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?"'浣跨敤涓&#8364;涓瓑寰呮椂闂翠娇寰梣tp鑳借繑鍥瀜c涓&#8364;涓墽琛屾垚鍔熺殑缁撴灉"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"WScript.Sleep?3000"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"'浣跨敤AOM鏉ユ帶鍒秖tp鐨勯噸鍚搷浣?"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"Dim?qtp"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"Set?qtp?=?CreateObject(""QuickTest.Application"")"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"qtp.Quit"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"WScript.sleep?2000"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"qtp.Launch"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"qtp.visible?=?true"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"set?qtp?=?nothing"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"set?fso?=?CreateObject(""Scripting.FileSystemObject"")"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"fso.deletefile?""D:\RestartQTP.vbs"""&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">restartcode?=?restartcode?&amp;"set?fso?=?nothing"&amp;vbnewline</div><div style="word-break: break-all; margin: 10px 0px;">file.write?restartcode</div><div style="word-break: break-all; margin: 10px 0px;">set?fso?=?nothing</div><div style="word-break: break-all; margin: 10px 0px;">set?WshShell?=?CreateObject("WScript.Shell")</div><div style="word-break: break-all; margin: 10px 0px;">WshShell.run?"cmd.exe?/c?D:\RestartQTP.vbs"</div><div style="word-break: break-all; margin: 10px 0px;">set?WshShell?=?nothing?</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　这样就可以实现重新启动QTP了，不过在执行下一个test之前需要一个等待时间，这个在调用脚本中很简单，就不罗嗦了</div><img src ="http://www.blogjava.net/qileilove/aggbug/407957.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2013-12-24 11:40 <a href="http://www.blogjava.net/qileilove/archive/2013/12/24/407957.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP中DataTable用法整理</title><link>http://www.blogjava.net/qileilove/archive/2013/12/19/407762.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Thu, 19 Dec 2013 03:08:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2013/12/19/407762.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/407762.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2013/12/19/407762.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/407762.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/407762.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">　DataTable的操作包括：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.7272338867188px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">DataTable.GetSheet(dtSheet)</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.GetSheetCount</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.[GetSheet.]GetRowCount</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.[GetSheet.]GetParameterCount</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.GetSheet(sSheetName).GetParameter(&#8220;ColumName&#8221;).ValueByName(iRowNumber)</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.[GetSheet.]GetCurrentRow</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.[GetSheet.]SetCurrentRow(RowNumber)</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.Value(ParameterID [, SheetID]) or DataTable (ParameterID [, SheetID])</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.AddSheet(SheetName)</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.DeleteSheet(SheetName)</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.Export(filename)</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.ExportSheet(filename,SheetName)</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.Import(FileName)</div><div style="word-break: break-all; margin: 10px 0px;">DataTable.ImportSheet(FileName, SheetSource, SheetDest)</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　1.得到datatable总行数的命令：GetRowCount</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　描述：返回运行时数据表的第一个<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">工作</strong></u></a>表（用于<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>的全局表或用于业务组件的业务组件表）中最长的列中的总行数。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　语法：DataTable.GetRowCount</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　返回值：数字</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　示例：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　以下示例使用 GetRowCount 方法查找 MySheet 运行时数据表中最长的列中的总行数，并将其写入报告。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　rowcount = DataTable.GetSheet("MySheet").GetRowCount</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Reporter.ReportEvent 2, "数据工作表中有 " &amp;rowcount, "行。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　2.得到datatable运行时的动态列数：GetParameterCount</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　语法：DTSheet.GetParameterCount</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　例： paramcount = DataTable.GetSheet("MySheet").GetParameterCount</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　3.GetCurrentRow方法</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　描述：返回运行时数据表的第一个工作表（用于测试的全局表或用于业务组件的业务组件表）中的当前（活动）行。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　语法：DataTable.GetCurrentRow</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　返回值：数字</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　示例：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　以下示例使用 GetCurrentRow 方法检索当前在运行时数据表中使用的行，并将其写入报告。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　row = DataTable.GetCurrentRow</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　Reporter.ReportEvent 1, "行号", row</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">4. 设置当前active的行数（第一行为1）：SetCurrentRow</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　语法：DataTable.SetCurrentRow(RowNumber)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　例： DataTable.SetCurrentRow(tb_i+1)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　DataTable.GetSheet("Action1"). SetCurrentRow(tb_i+1)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　'注：此命令可在循环运行中不断指向下一行数据</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　你也可以用GetCurrentRow来获取Action1的行，然后再用SetCurrentRow来保持两个Action的当前行一致：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　CurrRow = DataTable.GetSheet("Action1").GetCurrentRow</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 11.818181991577148px; background-color: #ffffff;">　　DataTable.GetSheet("Action2").SetCurrentRow(CurrRow)<br /><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;"><strong style="word-break: break-all; line-height: normal !important;">　5.查询、设置datatable的数值：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　语法：To find the value:</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.Value(ParameterID [, SheetID])</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　or : DataTable(ParameterID [, SheetID])</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　To set the value:</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.Value(ParameterID [, SheetID])=NewValue</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　or : DataTable(ParameterID [, SheetID]) =NewValue5</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable("Col", "Action2") 就是读取Action2的Col列。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　同样，表也可以用数字代替：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable(1, 2) 这样就是读取第二个Action表的第一列</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　还有一种写法：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable(1, "Action2") 这样就是读取Action2的第一列，不管第一列叫什么名字，都能读</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　还有一种赋值方法</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　aParam2=DataTable(&#8220;AccountsNumber&#8221;,dtGlobalSheet)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　还有一种赋值方法，但是有一个前提就是：必须只能是测试只包含一个操作的情况：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　aParam3=DataTable(&#8220;AccountsNumber&#8221;,dtLocalSheet)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　例： DataTable.Value("Destination", "ActionA")="New York"</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.Value(2,3)="New York"</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable("Destination", dtlocalSheet)="New York"</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　Call_date= DataTable.Value("Date","add Conference Call") '为Call_date赋值</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">6. 取datatable特定行的数据：</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.GetSheet("Action1").GetParameter("test\").ValueByRow(4)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">7 AddSheet 方法</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　描述：向运行时数据表中添加指定工作表并返回该工作表，以便可以直接在同一语句中设置新工作表的属性。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　语法：DataTable.AddSheet(SheetName)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　示例：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　以下示例先使用 AddSheet 方法在运行时数据表中新建工作表"MySheet"，然后向新工作表中添加参数。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　Dim Variable</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　Variable=DataTable.AddSheet ("MySheet").AddParameter("Time", "8:00")</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">8 DeleteSheet方法</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　描述：从运行时数据表中删除指定工作表。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　语法：DataTable.DeleteSheet SheetID</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　示例：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　以下示例使用 DeleteSheet 方法从运行时数据表中删除工作表"MySheet"。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.DeleteSheet "MySheet"</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　9 Export方法</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　描述：在指定位置保存运行时数据表的副本。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　语法：DataTable.Export(FileName)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　示例：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　以下示例使用 Export 方法将测试的数据表副本保存在 C:\flights.xls 中。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.Export ("C:\flights.xls")</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">10 ExportSheet方法</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　描述：将运行时数据表的指定工作表导出到指定文件中。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　如果指定文件不存在，则将创建一个新文件并保存指定工作表。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　如果当前文件存在，但是该文件不包含具有指定工作表名称的工作表，则将插入该工作表作为文件的最后一个工作表。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　如果当前文件存在且包含指定工作表，则导出的工作表将覆盖现有工作表。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　语法：DataTable.ExportSheet(FileName, DTSheet)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DTSheet 变量要导出的运行时数据表工作表的名称或索引。索引值从 1 开始。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　示例：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　以下示例使用 ExportSheet 方法将运行时数据表的第一个工作表保存到 name.xls 文件中。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.ExportSheet "C:\name.xls" ,1</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.ExportSheet "C:\name.xls" , " MySheet "</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">11 GetSheet方法</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　描述：返回运行时数据表中的指定工作表。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　语法：DataTable.GetSheet(SheetID)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　SheetID 变量标识要返回的工作表。SheetID 可以是工作表名称或索引。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　索引值从 1 开始。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　返回值：DTSheet 对象</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　示例：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　以下示例使用 GetSheet 方法返回运行时数据表的"MySheet"工作表，以便向其中添加参数。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　MyParam=DataTable.GetSheet ("MySheet").AddParameter("Time", "8:00")</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　您还可以使用该方法向"MySheet"本地表中添加参数（注意，不会返回值）。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.GetSheet ("MySheet").AddParameter "Time", "8:00"<br /><br /><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">12 GetSheetCount方法</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　描述：返回运行时数据表中的总工作表数。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　语法：DataTable.GetSheetCount</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　返回值：数字</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　示例：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　以下示例使用 GetSheetCount 方法查找运行时数据表中的总工作表数，并将其写入报告。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　sheetcount = DataTable.GetSheetCount</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　Reporter.ReportEvent 0, "工作表编号", "数据表中有" &amp; sheetcount &amp; "个工作表。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　<strong style="word-break: break-all; line-height: normal !important;">13 Import方法</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　描述：将指定的 Microsoft Excel 文件导入运行时数据表。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　注意：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　导入的表必须与测试或组件匹配。列名必须与测试或组件中的参数匹配，并且工作表名称（用于测试）必须与操作名匹配。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　如果导入的 Excel 表包含组合框或列表单元格、条件格式或其他特殊单元格格式，则不会导入这些格式，并且单元格在数据表中显示时包含固定值。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　语法：DataTable.Import(FileName)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　FileName 字符串型 要导入的 Excel 表的完整路径。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　示例：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　导入的表将替换现有运行时数据表（包括所有数据表）中的所有数据。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　以下示例使用 Import 方法将 flights.xls 表导入运行时数据表。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.Import ("C:\flights.xls")</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　<strong style="word-break: break-all; line-height: normal !important;">　14 ImportSheet方法</strong></div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　描述：将指定文件的工作表导入运行时数据表的指定工作表。导入的工作表中的数据将替换目标工作表中的数据（请参阅 SheetDest 参数）。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　注意：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　导入的工作表中的列标题必须与工作表导入操作中的数据表参数名匹配。否则，测试或组件可能会失败。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　导入的工作表会自动采用它所替换的工作表的名称。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　如果导入的 Excel 工作表包含组合框或列表单元格、条件格式或其他特殊单元格格式，则不会导入这些格式，并且单元格在数据表中显示时包含固定值。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　语法：DataTable.ImportSheet(FileName, SheetSource, SheetDest)</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　FileName 字符串型要从中导入工作表的 Excel 表的完整路径。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　SheetSource 变量 要从文件导入的工作表的名称或索引。索引值从 1 开始。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　SheetDest 变量数据表中要用 SheetSource 替换的工作表的名称或索引。索引值从 1 开始。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　示例：</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　以下示例使用 ImportSheet 方法将 name.xls 表的第一个工作表导入测试的运行时数据表中的Action1工作表。</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.ImportSheet "C:\name.xls" ,1 ," Action1"</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　DataTable.ImportSheet "C:\name.xls" ,1 ," Global"</div><div style="word-break: break-all; line-height: 21.59090805053711px; margin: 10px 0px; font-size: 11.818181991577148px;">　　Qtp中不要使用Global表，会出现死循环现象</div></div></div><img src ="http://www.blogjava.net/qileilove/aggbug/407762.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2013-12-19 11:08 <a href="http://www.blogjava.net/qileilove/archive/2013/12/19/407762.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP中利用DOM实现拖动浏览器滚动条</title><link>http://www.blogjava.net/qileilove/archive/2013/11/18/406468.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 18 Nov 2013 05:49:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2013/11/18/406468.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/406468.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2013/11/18/406468.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/406468.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/406468.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　有的时候需要在<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>的过程中需要模拟拖到浏览器的滚动条,我们可以通过Dom调用DocumentElement下的ScrollTop方法实现.</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">步骤:</strong></div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　(1)通过DOM获取Page的body高度,这个高度是滚动条滚动的最大范围</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　MaxHeight=Pageobj.Object.body.ClientHeight</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　(2)通过DOM调用Page的DocumentElement下的ScrollTop方法,为ScrollTop方式传入参数,实现滚动</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　Pageobj.Object.DocumentElement.ScrollTop=ScrollHeight(注:ScrollHeight为需要滚动到的位置,单位为像素(PX))</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;">　　以下是封装的一个拖到滚动条的函数:</div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">'**********************************************************</div><div style="word-break: break-all; margin: 10px 0px;">'功能:拖到浏览器纵向滚动条</div><div style="word-break: break-all; margin: 10px 0px;">'参数:Pageobj - 需要推动的Page对象</div><div style="word-break: break-all; margin: 10px 0px;">' &nbsp; &nbsp; ScrollPercentage - 滚动条滚动相对于page高度的百分比(如:0.1表示<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">移动</strong></u></a>到十分之一处)</div><div style="word-break: break-all; margin: 10px 0px;">'作者:**</div><div style="word-break: break-all; margin: 10px 0px;">'时间:2013-11-08</div><div style="word-break: break-all; margin: 10px 0px;">'**********************************************************</div><div style="word-break: break-all; margin: 10px 0px;">Function DragScrollBar(Pageobj,ScrollPercentage)</div><div style="word-break: break-all; margin: 10px 0px;">'判断ScrollPercentage是否为数字</div><div style="word-break: break-all; margin: 10px 0px;">If IsNumeric(ScrollPercentage) Then</div><div style="word-break: break-all; margin: 10px 0px;">'判断Pageobj对象是否存在</div><div style="word-break: break-all; margin: 10px 0px;">If Pageobj.Exist Then</div><div style="word-break: break-all; margin: 10px 0px;">'获取浏览器body的高度</div><div style="word-break: break-all; margin: 10px 0px;">MaxHeight = &nbsp;Pageobj.Object.body.ClientHeight</div><div style="word-break: break-all; margin: 10px 0px;">'若ScrollPercentage大于等于1,则滚动条移动到浏览器底部</div><div style="word-break: break-all; margin: 10px 0px;">If &nbsp;ScrollPercentage&gt;=1Then</div><div style="word-break: break-all; margin: 10px 0px;">ScrollHeight = MaxHeight</div><div style="word-break: break-all; margin: 10px 0px;">'若ScrollPercentage小于1,则滚动条移动到ScrollHeight位置</div><div style="word-break: break-all; margin: 10px 0px;">ElseIf (ScrollPercentage&gt;0 And ScrollPercentage&lt;1) Then</div><div style="word-break: break-all; margin: 10px 0px;">ScrollHeight = MaxHeight * ScrollPercentage</div><div style="word-break: break-all; margin: 10px 0px;">'若ScrollPercentage小于0,则滚动条移动到浏览器顶部</div><div style="word-break: break-all; margin: 10px 0px;">Else</div><div style="word-break: break-all; margin: 10px 0px;">ScrollHeight = 0</div><div style="word-break: break-all; margin: 10px 0px;">End If</div><div style="word-break: break-all; margin: 10px 0px;">'根据ScrollHeight移动浏览器滚动条</div><div style="word-break: break-all; margin: 10px 0px;">Pageobj.Object.DocumentElement.ScrollTop = ScrollHeight</div><div style="word-break: break-all; margin: 10px 0px;">Else</div><div style="word-break: break-all; margin: 10px 0px;">Msgbox "Pageobj对象未找到"</div><div style="word-break: break-all; margin: 10px 0px;">End If</div><div style="word-break: break-all; margin: 10px 0px;">Else</div><div style="word-break: break-all; margin: 10px 0px;">Msgbox "ScrollPercentage参数不正确,必须为数字"</div><div style="word-break: break-all; margin: 10px 0px;">End If</div><div style="word-break: break-all; margin: 10px 0px;">End Function</div></td></tr></tbody></table><br /><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; font-size: 12px;"><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;"><strong style="word-break: break-all;">　实例:</strong></div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　<strong style="word-break: break-all;">测试需求:</strong></div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　(1)打开http://www.baidu.com/more/</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">　　(2)拖到打开界面中的滚动条到窗口的60%处</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">'关闭IE浏览器</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Systemutil.CloseProcessByName "iexplore.exe"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">'打开http://www.baidu.com/more/</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Systemutil.Run "iexplore.exe","http://www.baidu.com/more/"</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set Browserobj = Browser("title:=百度产品大全")</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Set Pageobj =Browserobj.Page("title:=百度产品大全")</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">'等待浏览器打开完成</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">While Browserobj.Object.Busy</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Wend</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">'调用DragScrollBar拖到浏览器滚动条到百分之六十处</div><div style="word-break: break-all; margin: 10px 0px; background-color: #ffffff;">Call DragScrollBar(Pageobj,"0.6")</div></td></tr></tbody></table><div style="word-break: break-all; margin: 10px 0px;">版权声明：本文出自 ChinaTNT 的51Testing软件测试博客：http://www.51testing.com/?306685</div><div style="word-break: break-all; margin: 10px 0px;">原创作品，转载时请务必以超链接形式标明本文原始出处、作者信息和本声明，否则将追究法律责任。</div></div></div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; font-size: 12px;"></div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; font-size: 12px;"></div><div style="word-break: break-all; line-height: 21.59375px; margin: 10px 0px; font-size: 12px; height: 21px; position: relative; width: 627.1875px;"></div></div><img src ="http://www.blogjava.net/qileilove/aggbug/406468.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2013-11-18 13:49 <a href="http://www.blogjava.net/qileilove/archive/2013/11/18/406468.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP的飞机登录描述性编程</title><link>http://www.blogjava.net/qileilove/archive/2013/11/08/406136.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 08 Nov 2013 06:13:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2013/11/08/406136.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/406136.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2013/11/08/406136.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/406136.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/406136.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">在<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>中，要先去录制用户名和密码，错误的一次和正确的一次，对于错误所弹出的对话框要进行建立文本的检查点，以便datatable的用例进行比对。用户名和密码要进行参数化，在进行判断。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.2222290039063px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Dim url</div><div style="word-break: break-all; margin: 10px 0px;">url="C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"</div><div style="word-break: break-all; margin: 10px 0px;">if Dialog("text:=Login").Exist(1) then</div><div style="word-break: break-all; margin: 10px 0px;">OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set DataTable("p_Text", dtGlobalSheet)</div><div style="word-break: break-all; margin: 10px 0px;">OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Password:").Set DataTable("p_Text1", dtGlobalSheet)</div><div style="word-break: break-all; margin: 10px 0px;">OptionalStep.Dialog("text:=Login").WinButton("text:=OK").Click</div><div style="word-break: break-all; margin: 10px 0px;">wait(1)</div><div style="word-break: break-all; margin: 10px 0px;">else</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　如果QTP不能自己打开被<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>程序就使用该功能打开</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.2222290039063px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">systemUtil.Run url</div><div style="word-break: break-all; margin: 10px 0px;">OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set DataTable("p_Text", dtGlobalSheet)</div><div style="word-break: break-all; margin: 10px 0px;">OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Password:").Set DataTable("p_Text1", dtGlobalSheet)</div><div style="word-break: break-all; margin: 10px 0px;">OptionalStep.Dialog("text:=Login").WinButton("text:=OK").Click</div><div style="word-break: break-all; margin: 10px 0px;">wait(1)</div><div style="word-break: break-all; margin: 10px 0px;">end if</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　检查点</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.2222290039063px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">if Dialog("text:=Login").Dialog("text:=Flight Reservations").Exist(2) &nbsp;then</div><div style="word-break: break-all; margin: 10px 0px;">dim &nbsp;errorinfor,odesc</div><div style="word-break: break-all; margin: 10px 0px;">set desc=description.Create</div><div style="word-break: break-all; margin: 10px 0px;">odesc("text").value=DataTable("error",dtGlobalSheet)</div><div style="word-break: break-all; margin: 10px 0px;">errorinfor=Dialog("text:=Login").Dialog("text:=Flight Reservations").Static(odesc).GetROProperty("text")</div><div style="word-break: break-all; margin: 10px 0px;">Dialog("text:=Login").Dialog("text:=Flight Reservations").WinButton("text:=确定").Click</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">学习</strong></u></a>一下Reporter方法的用法</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.2222290039063px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Reporter.ReportEvent micDone,"登陆验证失败，提示信息如下",errorinfor</div><div style="word-break: break-all; margin: 10px 0px;">OptionalStep.Dialog("text:=Login").close</div><div style="word-break: break-all; margin: 10px 0px;">wait(1)</div><div style="word-break: break-all; margin: 10px 0px;">else</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　如果用户名和密码正确就进入订票页面</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.2222290039063px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">If Window("text:=Flight Reservation").Exist(10) then</div><div style="word-break: break-all; margin: 10px 0px;">Reporter.ReportEvent micPass,"登陆验证通过","用户名密码正确"</div><div style="word-break: break-all; margin: 10px 0px;">Window("text:=Flight Reservation").close</div><div style="word-break: break-all; margin: 10px 0px;">wait(1)</div><div style="word-break: break-all; margin: 10px 0px;">Set desc=Nothing</div><div style="word-break: break-all; margin: 10px 0px;">end if</div><div style="word-break: break-all; margin: 10px 0px;">end if</div></td></tr></tbody></table><br /><div style="word-break: break-all; margin: 10px 0px;">飞机登录描述性编程图片</div><div style="word-break: break-all; margin: 10px 0px;"><a href="http://www.51testing.com/batch.download.php?aid=43039" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/11/14982672_2013110614234212TRE.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; margin: 10px 0px;">　　测试结果</div><div style="word-break: break-all; margin: 10px 0px;"><a href="http://www.51testing.com/batch.download.php?aid=43040" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/11/14982672_201311061423422jAKj.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; margin: 10px 0px;"><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">版权声明：本文出自 shujin6040 的51Testing软件测试博客：http://www.51testing.com/?597535</div><div style="word-break: break-all; line-height: normal !important; margin: 10px 0px;">原创作品，转载时请务必以超链接形式标明本文原始出处、作者信息和本声明，否则将追究法律责任。</div></div><div style="word-break: break-all; margin: 10px 0px;"></div><div style="word-break: break-all; margin: 10px 0px;"></div><div style="word-break: break-all; margin: 10px 0px; height: 21px; position: relative; width: 627.1875px;"></div><br /></div><img src ="http://www.blogjava.net/qileilove/aggbug/406136.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2013-11-08 14:13 <a href="http://www.blogjava.net/qileilove/archive/2013/11/08/406136.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>testdao简单qtp登录描述性编程</title><link>http://www.blogjava.net/qileilove/archive/2013/10/11/404855.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 11 Oct 2013 02:15:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2013/10/11/404855.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/404855.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2013/10/11/404855.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/404855.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/404855.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><strong style="word-break: break-all; line-height: normal !important;">实验环境：</strong></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　QTP10+ie6+testdao网站登录</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">目的：</strong></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　尝试简单的描述性编程</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　<strong style="word-break: break-all; line-height: normal !important;">　实验内容：</strong></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　====================录制代码================</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　1、运行<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">qtp</strong></u></a>，直接录制打开的页面，以下为录制代码：</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　With Browser("<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>之道 - TestDao").Page("测试之道 - TestDao")</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　.webEdit("username").Set "001"</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　.WebEdit("password").SetSecure "50efa30bb712b83c14d2d01bae7f31d73eef82a6"</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　.WebButton("登录").Click</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　End With</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　===============打开对象库，查看对象属性信息======</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　2、查看对象</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=42643" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/09/14982672_201309291525431OCZa.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　==============根据属性进行修改==============</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　3、进行对象描述</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　With Browser("name:=测试之道 - TestDao").Page("title:=测试之道 - TestDao")</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　.WebEdit("name:=username").Set "001"</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　.WebEdit("name:=password").SetSecure "50efa30bb712b83c14d2d01bae7f31d73eef82a6"</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　.WebButton("name:=登录").Click</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　End With</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　===========验证是否描述性可以不需要对象库的支撑，可以回放成功========</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　4、删除对象库</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=42644" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/09/14982672_2013092915254322DCK.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　===============回放查看结果================</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=42645" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/09/14982672_201309291525433dwTj.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><img src ="http://www.blogjava.net/qileilove/aggbug/404855.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2013-10-11 10:15 <a href="http://www.blogjava.net/qileilove/archive/2013/10/11/404855.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>教你认识自动化测试工具QTP</title><link>http://www.blogjava.net/qileilove/archive/2013/09/30/404637.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Mon, 30 Sep 2013 03:30:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2013/09/30/404637.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/404637.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2013/09/30/404637.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/404637.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/404637.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">初学<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试</strong></u></a>自动化工具的一点感悟及教你认识<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">自动化测试</strong></u></a>工具<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　初学自动化测试工具，总结了几点应该注意的重点问题：</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">1、首先必须进行完善的<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none;"><u style="word-break: break-all;"><strong style="word-break: break-all;">用例设计</strong></u></a>和测试过程设计</strong></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　使用测试工具进行测试<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">工作</strong></u></a>的第一步并不是录制脚本。而是应该在理解被测对象的基础上，进行用例设计和测试过程设计。用例设计包括用例数据、用例测试过程、预期结果等。然后将用例测试过程录制成测试脚本，将用例数据进行参数化。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　完成一项功能或多项相关功能的测试时，需要设计合理的测试过程。不同的测试场景使用独立的一项测试操作实现(表现为一个独立的测试脚本文件)。多项相关<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">功能测试</strong></u></a>时，按设计的测试过程进行测试操作的组合(如使用QTP的操作调用)。这样，每一个测试场景使用不同的测试数据，且各个测试场景独立存在，但有有机地结合起来形成一个完整功能的测试。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">2、检查点是需要进行判断的</strong></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　初学者大多会按照教程设置各种检查点，但并不会看测试结果中检查点的结果。其实，许多检查点只表明了两种结果：&#8220;通过&#8221;或&#8220;失败&#8221;。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　关键的问题是：失败的理由、场景、状态等在结果中很难看出来。所以，在设置检查点后，还必须对检查点结果按照测试过程的业务逻辑进行判断，然后输出更为详细的结果。具体示例见我的上篇<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">日志</strong></u></a>中的&#8220; reporter.ReportEvent 1,"新增学生信息错误","信息存入<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">数据库</strong></u></a>，但数据没有在保存后立即显示，数据编号："+ DataTable("stu_ID", dtLocalSheet)&#8221;。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　此外，检查点的参数化至关重要，因为只有参数化检查点，才能真正体现系统运行过程中动态的变化!</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">3、录制测试与编写测试脚本的目的是便于重复测试</strong></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　既然是为了重复测试，那么就必须认真考虑和设计每个测试活动的前置条件(如在什么样的数据环境下才能开始这个测试活动?)和后置条件(如：本测试活动所录入的数据是否需要保留?)。否则就会很容易出现问题(如：录入数据时关键字重复!)。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　<strong style="word-break: break-all; line-height: normal !important;">4、测试工具不能解决所有问题</strong></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　许多初学者总希望测试工具能帮助他们解决所有问题。其实许多测试项目是必须靠手工完成的。如：界面布局的合理性、系统使用的方便性等。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　自动工具永远只是辅助手段!所以测试工作的关键还是对测试对象的理解、<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试用例</strong></u></a>与测试过程的设计。有了完善的用例，不管是手工测试还是自动测试，都是可以很好地完成测试任务的。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　说到自动化测试，就不得不提大名鼎鼎的QTP了，Mercury QTP简称QTP,是一个先进的</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　先进的自动化测试工具，它可以用于创建功能和回归测试。自动捕获、验证和重放用户的交互行为。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　QTP为每一个重要软件应用和环境提供功能和回归测试自动化的行业最佳解决方案,它是新一代自动化测试解决方案，采用了关键词驱动（Keyword-Driven）测试的理念，能完全简化测试的创建和维护工作。QTP关键词驱动方式独有之处在于，测试自动化专家可以通过一个整合的脚本和纠错环境，拥有对基础测试脚本和对象属性的完全访问权限，这些脚本和纠错环境与关键词视图（Keyword View）可以互为同步。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　QTP同时满足了技术型和非技术型用户的需求，让各个公司有能力部署更高质量的应用，同时部署的速度更快，费用更低，风险也更小。QTP和我们新的测试自动化系统Mercury Business Process Testing?的紧密结合，可以将非技术型的业务专家（SME, Subject-Matter Experts）引入质量流程，这一意义重大的引入可以将IT和业务更好地融合，最终建立起更出色的应用。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　有了该产品，您的QA部门可以获取多方面的优势：</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　1.用最少的培训赋予整个小组创建成熟测试方案的能力。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　2.确保跨所有环境、数据包和业务流程的正确功能点。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　3.为开发人员全面记录和复制缺陷，使他们能更快地修复缺陷，满足最后上线期限。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　4.对不断变化的应用和环境展开便捷的回归测试。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　5.成为帮助整个机构实现高质量产品和服务、提高总收入和收益率的关键角色。<br /><div style="word-break: break-all; margin: 10px 0px;"><strong style="word-break: break-all; line-height: normal !important;">QTP是如何工作的</strong></div><div style="word-break: break-all; margin: 10px 0px;">　　QTP易于操作，即使是初级的测试人员也能在短时间内对其驾轻就熟。您可以使用无需脚本的关键词视图来表现测试的每个步骤，仅由此就可创建一个测试。您还可以通过QTP所集成的录制能力来捕获测试步骤。该产品用简单的英语以文档形式记录每个步骤，并通过活动屏幕将文档与一个集成截屏相结合。传统的脚本记录工具所生产的脚本不易修改，与此不同的是，QTP的关键词驱动方式能让您便捷地插入、修改、数据驱动（data-drive）和移除测试步骤。</div><div style="word-break: break-all; margin: 10px 0px;">　　QTP可以自动引入检查点来验证应用的属性和功能点，比如确认输出量或检查链接的有效性。在关键词视图的每一步骤中，活动屏幕可显示被测应用在该步骤中的确切状态。您还可以为任意对象加入几种检查点，仅仅在活动屏幕中点击该对象，就可以验证该组件行为是否达到了期望值。</div><div style="word-break: break-all; margin: 10px 0px;">　　然后您可以将测试数据输入数据表（Data Table），它拥有和Excel同样完善的功能特性，是一个集成的电子数据表格。您可以使用数据集并创建多种重复测试，无需编程就可以扩展测试案例的覆盖面。数据可以通过键入的方式输入或从数据库、数据表格或文本文档中导出。</div><div style="word-break: break-all; margin: 10px 0px;">　　高级测试人员可以在专家视图（Expert View）中查看和修改他们的测试，在专家视图中显示了由QTP自动生成的基于行业标准的基本VBscrīpt语言。在专家视图中所做的任何改动将自动与关键词视图同步。</div><div style="word-break: break-all; margin: 10px 0px;">　　一旦测试人员运行了一个脚本，TestFusion报告将显示测试运行各方面的信息，包括：高水平的结果纵览；一个可扩展的测试脚本树状视图（Tree View），其明确指出了应用错误的发生位置；被使用的测试数据；每个步骤的应用截屏，其中并标明了所有的差异；以及通过或未通过每个检查点的详细解释。您可以将TestFusion报告和QTP结合，从而与整个QA和开发小组分享这些报告。</div><div style="word-break: break-all; margin: 10px 0px;">　　QTP处理一些应用的新版本问题。当一个被测应用发生变化时，比如把一个&#8221;Login&#8221;按钮被改名为&#8221;Sign in&#8221;，您可以在共享对象容器（Shared Object Repository）中做一次更新，接着此次更新将扩展到所有涉及这个对象的脚本。您可以将测试脚本公布给Mercury Quality Management，使其它的QA小组成员也可以使用您的测试脚本，从而减少了重复工作。</div><div style="word-break: break-all; margin: 10px 0px;">　　通过与Business Process Testing的整合，在一个基于web的系统中，QTP被用于实现自动化操作，使非技术型用户可以便捷地在一个完全的无脚本环境中也能够建立起测试。</div><div style="word-break: break-all; margin: 10px 0px;">　　QTP支持多种企业环境的功能测试，包括Windows、Web、.NET、 Java/J2EE、SAP、Siebel、Oracle、PeopleSoft、Visual Basic、ActiveX、Mainframe terminal emulators和Web services。</div><div style="word-break: break-all; margin: 10px 0px;">　　<strong style="word-break: break-all; line-height: normal !important;">Mercury功能测试</strong></div><div style="word-break: break-all; margin: 10px 0px;">　　那些在Mercury WinRunner</div></div><img src ="http://www.blogjava.net/qileilove/aggbug/404637.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2013-09-30 11:30 <a href="http://www.blogjava.net/qileilove/archive/2013/09/30/404637.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>我的测试历程—QTP之狭义的数据驱动模型</title><link>http://www.blogjava.net/qileilove/archive/2013/09/29/404603.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Sun, 29 Sep 2013 02:32:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2013/09/29/404603.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/404603.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2013/09/29/404603.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/404603.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/404603.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　07年我参加了<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">软件测试</strong></u></a>工程师培训课程（课程中包含自动测试工具，功能：<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>，性能：LR），QTP课程主要讲解了QTP的关键字视图相关的内容（专家视图部分没有涉及），培训完以后，我对QTP的认识是：QTP使用起来很简单，就是一个录制、回放（不通过就调试）、细化脚本、再回放（不通过就再调试）、出报告的过程，那时候对QTP的认识很肤浅，也和一些朋友一样对QTP产生过类似的质疑：QTP能满足实际项目包罗万象的需求吗？当时感觉QTP只能应用在主要流程的验证上，而且没有真正意义上做到测试的自动化（当然以上都是07年对QTP的认识）于是我停止了继续深入学习QTP&#8230;&#8230;</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　09年9月左右，由于项目人手少，测试时间又短，所以每次版本更新后，只对新增功能和相关模块进行测试，而比较稳定的模块只走一个正常流程（甚至时间太紧连正常流程也来不及走了），另外由于我所在项目和另外一个项目都是一个大项目的子项目，所以另外一个项目的修改也可能导致本项目的一些功能不可用，下面有个实际项目中遇到的例子：有一次另外那个项目修改了<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">数据库</strong></u></a>结构，数据库中删除了一个字段，导致我这个项目的一些特别稳定的功能中查询该字段的所有地方都报&#8220;黄页&#8221;（当然这些地方都做了安全处理，只抛了个自定义的页面，没有把代码抛出来），当时吓出了一身&#8220;冷汗&#8221;，还好每次更新我都会挑一些没有修改模块进行抽查，这次运气好，刚好抽到了，俗话说：&#8220;吃一堑长一智&#8221;，就算完全没有修改的模块也应该验证一下，但是目前的时间和人力只够对新功能的测试，我又想到了QTP，于是我安装了QTP，将老功能的业务流程录制成脚本，每次更新后，跑一下流程，验证一下老功能是否可用，成功案例：有一次QTP回放当中发现2个地方报&#8220;黄页&#8221;，后来才知道是因为另外一个项目更新了WEBSERVICE，而我这个项目的那2个地方刚好要调用那个WEBSERVICE，所以会报错，由于这一次的经历让我忽然对QTP产生了兴趣，对QTP脚本进行了更深入的<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">学习</strong></u></a>，从07年的完全自动录制到现在的手动写脚本，从脚本依赖对象库到脱离对象库，从求助别人到帮别人写实际项目的<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">自动化测试</strong></u></a>脚本，从各个测试脚本相互独立，到自己编写自动化测试框架&#8230;&#8230;2个月前自己写了个测试框架，实现了运行一个VBS脚本，就可以打开QTP（脱离对象库）并按照CASE优先级从高到低运行所有需要运行的CASE，运行结束自动将结果写入文件中&#8230;&#8230;2个星期前重新设计框架提高脚本开发效率和简单易用性。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　下面写下现在我对QTP的看法：在没有接触自动化测试框架之前，我所有的脚本都是都是相互独立的，即：每个功能作为一个TESTCASE，这样就导致每次都要手动把每个脚本运行一遍，然后看报告，感觉自动化一点也不自动化，而且脚本的可重用性也很不好。于是我就在想，怎样才能做到真正意义上的自动化呢？可不可以通过运行一个驱动脚本打开QTP然后自动运行所有指定的脚本用例呢？后来在网上查了相关资料，开始自己搭建自动化测试框架：</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　我的第一个框架：由依赖对象库到脱离对象库，由自动录制到手动编写测试脚本。这个框架思想是学习于51</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　论坛中的《轻量级自动化测试框架》，只不过在此基础添加了一些功能，比如用例执行优先级。当时觉得这个框架很好用，全部使用描述性编程这样可以使用例不依赖对象库运行，提高了脚本的可移植性，但是随着对QTP认识的不断的深入，渐渐的发现描述性编程的弊端：脚本开发效率太低，同样开发一个测试脚本，完全使用描述性编程和自动录制+手动增强脚本相比，录制一个同样的功能，需要的时间大约3-4倍，甚至更长，因为使用描述性编程需要对对象的各个属性特别熟悉，另外完全使用描述性编程的调试效率也很低，使用哪些属性作为识别该对象的依据又需要一个判断过程，这样都会降低测试脚本的开发效率，还有描述性编程对编程基础有一定要求，所以我觉得脚本开发应该以自动录制+手动增强脚本为主，以描述性编程为辅。因为在有的项目中有些步骤可能通过自动录制是录制不到的，这时候描述性编程就起到很好的辅助作用。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　我的第二个框架：由脱离对象库到依赖对象库，由手动编写测试脚本到自动录制+手动增强脚本（以描述性编程为辅）。由于第一个框架的弊端，所以我在想怎样避免这个弊端，提高脚本开发效率，自动录制是开发脚本最快的一种方式，而且对脚本开发人员的要求很低，于是我开始把目光回归到QTP这一最简单最基本的功能上。开始设计一个属于我们&#8220;菜鸟&#8221;的测试框架。（其中借鉴了《QTP项目应用与进阶》中<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">测试用例</strong></u></a>模板）</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　这个框架（相对于第一个框架）的优点：1、降低人员素质的要求，使用例的脚本开发人员不需要懂得太多QTP方面的专业知识，只要掌握简单的录制回放过程和脚本增强就可以，这样避免有些人整天忙有些人&#8220;没事&#8221;做了，从而达到资源的充分利用。2、提高脚本开发效率。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　这个框架（相对于第一个框架）的缺点：调用外部ACTION相对复杂一点，需要明确知道该ACTION所在脚本的位置，不过这一点可以通过文档解决这个问题，制作一个 ACTION列表就可以了。2、对象+<br /><br /><div style="word-break: break-all; margin: 10px 0px;">　由于这个框架写在了&#8220;丫头&#8221;的毕业论文中，目前她还没答辩，为了避免不必要的麻烦，所以这里就不详细写了（大家看了附件的框架实例就应该能明白我的思路了）本实例是使用QTP10.0录制的，重点阐述的是一种思想，脚本中很多功能未加入。例如：自动加载插件的功能，不过大家可以自己加一下（QTP自动化对象模型参考中有加载插件的代码），另外QTP版本比较低的朋友可以自己录制下脚本替换掉Script文件夹下对应的脚本试下。若要设置脚本运行时QTP可见，可以将函数driver（）中的qtapp.visible=False修改为qtapp.visible=True</div><div style="word-break: break-all; margin: 10px 0px;">　　最后，如果哪位朋友有什么好的建议或觉得哪里需要改进，可以给我留言，如果有时间我会试着改进一下，另外写的不好的地方也请多多指正，谢谢！</div><div style="word-break: break-all; margin: 10px 0px;">　　向大家推荐2本QTP相关的很不错书：</div><div style="word-break: break-all; margin: 10px 0px;">　　《QTP项目应用与进阶》 &nbsp; &nbsp;E测工作室（风过无息、斐明哲、黄先容、韩柳、俞戴龙 &nbsp; 化学工业出版社</div><div style="word-break: break-all; margin: 10px 0px;">　　《QTP自动化测试实践》 &nbsp; &nbsp;陈能技 &nbsp; &nbsp; &nbsp;电子工业出版社</div><div style="word-break: break-all; margin: 10px 0px;">　　第一本书我买了而且前段时间看了，感觉很不错，思路很清晰，而且包含编码规范等自动化以外的的知识，感觉写的蛮好的。</div><div style="word-break: break-all; margin: 10px 0px;">　　第二本书最近才了解到这本书，不过没看过，朋友说很不错，正打算买呢，另外看了作者博客里的资料，感觉写的很好，所以就推荐大家看看，希望能对大家有所帮助，谢谢！</div><div style="word-break: break-all; margin: 10px 0px;">版权声明：本文由会员 feiyunkai 首发于51Testing软件测试论坛 [软件测试新手上路] 版块。</div><div style="word-break: break-all; margin: 10px 0px;">原创作品，转载时请务必以超链接形式标明本文原始出处、作者信息和本声明，否则将追究法律责任。</div><div style="word-break: break-all; margin: 10px 0px;">相关文章：</div><div style="word-break: break-all; margin: 10px 0px;"><a href="http://www.51testing.com/html/03/n-852603.html" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;">我的测试历程---用例设计思路（安装/卸载）</a></div></div><img src ="http://www.blogjava.net/qileilove/aggbug/404603.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2013-09-29 10:32 <a href="http://www.blogjava.net/qileilove/archive/2013/09/29/404603.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【QTP】WebTable里存储数据的一种方法</title><link>http://www.blogjava.net/qileilove/archive/2013/09/27/404525.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 27 Sep 2013 02:41:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2013/09/27/404525.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/404525.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2013/09/27/404525.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/404525.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/404525.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">最近看到坛子里有人在问WebTable控件获取数据后，存储和使用的便捷方式。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　这里我就献丑写一下我在这块上的处理方式，我自己做了个简单的页面，来演示一些使用：</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=42530" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/09/14982672_201309231101021vfR4.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　比如上面这个页面，取数据不难，主要是直观，所以我用的方法是用数组与字典结合的方式：</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><table align="center" style="word-break: break-all; border-style: solid; border-color: #999999; width: 612.2222290039063px; background-color: #dddddd; font-size: 12px;"><tbody style="word-break: break-all;"><tr style="word-break: break-all;"><td style="word-break: break-all;"><div style="word-break: break-all; margin: 10px 0px;">Dim oTable</div><div style="word-break: break-all; margin: 10px 0px;">Set oTable = Browser("无标题文档").Page("无标题文档").WebTable("表格")</div><div style="word-break: break-all; margin: 10px 0px;">Dim oRow, oCol</div><div style="word-break: break-all; margin: 10px 0px;">oRow = oTable.RowCount</div><div style="word-break: break-all; margin: 10px 0px;">oCol = oTable.ColumnCount(1)</div><div style="word-break: break-all; margin: 10px 0px;">Dim arrData()</div><div style="word-break: break-all; margin: 10px 0px;">ReDim arrData(oRow)</div><div style="word-break: break-all; margin: 10px 0px;">Dim i , j</div><div style="word-break: break-all; margin: 10px 0px;">For i = 1 to oRow-1</div><div style="word-break: break-all; margin: 10px 0px;">Set arrData(i)=CreateObject("Scripting.Dictionary")</div><div style="word-break: break-all; margin: 10px 0px;">For j = 1 to oCol</div><div style="word-break: break-all; margin: 10px 0px;">arrData(i).Add Trim(oTable.GetCellData(1,j)) , oTable.GetCellData(i+1,j)</div><div style="word-break: break-all; margin: 10px 0px;">Next</div><div style="word-break: break-all; margin: 10px 0px;">Next</div><div style="word-break: break-all; margin: 10px 0px;">print &nbsp;arrData(3)("姓名")</div><div style="word-break: break-all; margin: 10px 0px;">print &nbsp;arrData(9)("数据3")</div></td></tr></tbody></table></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　下面的是使用和打印的效果。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=42531" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/09/14982672_201309231101022z8ag.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　OK，算是抛砖引玉吧。</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff; height: 21px; position: relative; width: 627.1875px;"></div><img src ="http://www.blogjava.net/qileilove/aggbug/404525.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2013-09-27 10:41 <a href="http://www.blogjava.net/qileilove/archive/2013/09/27/404525.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>QTP提供的编程接口实现对QTP操作</title><link>http://www.blogjava.net/qileilove/archive/2013/09/27/404520.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 27 Sep 2013 02:38:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2013/09/27/404520.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/404520.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2013/09/27/404520.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/404520.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/404520.html</trackback:ping><description><![CDATA[<div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　我们可以通过调用 Automation Object Model 里的对象接口 ,来实现对<a href="" target="_self" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><u style="word-break: break-all;"><strong style="word-break: break-all;">QTP</strong></u></a>&nbsp;的操作,如打开 /运行脚本等动作</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;">　　Automation object model 的对象结构图如下 (摘自QTP 参考手册 )</div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=42537" target="_blank" style="word-break: break-all; color: #202859; text-decoration: none; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/09/14982672_201309231401021AsK8.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"><a href="http://www.51testing.com/batch.download.php?aid=42538" target="_blank" style="word-break: break-all; color: #45a2fc; line-height: normal !important;"><img src="http://www.51testing.com/attachments/2013/09/14982672_201309231401022G2wx.jpg" border="0" style="word-break: break-all; list-style: none outside none; margin: 0px; padding: 0px; border: none; max-width: 500px;"  alt="" /></a></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff;"></div><div style="word-break: break-all; line-height: 23.99305534362793px; margin: 10px 0px; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 13.333333969116211px; background-color: #ffffff; height: 21px; position: relative; width: 627.1875px;"></div><img src ="http://www.blogjava.net/qileilove/aggbug/404520.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2013-09-27 10:38 <a href="http://www.blogjava.net/qileilove/archive/2013/09/27/404520.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>