ÓÃSelenium ²âÊÔ Ajax ÏîÄ¿
´Ö¿´ 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£¬3¸öÁУ¬ËùÓеÄÃüÁî×î¶àÖ»ÓÐÁ½¸ö²ÎÊý£¬ËùÒÔ×㹻λÖðڷš£Ò»¸öµäÐ͵Ätest caseÏñÕâÑù£º
µ±Ä㿪ʼÔËÐвâÊÔ (ÀýÈç °´ "All"°´Å¥), Selenium µÄ TestRunner »á×Ô¶¯½âÊÍ HTML ¸ñʽµÄ test-case£¬ ²¢ÔËÐÐÄãµÄwebÓ¦Ó㬲¢ÔÚÒ³ÃæÏ·½µÄ¿ò¼ÜÖÐÏÔʾÔËÐеÄÇéÐΡ£ Selenium ÔÊÐíÄãͨ¹ýÔÚä¯ÀÀÆ÷ÀïÄ£ÄâÓû§µÄÐÐΪÀ´½øÐвâÊÔ¡£Õ⵱Ȼ²»´ú±íËü¿ÉÒÔ´úÌæunit-testing£¬Ö»ÊÇÎÒÃÇͨ³£»áÓÃËüÀ´½øÐÐwebÓ¦ÓõŦÄܲâÊÔ¡£ËüÒ² ¿ÉÒÔ±»¼ÓÈë³ÖÐø¼Ì³Ð²âÊÔ(continuous-integration)ÖУ¬×÷Ϊ³£¹æµÄ×Ô¶¯»Ø¹é²âÊÔ(regression testing)¡£Èç¹ûÏë¸üÉîÈëÁ˽âSelenium, Çë²Î¿´ÔÚÏßÎĵµ "Selenium: Usage".
¿ªÊ¼²âÊÔ Ajax ÔÚÄãµÄwebÓ¦Óù¦ÄÜÊÇÓÃJavaScriptʵÏÖʱ£¬Selenium ¾ÍÏԵü«ÎªÓÐÓÃÁË¡£ Ajax, ÊÇAsynchronous JavaScript and XML µÄ¼ò³Æ£¬ÊÇwebÓ¦ÓÃÖеÄÒ»ÖÖweb ½»»¥¼¼Êõ¡£Ëü¿ÉÒÔʵÏÖÔÚÒ³Ãæ²»ÐèҪˢеÄÇé¿öÏ£¬ÔÚºǫ́Óë·þÎñÆ÷½»»¥ÉÙÁ¿Êý¾Ý£¬²¢¼´Ê±¸Ä±äÒ³ÃæÄÚÈÝ¡£ÕâÒâζ×ÅÍøÒ³¿´ÆðÀ´¸üʵʱ£¬¸üÓж¯Ì¬ºÍ¸üʵÓá£
Ajax ÖÐָʾÕýÔÚ"¶ÁÈ¡Êý¾Ý"µÄ±êÇ© ¸Õ²ÅÄǾ仰ÊǶÔAjaxµÄ¼¼Êõ¶¨Ò壬¶ÔÓÚÎÒÃÇ´ó¶àÊýÈËÀ´Ëµ£¬AjaxÒâζ×ÅÒ³ÃæÏòGMail »ò Flickr ÄÇÑù¡£µ±ÄãµãÒ»¸öÁ¬½Óʱ£¬Ëü²»»á²úÉúÒ³ÃæˢУ¬¶øÊÇÒ³Ãæ»áºÍ·þ
Ïà¹ØÎĵµ£º
HTML´úÂëÈçÏÂ:
LoginValidate.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoginValidate.aspx.cs" Inherits="LoginValidate" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ÑéÖ¤Óû§ÃûÊÇ·ñ´æÔÚ</title>
<script type="text/j ......
Ò»¸öajaxÇëÇóÒ»¸öjspÎļþ£¬²Ù×÷³É¹¦,jspÎļþout.println("1");µ«ÊÇÿ´Î³É¹¦ºóxmlHttp.responseText=='1'×ÜÊÇΪfalse£¬
ÓÃencodeURIComponent¿´xmlHttp.responseText£¬·¢ÏÖ×îºó¶àÁË%0A%0D£¬°Ù¶ÈһϠÓÃÀ´ÊÇ»»ÐУ¬
jspÎļþÖеÄout.println……°ÑlnÈ¥µôÔÙ´Î±È½Ï ³É¹¦ = =¡ ......
Õâ¸öÀàÕª×Ô£º ASP.NET AjaxµäÐÍÓ¦Óà һÊé
xmlhttp.js
function $() {
var elements = new Array();
for (var i = 0; i < arguments.length; i++) {
var element = arguments[i];
if (typeof element == 'string')
elem ......
¸ÐлÄú×¢²áʹÓà Google AJAX Search API ÃÜÔ¿£¡
ÄúµÄÃÜÔ¿ÊÇ£º
ABQIAAAA2XOmDwsdSefVWtliFM7oAhRgUnSrtx2R2fBqn5WGl7l070PqvBRbr7s7L72cRNSIH96KndKP3sbASw
¸ÃÃÜÔ¿¿ÉÓÃÓÚ¸ÃĿ¼ÖеÄËùÓÐÍøÖ·£º
http://www.rdladmin.test
ÒÔÏÂÊÇ°ïÖúÄúÈëÃŵÄʵÀýÍøÒ³£º
<!DOCTYPE html PUBLIC "-//W3C//DTD X ......
Ò»°ãÀ´Ëµ£¬ÄãÖ»ÐèÒªÒ»¸ödwr.xmlÎļþ£¬²¢ÇÒ·ÅÖÃÔÚĬÈϵÄλÖãºWEB-INF/dwr.xml¡£ Èç¹ûÄÇÑùµÄ»°£¬Äã¿ÉÒÔ²»ÓÃÁ˽âÏÂÃæµÄÅäÖá£
ÓÐÈý¸öÔÒòʹÄãÏ£ÍûÖ¸¶¨²»Í¬Î»ÖõÄdwr.xmlÎļþ¡£
ÄãÏ£ÍûÈÃdwr.xmlÎļþºÍËüÄÜ·ÃÎʵ½µÄ×ÊÔ´ÔÚÒ»Æð¡£ÔÚÕâÖÖÇé¿öÏÂÄãÐèÒªÒ»¸öÕâÑùµÄÅäÖ㺠<param-value>WEB-INF/classes/com/yourco/dwr/dwr. ......