´Ö¿´ Selenium
ÔÚµäÐ͵ÄÔÚÏßÉ̵êÖУ¬ÐèÒªÓû§ÊäÈë»òÑ¡ÔñÖڶಽÖèºó²Å¿ÉÒÔÍê³ÉÕû¸ö¹ºÎïÁ÷³Ì¡£×÷ΪwebÓ¦ÓõĿª·¢Õߣ¬ÄãÈçºÎ±£Ö¤Äã³ÌÐòµÄÖÊÁ¿ºÍÕýÈ·ÐÔÄØ£¿Èç¹ûÄÜÓа취²âÊÔÄ㹦ÄܵÄÕýÈ·ÐÔ£¬ÄÇÎÊÌâ¾ÍÓÈжø½âÁË£¬µ«ÈçºÎ×öµ½ÄØ?
Selenium ÊÇÒ»¸öÓÉThoughtWorks×öµÄרÃÅΪwebÓ¦ÓÃËù×öµÄ·Ç³£ÓÐЧµÄ¹¦ÄܲâÊÔ¹¤¾ß¡£Selenium µÄ tests Ö±½ÓÔÚä¯ÀÀÆ÷ÀïÅÜ£¬¾ÍÏñÓû§ÕæµÄÔÚ²Ù×÷Ò»Ñù¡£Selenium ¿ÉÔËÐÐ Windows, Linux, ºÍ Macintosh µÄ¸÷ÖÖä¯ÀÀÆ÷£¬ Èç Internet Explorer, Mozilla ºÍ Firefox¡£
¿´¿´Selenium µÄ online demo ¡£µã»÷ÓÒÉϽǵÄ"All"°´Å¥À´Æô¶¯ÔËÐÐtest cases£¬ ÈçÎÞÒâÆäÍ⣬Ä㽫¿´µ½ËùÓж¼ÊÇÂÌÐС£×¢ÒâactionµÄÂÌÉ«ÊÇ»á±ÈassertionsdzµÄ£¬ÕâÊÇÒòΪËûÃDzâÊÔµÄËùÓж«Î÷¶¼Ö»ÊÇverify»ò assert ÃüÁî¡£Èç¹ûÓÐÒ»¸öassertion ʧ°ÜÁË£¬ÔòÄÇÐÐÃüÁî»á±äΪºìÉ«£¬²¢ÇÒSelenium »áÍ£Ö¹ÔËÐС£Èç¹ûverify ÃüÁîʧ°ÜÁË£¬ÄÇÐÐÃüÁîÒ²»á±äΪºìÉ«£¬µ«ÊDz»»áÈòâÊÔÍ£ÏÂÀ´¡£
ÔÚ Selenium ÖеÄTest suites ºÍ cases ʵ¼ÊÉÏÊÇÓÉ HTML д³ÉµÄ£¬ ËüÃÇÖ»ÊǺܼòµ¥µÄ HTMLs¡£ test suite ÖÐûÐж¼Ö»ÊǹØÁªÁËÒ»¸ötest case, ÀýÈ磺
test-caseʵ¼ÊÉÏÊÇÓÉ "Selenese" д³ÉµÄ HTML Îĵµ£¬ÀïÃæ°üÓÐÒ»¸ötable£ ......
//Óû§ÃûУÑéµÄ·½·¨
//Õâ¸ö·½·¨½«Ê¹ÓÃXMLHTTPRequest¶ÔÏóÀ´½øÐÐAJAXµÄÒì²½Êý¾Ý½»»¥
var xmlhttp;
function verify() {
//0¡£Ê¹ÓÃdomµÄ·½Ê½»ñÈ¡Îı¾¿òÖеÄÖµ
//document.getElementById("userName")ÊÇdomÖлñÈ¡ÔªËØ½ÚµãµÄÒ»ÖÖ·½·¨£¬Ò»¸öÔªËØ½Úµã¶ÔÓ¦HTMLÒ³ÃæÖеÄÒ»¸ö±êÇ©£¬Èç¹û<input>
//¡£value¿ÉÒÔ»ñȡһ¸öÔªËØ½ÚµãµÄvalueÊôÐÔÖµ
var userName = document.getElementById("userName").value;
//1.´´½¨XMLHttpRequest¶ÔÏó
//ÕâÊÇXMLHttpReuquest¶ÔÏóÎÞ²¿Ê¹ÓÃÖÐ×ÔÓµÄÒ»²½
//ÐèÒªÕë¶ÔIEºÍÆäËûÀàÐ͵Ää¯ÀÀÆ÷½¨Á¢Õâ¸ö¶ÔÏóµÄ²»Í¬·½Ê½Ð´²»Í¬µÄ´úÂë
if (window.XMLHttpRequest) {
//Õë¶ÔFireFox£¬Mozillar£¬Opera£¬Safari£¬IE7£¬IE8
xmlhttp = new XMLHttpRequest();
//Õë¶ÔÄ³Ð©ÌØ¶¨°æ±¾µÄmozillarä¯ÀÀÆ÷µÄBUG½øÐÐÐÞÕý
&nb ......
AJAXÖÐÎÄÎÊÌâ·ÖΪÁ½´óÀࣺ
1£©·¢ËÍ·¾¶ÖеIJÎÊýÓÐÖÐÎÄ£¬ÔÚ·þÎñÆ÷¶Î½ÓÊÕ²ÎÊýÖµÊÇÂÒÂë
ÀýÈ磺
var url="a.jsp?name=СÀî"£»
xmlHTTP.open ("post",url,true);
½â¾ö°ì·¨£º
ÀûÓÃjavascriptµÄÌṩµÄescape()»òencodeURI()·½·¨
ÀýÈ磺
¿Í»§¶Ë£º
var url="a.jsp?name=СÀî"£»
url=encodeURI(url);
url=encodeURI(url); //Á½´Î£¬ºÜ¹Ø¼ü[¾ßÌåΪʲô£¬ÎÒÒ²²»Çå³þ]
/********************************************/
Ò²ÓÐÈËд³Évar url="a.jsp?name=escape("СÀî")"£»
¹¦ÄܺÍencodeURI·½·¨ÀàËÆ¡£
/********************************************/
xmlHTTP.setrequestheader("cache-control","no-cache");
xmlHTTP.setrequestheader("Content-Type","application/x-www-form-urlencoded");
xmlHTTP.setrequestheader("contentType","text/html;charset=uft-8")//Ö¸¶¨·¢ËÍÊý¾ÝµÄ±àÂë¸ñʽ
xmlHTTP.open ("post",url,true);
·þÎñÆ÷¶Ë£º
String name = request.getParameter("name");
name = java.net.URLDecoder.decode(&qu ......
function ajaxFunction()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("ÄúµÄä¯ÀÀÆ÷²»Ö§³ÖAJAX£¡");
return false;
}
}
}
} ......
ÔÚweb.configÖÐÐÞ¸ÄÐÞ¸ÄÊôÐÔ
1£º<configSections><configSections>ÖмÓÏÂÃæ´úÂë
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version ......
ÔÚweb.configÖÐÐÞ¸ÄÐÞ¸ÄÊôÐÔ
1£º<configSections><configSections>ÖмÓÏÂÃæ´úÂë
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajaxµ¯³öʾÀý-¿É¿ØÖÆÊ±¼ä×ÔÓÉÇл»ºÍ¹Ø±Õ</title>
<script type="text/javascript">
var NowImg = 1;
var bStart = 0;
var bStop =0;
function fnToggle()
{
var next = NowImg + 1;
if(next == 6)
{
NowImg = 6;
next = 1;
}
if(bStop!=1)
{
if(bStart == 0)
{
bStart = 1;
setTimeout('fnToggle()', 20000);
return;
}
else
{
document.getElementById("oDIV1").style.display="none"
......