前端性能测试自动化—精通软件性能测试与LoadRunner最佳实战(15)

发表于:2013-7-17 11:00

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

 作者:于涌 王磊等    来源:51Testing软件测试网采编

  VBScript脚本代码(page_check.vbs文件内容):

' Page Check VBScript Example

' For more information about this example please refer to the readme.txt file in the

' same directory

'

WScript.Echo(vbCrLf & "Enter the URL of the page to check (press enter for www.httpwatch.com):" & vbCrLf)

Dim url

url = WScript.StdIn.ReadLine

if Len(url) = 0 then

url = "www.httpwatch.com"

end if

WScript.Echo( vbCrLf & "Checking " & url & "..." & vbCrLf)

' Create a new instance of HttpWatch in IE

Dim control

Set control = CreateObject("HttpWatch.Controller")

Dim plugin

Set plugin = control.IE.New

' Start Recording HTTP traffic

plugin.Log.EnableFilter false

plugin.Record

' Goto to the URL and wait for the page to be loaded

plugin.GotoURL url

control.Wait plugin, -1

' Stop recording HTTP

plugin.Stop

if plugin.Log.Pages.Count <> 0 then

WScript.Echo("")

WScript.Echo("Page Title: '" & plugin.Log.Pages(0).Title & "'")

' Display summary statistics for page

Dim summary

Set summary = plugin.Log.Pages(0).Entries.Summary

WScript.Echo( "Total time to load page (secs):      " & summary.Time)

WScript.Echo( "Number of bytes received on network: " & summary.BytesReceived)

WScript.Echo( "HTTP compression saving (bytes):     " & summary.CompressionSavedBytes)

WScript.Echo( "Number of round trips:               " & summary.RoundTrips)

WScript.Echo( "Number of errors:                    " & summary.Errors.Count)

end if

' Close down IE

plugin.CloseBrowser

WScript.Echo( vbCrLf & "Press Enter to exit")

WScript.StdIn.ReadLine

  JavaScript脚本代码(page_check.js文件内容):

// Page Check Javascript Example

// 

// For more information about this example please refer to the readme.txt file in the

// same directory

//

WScript.Echo("\nEnter the URL of the page to check (press enter for www.httpwatch.com):\n");

var url = WScript.StdIn.ReadLine();

if ( url.length == 0 )

url = "www.httpwatch.com";

WScript.Echo("\nChecking " + url + "...\n");

// Create a new instance of HttpWatch in IE

var control = new ActiveXObject('HttpWatch.Controller');

var plugin = control.IE.New();

// Start Recording HTTP traffic

plugin.Log.EnableFilter(false);

plugin.Record();

// Goto to the URL and wait for the page to be loaded

plugin.GotoURL(url);

control.Wait(plugin, -1);

// Stop recording HTTP

plugin.Stop();

if ( plugin.Log.Pages.Count != 0 )

{

WScript.Echo( "\nPage Title: '" + plugin.Log.Pages(0).Title + "'");

// Display summary statistics for page

var summary = plugin.Log.Pages(0).Entries.Summary;

WScript.Echo( "Total time to load page (secs):      " + summary.Time);

WScript.Echo( "Number of bytes received on network: " + summary.BytesReceived);

WScript.Echo( "HTTP compression saving (bytes):     " + summary.CompressionSavedBytes);

WScript.Echo( "Number of round trips:               " + summary.RoundTrips);

WScript.Echo( "Number of errors:                    " + summary.Errors.Count);

}

// Close down IE

plugin.CloseBrowser();

WScript.Echo( "\r\nPress Enter to exit");

WScript.StdIn.ReadLine();

43/4<1234>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

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

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

沪ICP备05003035号

沪公网安备 31010102002173号