发布新日志

  • jQuery实现AJAX定时局部页面刷新

    2013-07-02 18:43:19

    不时,我需要某种机制,不断刷新网页,以提供一个实时的仪表板某种。如果我只能刷新一个特定的页面的一部分,这将是很大的,例如:仪表盘上的交通灯显示系统状态。

    这是很容易通过使用jQuery JavaScript库,只刷新页面的一部分。一旦我们纳入我们的页面的jQuery库,我们只需要1行的JavaScript得到它的工作:

    1
    <script src="/js/jquery-1.3.2.min.js" type="text/javascript"></script>

    所以我们只要我们的页面放入这个小的JS代码片段刷新里面的内容ID标签的一切,让我们说,每5秒:

    1
    2
    3
    setInterval(function() {
        $("#content").load(location.href+" #content>*","");
    }, 5000);

     

    这就是它!!因此,这是很容易完成一些实时监控的行为,只是那行代码。没有更奇怪的元刷新标记或iframe一种解决方法,在Web应用程序。

    每5秒,我们将刷新内容相同的URL和所有元素,驻留在元素ID为content元素的内容:内容。

  • jQuery Ajax 全解析

    2013-07-02 18:35:26

    jQuery Ajax 全解析

    http://www.cnblogs.com/QLeelulu/archive/2008/04/21/1163021.html

    本文地址: jQuery Ajax 全解析

    本文作者:QLeelulu

    转载请标明出处!

    jQuery确实是一个挺好的轻量级的JS框架,能帮助我们快速的开发JS应用,并在一定程度上改变了我们写JavaScript代码的习惯。

    废话少说,直接进入正题,我们先来看一些简单的方法,这些方法都是对jQuery.ajax()进行封装以方便我们使用的方法,当然,如果要处理复杂的逻辑,还是需要用到jQuery.ajax()的(这个后面会说到).

    1. load( url, [data], [callback] ) :载入远程 HTML 文件代码并插入至 DOM 中。

    url (String) : 请求的HTML页的URL地址。

    data (Map) : (可选参数) 发送至服务器的 key/value 数据。

    callback (Callback) : (可选参数) 请求完成时(不需要是success的)的回调函数。

    这个方法默认使用 GET 方式来传递的,如果[data]参数有传递数据进去,就会自动转换为POST方式的。jQuery 1.2 中,可以指定选择符,来筛选载入的 HTML 文档,DOM 中将仅插入筛选出的 HTML 代码。语法形如 "url #some > selector"。

    这个方法可以很方便的动态加载一些HTML文件,例如表单。

    示例代码:

    $(".ajax.load").load("http://www.cnblogs.com/QLeelulu/archive/2008/03/30/1130270.html .post",
      function (responseText, textStatus, XMLHttpRequest){
      this;//在这里this指向的是当前的DOM对象,即$(".ajax.load")[0] 
      //alert(responseText);//请求返回的内容
      //alert(textStatus);//请求状态:success,error
      //alert(XMLHttpRequest);//XMLHttpRequest对象
    });

    广州.NET俱乐部的活动

    今天去参加广州.NET俱乐部的活动。下着毛毛的雨,本来不想去了,后来三明说去,然后就去了。

    主要说了WPF Silverlight mobile开发

    去到的时候,已经开始了,人很多。

    WPF的DEMO很炫啊,看得我都完全心动,对视频的支持也非常好。有机会好好学。

    Silverlight 讲得也不错。

    彭斌依然很幽默,讲的mobile开发的DEMO很不错,自己对mobile开发也有那么一点点的了解了。

    要学的东西好多啊!!!baxia!!

    posted on 2008-03-30 22:19 Q.Lee.lulu 阅读(...) 评论(...编辑 收藏

     

    注:不知道为什么URL写绝对路径在FF下会出错,知道的麻烦告诉下。下面的get()和post()示例使用的是绝对路径,所以在FF下你将会出错并不会看到返回结果。还有get()和post()示例都是跨域调用的,发现传上来后没办法获取结果,所以把运行按钮去掉了。

     

    2. jQuery.get( url, [data], [callback] ):使用GET方式来进行异步请求

    参数:

    url (String) :  发送请求的URL地址.

    data (Map) : (可选) 要发送给服务器的数据,以 Key/value 的键值对形式表示,会做为QueryString附加到请求URL中。

    callback (Function) : (可选) 载入成功时回调函数(只有当Response的返回状态是success才是调用该方法)。

    这是一个简单的 GET 请求功能以取代复杂 $.ajax 。请求成功时可调用回调函数。如果需要在出错时执行函数,请使用 $.ajax。示例代码:

      $.get("./Ajax.aspx", {Action:"get",Name:"lulu"}, function (data, textStatus){
        //返回的 data 可以是 xmlDoc, jsonObj, html, text, 等等.
        this; // 在这里this指向的是Ajax请求的选项配置信息,请参考下图
        alert(data);
        //alert(textStatus);//请求状态:success,error等等。
    当然这里捕捉不到error,因为error的时候根本不会运行该回调函数
    //alert(this); });

    点击发送请求:

    jQuery.get()回调函数里面的 this ,指向的是Ajax请求的选项配置信息:

    image

     

    3. jQuery.post( url, [data], [callback], [type] ) :使用POST方式来进行异步请求

    参数:

    url (String) : 发送请求的URL地址.

    data (Map) : (可选) 要发送给服务器的数据,以 Key/value 的键值对形式表示。

    callback (Function) : (可选) 载入成功时回调函数(只有当Response的返回状态是success才是调用该方法)。

    type (String) : (可选)官方的说明是:Type of data to be sent。其实应该为客户端请求的类型(JSON,XML,等等)

    这是一个简单的 POST 请求功能以取代复杂 $.ajax 。请求成功时可调用回调函数。如果需要在出错时执行函数,请使用 $.ajax。示例代码:

    Ajax.aspx:

    Response.ContentType = "application/json";
    Response.Write("{result: '" + Request["Name"] + ",你好!(这消息来自服务器)'}");
    jQuery 代码:
    $.post("Ajax.aspx", { Action: "post", Name: "lulu" },
      function (data, textStatus){
       // data 可以是 xmlDoc, jsonObj, html, text, 等等.
       //this; // 这个Ajax请求的选项配置信息,请参考jQuery.get()说到的this
       alert(data.result);
      }, "json");

    点击提交:

    这里设置了请求的格式为"json":

    image

    如果你设置了请求的格式为"json",此时你没有设置Response回来的ContentType 为:Response.ContentType = "application/json"; 那么你将无法捕捉到返回的数据。

    注意一下,alert(data.result); 由于设置了Accept报头为“json”,这里返回的data就是一个对象,并不需要用eval()来转换为对象。

     

    4. jQuery.getScript( url, [callback] ) : 通过 GET 方式请求载入并执行一个 JavaScript. 文件

    参数

    url (String) : 待载入 JS 文件地址。

    callback (Function) : (可选) 成功载入后回调函数。

    jQuery 1.2 版本之前,getScript. 只能调用同域 JS 文件。 1.2中,您可以跨域调用 JavaScript. 文件。注意:Safari 2 或更早的版本不能在全局作用域中同步执行脚本。如果通过 getScript. 加入脚本,请加入延时函数。

    这个方法可以用在例如当只有编辑器focus()的时候才去加载编辑器需要的JS文件.下面看一些示例代码:

    加载并执行 test.js。

    jQuery 代码:

    $.getScript("test.js");


    加载并执行 AjaxEvent.js ,成功后显示信息。

    jQuery 代码:

    $.getScript("AjaxEvent.js", function(){
      alert("AjaxEvent.js 加载完成并执行完成.你再点击上面的Get或Post按钮看看有什么不同?");
    });

     

    加载完后请重新点击一下上面的 Load 请求看看有什么不同。

    jQuery Ajax 事件

    Ajax请求会产生若干不同的事件,我们可以订阅这些事件并在其中处理我们的逻辑。在jQuery这里有两种Ajax事件:局部事件 和 全局事件。

    局部事件就是在每次的Ajax请求时在方法内定义的,例如:

     $.ajax({
       beforeSend: function(){
         // Handle the beforeSend event
       },
       complete: function(){
         // Handle the complete event
       }
       // ...
     });

    全局事件是每次的Ajax请求都会触发的,它会向DOM中的所有元素广播,在上面 getScript() 示例中加载的脚本就是全局Ajax事件。全局事件可以如下定义:

     $("#loading").bind("ajaxSend", function(){
       $(this).show();
     }).bind("ajaxComplete", function(){
       $(this).hide();
     });

    或者:

     $("#loading").ajaxStart(function(){
       $(this).show();
     }); 

    我们可以在特定的请求将全局事件禁用,只要设置下 global 选项就可以了:

     $.ajax({
       url: "test.html",
       global: false,// 禁用全局Ajax事件.
       // ...
     });

    下面是jQuery官方给出的完整的Ajax事件列表:

  • ajaxStart (Global Event)
    This event is broadcast if an Ajax request is started and no other Ajax requests are currently running.
    • beforeSend (Local Event)
      This event, which is triggered before an Ajax request is started, allows you to modify the XMLHttpRequest object (setting additional headers, if need be.)
    • ajaxSend (Global Event)
      This global event is also triggered before the request is run.
    • success (Local Event)
      This event is only called if the request was successful (no errors from the server, no errors with the data).
    • ajaxSuccess (Global Event)
      This event is also only called if the request was successful.
    • error (Local Event)
      This event is only called if an error occurred with the request (you can never have both an error and a success callback with a request).
    • ajaxError (Global Event)
      This global event behaves the same as the local error event.
    • complete (Local Event)
      This event is called regardless of if the request was successful, or not. You will always receive a complete callback, even for synchronous requests.
    • ajaxComplete (Global Event)
      This event behaves the same as the complete event and will be triggered every time an Ajax request finishes.
  • ajaxStop (Global Event)
    This global event is triggered if there are no more Ajax requests being processed.

    具体的全局事件请参考API文档。
    好了,下面开始说jQuery里面功能最强的Ajax请求方法 $.ajax();  

     

    jQuery.ajax( options ) : 通过 HTTP 请求加载远程数据

    这个是jQuery 的底层 AJAX 实现。简单易用的高层实现见 $.get, $.post 等。

    $.ajax() 返回其创建的 XMLHttpRequest 对象。大多数情况下你无需直接操作该对象,但特殊情况下可用于手动终止请求。

    注意: 如果你指定了 dataType 选项,请确保服务器返回正确的 MIME 信息,(如 xml 返回 "text/xml")。错误的 MIME 类型可能导致不可预知的错误。见 Specifying the Data Type for AJAX Requests 。
    当设置 datatype 类型为 'script' 的时候,所有的远程(不在同一个域中)POST请求都回转换为GET方式。

    $.ajax() 只有一个参数:参数 key/value 对象,包含各配置及回调函数信息。详细参数选项见下。

    jQuery 1.2 中,您可以跨域加载 JSON 数据,使用时需将数据类型设置为 JSONP。使用 JSONP 形式调用函数时,如 "myurl?callback=?" jQuery 将自动替换 ? 为正确的函数名,以执行回调函数。数据类型设置为 "jsonp" 时,jQuery 将自动调用回调函数。(这个我不是很懂)

    参数列表:

  • jquery 局部刷新, ajax函数应用示例 $.post 及$.get 的用法

    2013-07-02 18:34:25

    有两个文件,运行一下,你就知道效果了

    网上转过来的资料,是理解ajax() 函数    post及get方式的很好的例子。

    点第一个按钮,是不是一个局部刷新的好例子啊。 如果把数据处理放在ajax_json.php里,那还可以改成一个小小微博吧  

    index.php

    <html>
    <head>
    <title>jQuery Ajax 实例演示</title>
    </head>
    <meta. http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script. language="javascript" src="js/jquery.js"></script>
    <script. language="javascript">
    $(document).ready(function ()
    {


       $('#send_ajax').click(function (){
         var params=$('input').serialize(); //序列化表单的值
    alert(params);
         $.ajax({
           url:'ajax_json.php', //后台处理程序
           type:'post',         //数据发送方式
           dataType:'json',     //接受数据格式
           data:params,         //要传递的数据
           success:update_page //回传函数(这里是函数名) //通过对json回传值的处理来做显示处理
         });
       });
       

    //$.post()方式:
    $('#test_post').click(function (){
        $.post(
          'ajax_json.php',
          {
            username:$('#input1').val(),
            age:$('#input2').val(),
            sex:$('#input3').val(),
            job:$('#input4').val()
          },
          function (data) //回传函数
          {
            var myjson='';
            eval('myjson=' + data + ';');
            $('#result').html("姓名:" + myjson.username + "<br/>工作:" + myjson['job']);
          }
        );
       });
       
      

       
       
    //$.get()方式:
    $('#test_get').click(function ()
    {
        $.get(
          'ajax_json.php',
          {
            username:$("#input1").val(),
            age:$("#input2").val(),
            sex:$("#input3").val(),
            job:$("#input4").val()
          },
          function(data) //回传函数
          {
            var myjson='';
            eval("myjson=" + data + ";");
             $('#result').html("姓名:" + myjson.username + "<br/>工作:" + myjson['job']);
          }
        );
    });


    });

    function update_page (json) //回传函数实体,参数为XMLhttpRequest.responseText
    {
    var str="姓名:"+json.username+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    str+="年龄:"+json.age+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    str+="性别:"+json.sex+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    str+="工作:"+json.job+"<br/>";
    //$("#result").html(str);
    alert($("#result").append("<br/>新消息:<font color=green>"+str+"</font><br/>"));
    }


    </script>

    <body>
    <div id="result" style="background:orange;border:1px solid red;width:400px;height:200px;"></div>
    <form. id="formtest" action="" method="post">
        <p><span>输入姓名:</span><input type="text" name="username" id="input1" /></p>
        <p><span>输入年龄:</span><input type="text" name="age" id="input2" /></p>
        <p><span>输入性别:</span><input type="text" name="sex" id="input3" /></p>
        <p><span>输入工作:</span><input type="text" name="job" id="input4" /></p>
    </form>
    <button id="send_ajax">提交</button>
    <button id="test_post">POST提交</button>
    <button id="test_get">GET提交</button>
    <button id="ajax_post">GET提交</button>
    </body>
    </html>

    ajax_json.php

    <?php
    //$arr = $_POST; //若以$.get()方式发送数据,则要改成$_GET.或者干脆:$_REQUEST
    $arr = $_REQUEST;
    //$arr['append'] = '测试字符串';
    //print_r($arr);
    if(function_exists("json_encode"))
    echo json_encode($arr);
    else
    echo $arr;
    ?>

  • 如何做一个让开发人员看得起的测试人员

    2012-07-06 15:48:39

    做测试做了8年,前两年做的是与硬件产品相关的测试,质量管理比软件行业要严格的多的多,原因是,大部分的应用软件代码出错,改下代码重新编译,打补丁,就ok了,而一旦硬件设计出错,或者零件用错,造成的成本损失会很大,严重的可能是电路板报废,更严重的是导致整批产品的报废。当然,软件出错也能造成无可挽回的损失,只是某些特定领域会要求很严格,知识相对于硬件来说,程序修改要比电路板的维修成本相对低一些。

    因为这种现象的存在,所以很多国内企业,尤其是一些小型的企业,对测试重视程度不够,甚至没有专门的测试人员,可能有的是为了项目需要,设立了测试团队,1人测试团队也屡见不鲜,我就知道好多企业是一人测试组,而且还是应届生的也有。对于这样的企业,您无法想象测试人员的地位会是什么样,老板都觉得设置测试人员是组织架构需要,而不是为了质量需要,那开发人员对测试人员自然也是不太看得起。

    由于专职测试人员并不参与产品的代码编写,所以给人一种非生产劳动力的感觉,而且大多企业都是用一些编码能力较弱的人去做测试。

    在很多外企中,对测试相对国内会重视一些,对测试人员素质要求也较高,对测试人员培训也较重视,但是并不代表测试人员地位就高,一样是会有开发人员看不起测试的情况,这种看不起并不会流于表面,而是骨子里的,没人说出来,但是会存在,大家心知肚明。

    然而我们有时候也会听到有开发人员说某某测试人员挺厉害的,那么怎么样才能做一名让开发人员佩服的测试人员呢?

    一,编程语言

    你至少要掌握一门语言,不管是简单的php,java,还是C++也好,或者其他的脚本语言python,perl还是shell也好,至少你用一种语言真正的做过一些事情,而且能拿来就用。

    二,数据库

    你至少要掌握一种数据库的DBA,对SQL的操作要熟悉,至少能熟练的运用JOIN进行查询,知道基本的HAVING的用法,如果你能写存储过程,并且能优化存储过程那当然更好了,测试人员离不开数据库的管理和数据库的操作。

    三,操作系统

    作为测试人员,各种操作系统你应该很熟悉,系统安装,配置,管理,一个都不能少,对于Linux,你至少要对一种系统做过系统管理,熟悉常用的命令行操作,具体要会哪些,建议google一下,用Linux的时候,尽量能用命令行,就不要去点鼠标,因为它不是windows,要改变这样的习惯。能在Linux下能安装和配置软件,最好建议大家自己下载source code,亲自编译,了解make file的原理。

    四,扎实的软件测试理论

    这是做为测试人员最基本的,不要连开发人员都知道的一些测试方法,我们测试人员竟然没听过,很多测试人员觉得理论知识我看过,以为自己就了解了,其实做过一段时间之后,你再回头去看理论,会有更多的收获,我工作多年之后再看测试方面的书籍,发现还是会有不同的收获,理论是实践经验的总结,不能说最好,但是如果说你设计测试用例的时候,如果每种方法都有涉及到,你肯定会发现用例覆盖率会高,而且容易发现bug。

    五,尽量自己分析问题

    发现问题了,怎么办?可以找相关的开发人员帮忙分析,但是我想说的是,在发现问题之后,能自己尽量的寻找线索,首先要确定非环境因素,比如检查配置是否全部正确,网络是否有问题等等,然后确定非环境因素后,保护现场,保存记录系统提示信息,如果有日志功能,那自己先根据日志查找一些线索,并把自己检查过的地方和做过的分析信息尽可能多的提供给开发人员,而不是仅仅把错误日志或者错误信息丢给开发人员让他们分析就不管了。

    六,多涉猎一些项目之外的知识

    不要做一个项目,就两耳不闻窗外事,做测试的就是要涉猎的广,跟开发不同,测试是要能接受任何类型的项目,因为测试是一门方法学,方法学是不受某个产品或者领域限制的,但是如果你对其他领域也了解的多,对你做测试是有帮助的,前沿技术你也要了解一些。

    七,掌握一些安全方面的知识

    往往系统安全是很重要的,如果你能提出一些系统安全方面的漏洞,那别人自然会觉得你考虑的比较全面,至于安全方面需要哪些知识,我觉得首先从网络安全入手,了解一些密码学方面的知识,比如了解常用的加密算法原理,比如报文加密传输协议原理,建议看一下hash的方法,这个简单容易理解,还比较容易举一反三。

    八,提高沟通能力,懂得尊重开发人员

    测试人员要面对的人员很多,客户,项目经理,开发人员,产品经理等,有时候你会全部都接触的到,那么沉默就不一定是金,有良好正确的沟通能力,会帮助你提高在其他人心目中的好印象,沟通不是能说就行,要正确的沟通,高效的沟通,就是能用最简洁的语言把事情描述清楚,沟通的好,你的人缘就会好,就自然会受到大家的欢迎,其他人也愿意与你合作,千万不要在背后评论开发人员,即使评论,也评论别人的优点有哪些值得我们学习,懂得尊重开发人员,即使是你技术比别人强,懂得尊重别人的人才能被别人尊重。

    九,不要自己把自己的地位降低

    很多测试人员觉得自己做的测试工作本身就没有技术含量,觉得自己的工作创造的价值少,没有挑战性,其实如果连你自己都看不起自己,那如何让别人看得起你呢?

    总之,做测试,是一门技术,也是一门艺术,我们把世界分为三个层次:技术(Technology),科学(Science),艺术(Art),技术是底层的,科学高一层,艺术是最高层的,技术可以通过短时间内学会,而如果把技术上升为科学,是需要大量的研究和积累的,而艺术的层次,这个不是学的来的,你需要有天赋,比如乔布斯,他就是因为有了艺术的天赋才造就了成功的苹果。

    看着上面这些,你会不会觉得做测试要比开发需要学习的东西更多呢?如果你这么想,那就是正确的,真正优秀的测试人员,绝对是要在综合能力方面超过开发人员的,因为,你懂得的不仅仅是一门技术,你已经掌握了一门艺术。

    杨柳@ 广州

    杨柳博客网原文链接:http://www.yangliu.cc/?p=311

  • 长文章分页类 PHP

    2010-04-27 16:40:41

    <?php
    /*  
    *   长文章分页类  
    */  
    !defined('IN_MUDDER') && exit('Access Denied');
         class cutpage{    
             var $pagestr;       //被切分的内容    
             var $pagearr;       //被切分文字的数组格式    
             var $sum_word;       //总字数(UTF-8格式的中文字符也包括)    
             var $sum_page;       //总页数    
             var $page_word;     //一页多少字    
             var $cut_tag;       //自动分页符    
             var $cut_custom;     //手动分页符    
             var $ipage;         //当前切分的页数,第几页    
             var $url;    
             
             function __construct(){   
                 $this->page_word = 3000;   
                 $this->cut_tag = array("</table>", "</div>", "</p>", "<br/>", "”。", "。", ".", "!", "……", "?", ",");   
                 $this->cut_custom = "{nextpage}";   
                 $tmp_page = intval(trim($_GET["ipage"]));   
                 $this->ipage = $tmp_page>1?$tmp_page:1;   
             }   
             //统计总字数   
             function get_page_word(){   
                 $this->sum_word = $this->strlen_utf8($this->pagestr);   
                 return $this->sum_word;   
             }   
             /*   统计UTF-8编码的字符长度 
             *   一个中文,一个英文都为一个字 
             */ 
             function strlen_utf8($str){   
               $i = 0;   
               $count = 0;   
               $len = strlen ($str);   
               while ($i < $len){   
                   $chr = ord ($str[$i]);   
                   $count++;   
                   $i++;   
                   if ($i >= $len)   
                       break;   
                   if ($chr & 0x80){   
                       $chr <<= 1;   
                       while ($chr & 0x80) {   
                           $i++;   
                           $chr <<= 1;   
                       }   
                   }   
               }   
               return $count;   
             }   
             //设置自动分页符号   
             function set_cut_tag($tag_arr=array()){   
                 $this->cut_tag = $tag_arr;   
             }   
             //设置手动分页符   
             function set_cut_custom($cut_str){   
                 $this->cut_custom = $cut_str;   
             }   
             function show_cpage($ipage=0){   
                 $this->cut_str();   
                 $ipage = $ipage ? $ipage:$this->ipage;   
                 return $this->pagearr[$ipage];   
             }   
             function cut_str(){   
                 $str_len_word = strlen($this->pagestr);     //获取使用strlen得到的字符总数   
                 $i = 0;   
                 if ($str_len_word<=$this->page_word){   //如果总字数小于一页显示字数
                    if (strpos($this->pagestr, $this->cut_custom)){   
                         $page_arr = explode($this->cut_custom, $this->pagestr);   
                     }else{   
                     $page_arr[$i] = $this->pagestr;
                     }   
                 }else{   
                     if (strpos($this->pagestr, $this->cut_custom)){   
                         $page_arr = explode($this->cut_custom, $this->pagestr);   
                     }else{   
                         $str_first = substr($this->pagestr, 0, $this->page_word);   //0-page_word个文字     cutStr为func.global中的函数   
                         foreach ($this->cut_tag as $v){   
                             $cut_start = strrpos($str_first, $v);       //逆向查找第一个分页符的位置   
                             if ($cut_start){   
                                 $page_arr[$i++] = substr($this->pagestr, 0, $cut_start).$v;   
                                 $cut_start = $cut_start + strlen($v);   
                                 break;   
                             }   
                         }   
                         if (($cut_start+$this->page_word)>=$str_len_word){   //如果超过总字数   
                             $page_arr[$i++] = substr($this->pagestr, $cut_start, $this->page_word);   
                         }else{   
                             while (($cut_start+$this->page_word)<$str_len_word){   
                                 foreach ($this->cut_tag as $v){   
                                     $str_tmp = substr($this->pagestr, $cut_start, $this->page_word);         //取第cut_start个字后的page_word个字符   
                                     $cut_tmp = strrpos($str_tmp, $v);       //找出从第cut_start个字之后,page_word个字之间,逆向查找第一个分页符的位置   
                                     if ($cut_tmp){   
                                         $page_arr[$i++] = substr($str_tmp, 0, $cut_tmp).$v;   
                                         $cut_start = $cut_start + $cut_tmp + strlen($v);   
                                         break;   
                                     }   
                                 }     
                             }   
                             if (($cut_start+$this->page_word)>$str_len_word){   
                                 $page_arr[$i++] = substr($this->pagestr, $cut_start, $this->page_word);   
                             }   
                         }   
                     }   
                 }   
                 $this->sum_page = count($page_arr);     //总页数   
                 $this->pagearr = $page_arr;   
             }   
             //显示上一条,下一条   
             function show_prv_next(){   
                 $this->set_url();   
                 if ($this->sum_page>1 and $this->ipage<$this->sum_page){   
                     $str = "<a href='".$this->url.($this->ipage+1)."'><b>下一页</b>& lt;/a> ";
                     $str .= $this->show_page_select();   
                 }else{
                    $str= "<font color='gray'>下一页</font>";
                    $str .= $this->show_page_select();
                 }   
                 if ($this->sum_page>1 and $this->ipage>1){   
                     $str.= "<a href='".$this->url.($this->ipage-1)."'><b>上一页</b>& lt;/a>";   
                 }else{
                    $str.= "<font color='gray'>上一页</font>";
                 }   
                 return $str;   
             }   
             function show_page_select(){   
                 if ($this->sum_page>1){   
                     $str .= "   <select nchange=\"location.href=this.options[this.selectedIndex].value\">";   
                     for ($i=1; $i<=$this->sum_page; $i++){   
                         $str.= "<option value='".$this->url.$i."' ".(($this->ipage)==$i ? " selected='selected'":"").">第".$i."页</option>";   
                     }   
                     $str.= "</select>";   
                 }   
                 return $str;   
             }   
             function show_page_select_wap(){   
                 if ($this->sum_page>1){   
                     $str = "<select ivalue='".($this->ipage-1)."'>";   
                     for ($i=1; $i<=$this->sum_page; $i++){   
                         $str.= "<option npick='".$this->url.$i."'>第".$i."节</option>";   
                     }   
                     $str.= "</select>";   
                 }   
                 return $str;   
             }   
             function set_url(){   
                 parse_str($_SERVER["QUERY_STRING"], $arr_url);   
                 unset($arr_url["ipage"]);   
                 if (empty($arr_url)){   
                     $str = "ipage=";   
                 }else{   
                     $str = http_build_query($arr_url)."&ipage=";   
                 }   
                 $this->url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]."?".$str;   
             }   
         }
        
         
    ?>


    //文章分页
    $article_content = $article['content'];   
    $ipage = $_GET["ipage"]? intval($_GET["ipage"]):1;   
    $CP = new cutpage();
    $CP->pagestr = $article_content;   
    $CP->cut_str();
    $currentpage = $CP->pagearr[$ipage-1];  
    $pre_next_page = $CP->show_prv_next();
    $page_number = $CP->show_page_select_wap();
    $select_page_number = $CP->show_page_select();
  • 给文本框添加灰色提示文字

    2010-04-18 17:19:24

    <html>
    <head>
    <title>给文本框添加灰色提示文字</title>
    <meta http-equiv="content-Type" content="text/html;charset=gb2312">
    </head>
    <body>
    <!--把下面代码加到<body>与</body>之间-->
    <input type="text" id="key" name="key" value="请输入关键词" onFocus="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#999'}" style="color:#999999">
    </body>
    </html>
  • 网站测试流程、要求及测试报告

    2009-12-28 17:03:19

     网站测试流程、要求及测试报告
    一个网站基本完工后,需要通过下面三步测试才可以交活。
    一、 制作者测试,包括美工测试页面、程序员测试功能。在做完后第一时间内有制作者本人进行测试。
    a) 页面 包括首页、二级页面、三级页面的页面在各种常用分辨率下有无错位;图片上有没有错别字;各连接是否是死连接;各栏目图片与内容是否对应等
    b) 功能 达到客户要求;数据库连接正确;各个动态生成连接正确;传递参数格式、内容正确;试填测试内容没有报错;页面显示正确
    二、 全面测试 根据交工标准和客户要求,由专人进行全面测试
    也是包括页面和程序两方面,而且要结合起来测,保证填充足够的内容后不会导致页面变形。另外要检查是否有错别字,文字内容是否有常识错误。
    三、 发布测试 网站发布到主服务器之后的测试,主要是防止环境不同导致的错误



    软件缺陷的原则
    软件缺陷区别于软件bug,它是在测试过程中出现的对系统有影响的,但是在设计中没有的或者对修改后的bug测试和开发人员有不同意见等
    软件未达到产品说明书标明的功能。
    软件出现了产品说明书指明不会出现的错误。
    软件功能超出产品说明书指明范围。
    软件未达到产品说明书虽未指出但应达到的目标。
    软件测试员认为软件难以理解、不易使用、运行速度缓慢,或者最终用户认为不好。



    测试的主要方面:

    一、功能测试

    对于网站的测试而言,每一个独立的功能模块需要单独的测试用例的设计导出,主要依据为《需求规格说明书》及《详细设计说明书》,对于应用程序模块需要设计者提供基本路径测试法的测试用例。

    1、链接测试
       链接是Web应用系统的一个主要特征,它是在页面之间切换和指导用户去一些不知道地址的页面的主要手段。链接测试可分为三个方面:

    1)测试所有链接是否按指示的那样确实链接到了该链接的页面;

    2)测试所链接的页面是否存在;

    3)保证Web应用系统上没有孤立的页面,所谓孤立页面是指没有链接指向该页面,只有知道正确的URL地址才能访问。

    链接测试可以自动进行,现在已经有许多工具可以采用。链接测试必须在集成测试阶段完成,也就是说,在整个Web应用系统的所有页面开发完成之后进行链接测试。

    Xenu------主要测试链接的正确性的工具
    可惜的是对于动态生成的页面的测试会出现一些错误。

    2、表单测试

    当 用户给Web应用系统管理员提交信息时,就需要使用表单操作,例如用户注册、登陆、信息提交等。在这种情况下,我们必须测试提交操作的完整性,以校验提交 给服务器的信息的正确性。例如:用户填写的出生日期与职业是否恰当,填写的所属省份与所在城市是否匹配等。如果使用了默认值,还要检验默认值的正确性。如 果表单只能接受指定的某些值,则也要进行测试。例如:只能接受某些字符,测试时可以跳过这些字符,看系统是否会报错。

    要测试这些程序,需要验证服务器能正确保存这些数据,而且后台运行的程序能正确解释和使用这些信息。

    B/S结构实现的功能可能主要的就在这里,提交数据,处理数据等如果有固定的操作流程可以考虑自动化测试工具的录制功能,编写可重复使用的脚本代码,可以在测试、回归测试时运行以便减轻测试人员工作量。

    我们对UM子系统中各个功能模块中的各项功能进行逐一的测试,主要测试方法为:边界值测试、等价类测试,以及异常类测试。测试中要保证每种类型都有2个以上的典型数值的输入,以确保测试输入的全面性。

    3、Cookies测试
       Cookies通常用来存储用户信息和用户在某应用系统的操作,当一个用户使用Cookies访问了某一个应用系统时,Web服务器将发送关于用户的信息,把该信息以Cookies的形式存储在客户端计算机上,这可用来创建动态和自定义页面或者存储登陆等信息。

    如果Web应用系统使用了Cookies,就必须检查Cookies是否能正常工作而且对这些信息已经加密。测试的内容可包括Cookies是否起作用,是否按预定的时间进行保存,刷新对Cookies有什么影响等。

    4、设计语言测试

    Web 设计语言版本的差异可以引起客户端或服务器端严重的问题,例如使用哪种版本的HTML等。当在分布式环境中开发时,开发人员都不在一起,这个问题就显得尤 为重要。除了HTML的版本问题外,不同的脚本语言,例如Java、Javascrīpt、 ActiveX、VBscrīpt或Perl等也要进行验证。

    5、数据库测试

      在Web应用技术中,数据库起着重要的作用,数据库为Web应用系统的管理、运行、查询和实现用户对数据存储的请求等提供空间。在Web应用中,最常用的数据库类型是关系型数据库,可以使用SQL对信息进行处理。

    在使用了数据库的Web应用系统中,一般情况下,可能发生两种错误,分别是数据一致性错误和输出错误。数据一致性错误主要是由于用户提交的表单信息不正确而造成的,而输出错误主要是由于网络速度或程序设计问题等引起的,针对这两种情况,可分别进行测试。

    二、性能测试

    网站的性能测试对于网站的运行而言异常重要,但是目前对于网站的性能测试做的不够,我们在进行系统设计时也没有一个很好的基准可以参考,因而建立网站的性能测试的一整套的测试方案将是至关重要的。
    网站的性能测试主要从三个方面进行:连接速度测试、负荷测试(Load)和压力测试(Stress),

    连接速度测试指的是打开网页的响应速度测试。负荷测试指的是进行一些边界数据的测试,压力测试更像是恶意测试,压力测试倾向应该是致使整个系统崩溃。

    1、连接速度测试

      用户连接到Web应用系统的速度根据上网方式的变化而变化,他们或许是电话拨号,或是宽带上网。当下载一个程序时,用户可以等较长的时间,但如果仅仅访问一个页面就不会这样。如果Web系统响应时间太长(例如超过5秒钟),用户就会因没有耐心等待而离开。

      另外,有些页面有超时的限制,如果响应速度太慢,用户可能还没来得及浏览内容,就需要重新登陆了。而且,连接速度太慢,还可能引起数据丢失,使用户得不到真实的页面。

    2、负载测试

       负载测试是为了测量Web系统在某一负载级别上的性能,以保证Web系统在需求范围内能正常工作。负载级别可以是某个时刻同时访问Web系统的用户数 量,也可以是在线数据处理的数量。例如:Web应用系统能允许多少个用户同时在线?如果超过了这个数量,会出现什么现象?Web应用系统能否处理大量用户 对同一个页面的请求?

    3、压力测试

      负载测试应该安排在Web系统发布以后,在实际的网络环境中进行测试。因为一个企业内部员工,特别是项目组人员总是有限的,而一个Web系统能同时处理的请求数量将远远超出这个限度,所以,只有放在Internet上,接受负载测试,其结果才是正确可信的。

      进行压力测试是指实际破坏一个Web应用系统,测试系统的反映。压力测试是测试系统的限制和故障恢复能力,也就是测试Web应用系统会不会崩溃,在什么情况下会崩溃。黑客常常提供错误的数据负载,直到Web应用系统崩溃,接着当系统重新启动时获得存取权。

    压力测试的区域包括表单、登陆和其他信息传输页面等。

    采用的测试工具:

    性能测试可以采用相应的工具进行自动化测试,我们目前采用如下工具
    ab -----Apache 的测试工具
    OpenSTA—开发系统测试架构

    三、接口测试
    在很多情况下,web 站点不是孤立。Web 站点可能会与外部服务器通讯,请求数据、

    验证数据或提交订单。

    1、 服务器接口
    第一个需要测试的接口是浏览器与服务器的接口。测试人员提交事务,然后查看服务器

    记录,并验证在浏览器上看到的正好是服务器上发生的。测试人员还可以查询数据库,确认事务数据已正确保存。

    2、 外部接口
    有些 web 系统有外部接口。例如,网上商店可能要实时验证信用卡数据以减少欺诈行

    为 的发生。测试的时候,要使用 web 接口发送一些事务数据,分别对有效信用卡、无效信用卡和被盗信用卡进行验证。如果商店只使用 Visa 卡和 Mastercard 卡, 可以尝试使用 Discover 卡的数据。(简单的客户端脚本能够在提交事务之前对代码进行识别,例如 3 表示 American Express,4 表示 Visa,5 表示 Mastercard,6 代表Discover。)通常,测试人员需要确认软件能够处理外部服务器返回的所有可能的消息。

    3、错误处理
    最容易被测试人员忽略的地方是接口错误处理。通常我们试图确认系统能够处理所有错

    误,但却无法预期系统所有可能的错误。尝试在处理过程中中断事务,看看会发生什么情况?

    订单是否完成?尝试中断用户到服务器的网络连接。尝试中断 web 服务器到信用卡验证服

    务器的连接。在这些情况下,系统能否正确处理这些错误?是否已对信用卡进行收费?如果

    用户自己中断事务处理,在订单已保存而用户没有返回网站确认的时候,需要由客户代表致

    电用户进行订单确认。

    四、可用性测试

    可用性/易用性方面目前我们只能采用手工测试的方法进行评判,而且缺乏一个很好的评判基准进行,此一方面需要大家共同讨论。

    1、导航测试

       导航描述了用户在一个页面内操作的方式,在不同的用户接口控制之间,例如按钮、对话框、列表和窗口等;或在不同的连接页面之间。通过考虑下列问题,可以 决定一个Web应用系统是否易于导航:导航是否直观?Web系统的主要部分是否可通过主页存取?Web系统是否需要站点地图、搜索引擎或其他的导航帮助?

       在一个页面上放太多的信息往往起到与预期相反的效果。Web应用系统的用户趋向于目的驱动,很快地扫描一个Web应用系统,看是否有满足自己需要的信 息,如果没有,就会很快地离开。很少有用户愿意花时间去熟悉Web应用系统的结构,因此,Web应用系统导航帮助要尽可能地准确。

      导航的另一个重要方面是Web应用系统的页面结构、导航、菜单、连接的风格是否一致。确保用户凭直觉就知道Web应用系统里面是否还有内容,内容在什么地方。

    Web应用系统的层次一旦决定,就要着手测试用户导航功能,让最终用户参与这种测试,效果将更加明显。

    2、图形测试

      在Web应用系统中,适当的图片和动画既能起到广告宣传的作用,又能起到美化页面的功能。一个Web应用系统的图形可以包括图片、动画、边框、颜色、字体、背景、按钮等。图形测试的内容有:

      (1)要确保图形有明确的用途,图片或动画不要胡乱地堆在一起,以免浪费传输时间。Web应用系统的图片尺寸要尽量地小,并且要能清楚地说明某件事情,一般都链接到某个具体的页面。

      (2)验证所有页面字体的风格是否一致。

      (3)背景颜色应该与字体颜色和前景颜色相搭配。

      (4)图片的大小和质量也是一个很重要的因素,一般采用JPG或GIF压缩。

    3、内容测试

      内容测试用来检验Web应用系统提供信息的正确性、准确性和相关性。

    信 息的正确性是指信息是可靠的还是误传的。例如,在商品价格列表中,错误的价格可能引起财政问题甚至导致法律纠纷;信息的准确性是指是否有语法或拼写错误。 这种测试通常使用一些文字处理软件来进行,例如使用Microsoft Word的"拼音与语法检查"功能;信息的相关性是指是否在当前页面可以找到与当前浏览信息相关的信息列表或入口,也就是一般Web站点中的所谓"相关文 章列表"。

    4、整体界面测试

      整体界面是指整个Web应用系统的页面结构设计,是给用户的一个整体感。例如:当用户浏览Web应用系统时是否感到舒适,是否凭直觉就知道要找的信息在什么地方?整个Web应用系统的设计风格是否一致?

    对整体界面的测试过程,其实是一个对最终用户进行调查的过程。一般Web应用系统采取在主页上做一个调查问卷的形式,来得到最终用户的反馈信息。

      对所有的可用性测试来说,都需要有外部人员(与Web应用系统开发没有联系或联系很少的人员)的参与,最好是最终用户的参与。

    五、兼容性测试

    需要验证应用程序可以在用户使用的机器上运行。如果您用户是全球范围的,需要测试各种操作系统、浏览器、视频设置和 modem 速度。最后,还要尝试各种设置的组合。

    1、平台测试

      市场上有很多不同的操作系统类型,最常见的有Windows、Unix、Macintosh、Linux等。Web应用系统的最终用户究竟使用哪一种操作系统,取决于用户系统的配置。这样,就可能会发生兼容性问题,同一个应用可能在某些操作系统下能正常运行,但在另外的操作系统下可能会运行失败。

    因此,在Web系统发布之前,需要在各种操作系统下对Web系统进行兼容性测试。

    2、浏览器测试

       浏览器是Web客户端最核心的构件,来自不同厂商的浏览器对Java,、Javascrīpt、 ActiveX、 plug-ins或不同的HTML规格有不同的支持。例如,ActiveX是Microsoft的产品,是为Internet Explorer而设计的,Javascrīpt是Netscape的产品,Java是Sun的产品等等。另外,框架和层次结构风格在不同的浏览器中也有 不同的显示,甚至根本不显示。不同的浏览器对安全性和Java的设置也不一样。

    测试浏览器兼容性的一个方法是创建一个兼容性矩阵。在这个矩阵中,测试不同厂商、不同版本的浏览器对某些构件和设置的适应性。

    采用测试工具:

    通过白盒测试或者黑盒测试导出的测试用例,采用相应的工具进行测试,可以采用OpenSTA进行测试,此测试工具可以采用不同的浏览器进行测试。

    3.视频测试

    页面版式在 640x400、600x800 或 1024x768 的分辨率模式下是否显示正常? 字体是否太小以至于无法浏览? 或者是太大? 文本和图片是否对齐?

    4.Modem/连接速率测试
    是否有这种情况,用户使用 28.8 modem下载一个页面需要 10 分钟,但测试人员在测

    试的时候使用的是 T1 专线? 用户在下载文章或演示的时候,可能会等待比较长的时间,

    但却不会耐心等待首页的出现。最后,需要确认图片不会太大。

    5、打印机测试

    用 户可能会将网页打印下来。因此网页在设计的时候要考虑到打印问题,注意节约纸张和油墨。有不少用户喜欢阅读而不是盯着屏幕,因此需要验证网页打印是否正 常。有时在屏幕上显示的图片和文本的对齐方式可能与打印出来的东西不一样。测试人员至少需要验证订单确认页面打印是正常的。

    6、组合测试
    最后需要进行组合测试。600x800 的分辨率在 MAC 机上可能不错,但是在 IBM 兼容

    机上却很难看。在 IBM 机器上使用 Netscape 能正常显示,但却无法使用 Lynx 来浏览。

    如果是内部使用的 web 站点,测试可能会轻松一些。如果公司指定使用某个类型的浏览器,

    那么只需在该浏览器上进行测试。如果所有的人都使用 T1 专线,可能不需要测试下载施加。

    (但需要注意的是,可能会有员工从家里拨号进入系统) 有些内部应用程序,开发部门可能

    在系统需求中声明不支持某些系统而只支持一些那些已设置的系统。但是,理想的情况是,

    系统能在所有机器上运行,这样就不会限制将来的发展和变动。

    六、安全测试

    Web应用系统的安全性测试区域主要有:

    1、 目录设置
    Web 安全的第一步就是正确设置目录。每个目录下应该有 index.html 或 main.html 页

    面, 这样就不会显示该目录下的所有内容。如果没有执行这条规则。那么选中一幅图片,单击鼠标右键,找到该图片所在的路径"…com/objects /images"。然后在浏览器地址栏中手工输入该路径,发现该站点所有图片的列表。这可能没什么关系。但是进入下一级目录 "…com/objects" ,点击 jackpot。在该目录下有很多资料,其中有些都是已过期页面。如果该公司每个月都要更改产品价格信息,并且保存过期页面。那么只要翻看了一下这些记 录,就可以估计他们的边际利润以及他们为了争取一个合同还有多大的降价空间。如果某个客户在谈判之前查看了这些信息,他们在谈判桌上肯定处于上风。

    2.登录

      现在的Web应用系统基本采用先注册,后登陆的方式。因此,必须测试有效和无效的用户名和密码,要注意到是否大小写敏感,可以试多少次的限制,是否可以不登陆而直接浏览某个页面等。 

    3.Session

    Web应用系统是否有超时的限制,也就是说,用户登陆后在一定时间内(例如15分钟)没有点击任何页面,是否需要重新登陆才能正常使用。

    4.日志文件

    为了保证Web应用系统的安全性,日志文件是至关重要的。需要测试相关信息是否写进了日志文件、是否可追踪。

    5.加密

    当使用了安全套接字时,还要测试加密是否正确,检查信息的完整性。

    6.安全漏洞

    服务器端的脚本常常构成安全漏洞,这些漏洞又常常被黑客利用。所以,还要测试没有经过授权,就不能在服务器端放置和编辑脚本的问题。

    目前网络安全问题日益重要,特别对于有交互信息的网站及进行电子商务活动的网站尤其重要。目前我们的测试没有涵盖网站的安全性的测试,我们拟定采用工具来测定,

    工具如下
    SAINT------- Security Administrator’s Integrated Network Tool
    此工具能够测出网站系统的相应的安全问题,并且能够给出安全漏洞的解决方案,不过是一些较为常见的漏洞解决方案。

    七、代码合法性测试
    代码合法性测试主要包括2个部分:程序代码合法性检查与显示代码合法性检查。

    1、程序代码合法性检查
    程序代码合法性检查主要标准为《intergrp小组编程规范》,目前采用由SCM管理员进行规范的检查,未来期望能够有相应的工具进行测试。

    2、显示代码合法性检查
    显示代码的合法性检查,主要分为Html、Javascrīpt、Css代码检查,目前采用
    HTML代码检查------采用CSE HTML Validator进行测试
    Javascrīpt、Css也可以在网上下载相应的测试工具。

    八、 文档测试
    l、产品说明书属性检查清单
    1)完整.是否有遗漏和丢失,完全吗? 单独使用是否包含全部内容
    2)准确.既定解决方案正确吗? 目标明确吗? 有没有错误?
    3)精确、不含糊、清晰.描述是否一清二楚? 还是自说自话?容易看懂和理解吗?
    4)一致.产品功能能描述是否自相矛盾,与其他功能有没有冲突
    5)贴切.描述功能的陈述是否必要?有没有多余信息? 功能是否原来的客户要求?
    6)合理.在特定的预算和进度下,以现有人力,物力和资源能否实现?
    7)代码无关.是否坚持定义产品,而不是定义其所信赖的软件设计,架构和代码
    8)可测试性.特性能否测试? 测试员建立验证操作的测试程序是否提供足够的信息?
    2、 产品说明书用语检查清单
    1)说明。 对问题的描述通常表现为粉饰没有仔细考虑的功能----可归结于前文所述的属性.从产品说明书上找出这样的用语,仔细审视它们在文中是怎样使用的.产品说明书可能会为其掩饰和开脱,也可能含糊其词----无论是哪一种情况都可视为软件缺陷.
    2)总是,每一种,所有,没有,从不.如果看到此类绝对或肯定的,切实认定的叙述,软件测试员就可以着手设计针锋相对的案例.
    3)当然,因此,明显,显然,必然.这些话意图诱使接受假定情况.不要中了圈套.
    4)某些,有时,常常,通常,惯常,经常,大多,几乎.这些话太过模糊."有时"发生作用的功能无法测试.
    5)等等,诸如此类,依此类推.以这样的词结束的功能清单无法测试.功能清单要绝对或者解释明确,以免让人迷惑,不知如何推论.
    6)良好,迅速,廉价,高效,小,稳定.这些是不确定的说法,不可测试.如果在产品说明书中出现,就必须进一步指明含义.
    7)已处理,已拒绝,已忽略,已消除.这些廉洁可能会隐藏大量需要说明的功能.
    8)如果...那么...(没有否则).找出有"如果...那么..."而缺少配套的"否则"结构的陈述.想一想"如果"没有发生会怎样.

    相关的测试工具
    OpenSTA
    主要做性能测试的负荷及压力测试,使用比较方便,可以编写测试脚本,也可以先行自动生成测试脚本,而后对于应用测试脚本进行测试。
    SAINT
    网站安全性测试,能够对于指定网站进行安全性测试,并可以提供安全问题的解决方案。
    CSE HTML Validator
    一个有用的对于HTML代码进行合法性检查的工具
    Ab(Apache Bench)
    Apache自带的对于性能测试方面的工具,功能不是很多,但是非常实用。
    Crash-me
    Mysql自带的测试数据库性能的工具,能够测试多种数据库的性能。
  • 多浏览器兼容性问题及解决方案之Javascript篇

    2009-12-28 16:59:17

    CSS跟JavaScript开发中,最令大家头疼的问题就是浏览器兼容性了,虽然很多文章有这方面的文章,但依然让很多开发人员晕头转向,而且也不够全面。这篇文章,将全面收集css和javascript在各种浏览器下的兼容性报告,也期待各位不断补充。

    由于发觉内容收集越来越多,决定将CSS跟JavaScript分开。

    一、document.formName.item(”itemName”) 问题

    问题说明:IE下,可以使用 document.formName.item(”itemName”) 或 document.formName.elements ["elementName"];Firefox 下,只能使用document.formName.elements["elementName"]。
    解决方法:统一使用document.formName.elements["elementName"]。

    二、集合类对象问题

    问题说明:IE下,可以使用 () 或 [] 获取集合类对象;Firefox下,只能使用 [ ]获取集合类对象。
    解决方法:统一使用 [] 获取集合类对象。

    三、自定义属性问题

    问题说明:IE下,可以使用获取常规属性的方法来获取自定义属性,也可以使用 getAttribute() 获取自定义属性;Firefox下,只能使用 getAttribute() 获取自定义属性。
    解决方法:统一通过 getAttribute() 获取自定义属性。

    四、eval(”idName”)问题

    问题说明:IE下,可以使用 eval(”idName”) 或 getElementById(”idName”) 来取得 id 为 idName 的HTML对象;Firefox下,只能使用 getElementById(”idName”) 来取得 id 为 idName 的HTML对象。
    解决方法:统一用 getElementById(”idName”) 来取得 id 为 idName 的HTML对象。

    五、变量名与某HTML对象ID相同的问题

    问题说明:IE下,HTML对象的ID可以作为 document 的下属对象变量名直接使用,Firefox下则不能;Firefox下,可以使用与HTML对象ID相同的变量名,IE下则不能。
    解决方法:使用 document.getElementById(”idName”) 代替 document.idName。最好不要取HTML对象ID相同的变量名,以减少错误;在声明变量时,一律加上var关键字,以避免歧义。

    六、const问题

    问题说明:Firefox下,可以使用const关键字或var关键字来定义常量;IE下,只能使用var关键字来定义常量。
    解决方法:统一使用var关键字来定义常量。

    七、input.type属性问题

    问题说明:IE下 input.type 属性为只读;但是Firefox下 input.type 属性为读写。
    解决办法:不修改 input.type 属性。如果必须要修改,可以先隐藏原来的input,然后在同样的位置再插入一个新的input元素。

    八、window.event问题

    问题说明:window.event 只能在IE下运行,而不能在Firefox下运行,这是因为Firefox的event只能在事件发生的现场使用。
    解决方法:在事件发生的函数上加上event参数,在函数体内(假设形参为evt)使用 var myEvent = evt?evt:(window.event?window.event:null)
    示例:

    <input type="button" onclick="doSomething(event)"/>
    <script language="javascript">
    function doSomething(evt) {
    var myEvent = evt?evt:(window.event?window.event:null)
    ...
    }

    九、event.x与event.y问题

    问题说明:IE下,even对象有x、y属性,但是没有pageX、pageY属性;Firefox下,even对象有pageX、pageY属性,但是没有x、y属性。
    解决方法:var myX = event.x ? event.x : event.pageX; var myY = event.y ? event.y:event.pageY;
    如果考虑第8条问题,就改用myEvent代替event即可。

    十、event.srcElement问题

    问题说明:IE下,even对象有srcElement属性,但是没有target属性;Firefox下,even对象有target属性,但是没有srcElement属性。
    解决方法:使用srcObj = event.srcElement ? event.srcElement : event.target;
    如果考虑第8条问题,就改用myEvent代替event即可。

    十一、window.location.href问题

    问题说明:IE或者Firefox2.0.x下,可以使用window.location或window.location.href;Firefox1.5.x下,只能使用window.location。
    解决方法:使用 window.location 来代替 window.location.href。当然也可以考虑使用 location.replace()方法。

    十二、模态和非模态窗口问题

    问题说明:IE下,可以通过showModalDialog和showModelessDialog打开模态和非模态窗口;Firefox下则不能。
    解决方法:直接使用 window.open(pageURL,name,parameters) 方式打开新窗口。
    如果需要将子窗口中的参数传递回父窗口,可以在子窗口中使用window.opener来访问父窗口。如果需要父窗口控制子窗口的话,使用 var subWindow = window.open(pageURL,name,parameters); 来获得新开的窗口对象。

    十三、frame和iframe问题

    以下面的frame为例:

    (1)访问frame对象
    IE:使用window.frameId或者window.frameName来访问这个frame对象;
    Firefox:使用window.frameName来访问这个frame对象;
    解决方法:统一使用 window.document.getElementById(”frameId”) 来访问这个frame对象;
    (2)切换frame内容
    在IE和Firefox中都可以使用 window.document.getElementById(”frameId”).src = “webjx.com.html”或 window.frameName.location = “webjx.com.html”来切换frame的内容;
    如果需要将frame中的参数传回父窗口,可以在frame中使用parent关键字来访问父窗口。

    十四、body载入问题

    问题说明:Firefox的body对象在body标签没有被浏览器完全读入之前就存在;而IE的body对象则必须在body标签被浏览器完全读入之后才存在。
    [注] 这个问题尚未实际验证,待验证后再来修改。
    [注] 经验证,IE6、Opera9以及FireFox2中不存在上述问题,单纯的JS脚本可以访问在脚本之前已经载入的所有对象和元素,即使这个元素还没有载入完成。

    十五、事件委托方法

    问题说明:IE下,使用 document.body.onload = inject; 其中function inject()在这之前已被实现;在Firefox下,使用 document.body.onload = inject();
    解决方法:统一使用 document.body.onload=new Function(’inject()’); 或者 document.body.onload = function(){/* 这里是代码 */}
    [注意] Function和function的区别

    十六、访问的父元素的区别

    问题说明:在IE下,使用 obj.parentElement 或 obj.parentNode 访问obj的父结点;在firefox下,使用 obj.parentNode 访问obj的父结点。
    解决方法:因为firefox与IE都支持DOM,因此统一使用obj.parentNode 来访问obj的父结点。

    十七、innerText的问题.

    问题说明:innerText在IE中能正常工作,但是innerText在FireFox中却不行。
    解决方法:在非IE浏览器中使用textContent代替innerText。
    示例:

    if(navigator.appName.indexOf("Explorer") >-1){
    document.getElementById('element').innerText = "my text";
    } else{
    document.getElementById('element').textContent = ";my text";
    }

    [注] innerHTML 同时被ie、firefox等浏览器支持,其他的,如outerHTML等只被ie支持,最好不用。

    十八、Table操作问题

    问题说明:ie、firefox以及其它浏览器对于 table 标签的操作都各不相同,在ie中不允许对table和tr的innerHTML赋值,使用js增加一个tr时,使用appendChild方法也不管用。 document.appendChild在往表里插入行时FIREFOX支持,IE不支持
    解决办法:把行插入到TBODY中,不要直接插入到表
    解决方法:

    //向table追加一个空行:

    var row = otable.insertRow(-1);
    var cell = document.createElement("td");
    cell.innerHTML = "";
    cell.className = "XXXX";
    row.appendChild(cell);

    [注] 建议使用JS框架集来操作table,如JQuery。

    十九、对象宽高赋值问题

    问题说明:FireFox中类似 obj.style.height = imgObj.height 的语句无效。
    解决方法:统一使用 obj.style.height = imgObj.height + ‘px’;

    二十、setAttribute(’style’,'color:red;’)
    FIREFOX支持(除了IE,现在所有浏览器都支持),IE不支持
    解决办法:不用setAttribute(’style’,'color:red’)
    而用object.style.cssText = ‘color:red;’(这写法也有例外)
    最好的办法是上面种方法都用上,万无一失

    二一、类名设置
    setAttribute(’class’,’styleClass’)
    FIREFOX支持,IE不支持(指定属性名为class,IE不会设置元素的class属性,相反只使用setAttribute时IE自动识CLASSNAME属性)
    解决办法:
    setAttribute(’class’,’styleClass’)

    setAttribute(’className’,’styleClass’)

    或者直接 object.className=’styleClass’;

    IE和FF都支持object.className。

    二二、用setAttribute设置事件
    var bj = document.getElementById(’objId’);
    obj.setAttribute(’onclick’,'funcitonname();’);
    FIREFOX支持,IE不支持
    解决办法:
    IE中必须用点记法来引用所需的事件处理程序,并且要用赋予匿名函数
    如下:
    var bj = document.getElementById(’objId’);
    obj.onclick=function(){fucntionname();};
    这种方法所有浏览器都支持

    二三、建立单选钮
    IE以外的浏览器
    var rdo = document.createElement(’input’);
    rdo.setAttribute(’type’,'radio’);
    rdo.setAttribute(’name’,'radiobtn’);
    rdo.setAttribute(’value’,'checked’);

    IE:
    var rdo =document.createElement(”<input name=”radiobtn” type=”radio” value=”checked” />”);
    解决办法:
    这一点区别和前面的都不一样。这次完全不同,所以找不到共同的办法来解决,那么只有IF-ELSE了
    万幸的是,IE可以识别出document的uniqueID属性,别的浏览器都不可以识别出这一属性。问题解决。

  • 多浏览器兼容性问题及解决方案之CSS篇

    2009-12-28 16:57:32

    CSS跟JavaScript开发中,最令大家头疼的问题就是浏览器兼容性了,虽然很多文章有这方面的文章,但依然让很多开发人员晕头转向,而且也不够全面。这篇文章,将全面收集css在各种浏览器下的兼容性报告,以及浏览器的渲染bug,也期待各位不断补充。

    兼容性处理要点

    1、DOCTYPE 影响 CSS 处理

    2、FF: 设置 padding 后, div 会增加 height 和 width, 但 IE 不会, 故需要用 !important 多设一个 height 和 width

    3、FF: 支持 !important, IE 则忽略, 可用 !important 为 FF 特别设置样式

    4、div 的垂直居中问题: vertical-align:middle; 将行距增加到和整个DIV一样高 line-height:200px; 然后插入文字,就垂直居中了。缺点是要控制内容不要换行

    5、在mozilla firefox和IE中的BOX模型解释不一致导致相差2px解决方法:

    div{margin:30px!important;margin:28px;}

    注意这两个margin的顺序一定不能写反,!important这个属性IE不能识别,但别的浏览器可以识别。所以在IE下其实解释成这样:

    div{maring:30px;margin:28px}

    重复定义的话按照最后一个来执行,所以不可以只写margin:XXpx!important;

    浏览器差异

    1、ul和ol列表缩进问题

    消除ul、ol等列表的缩进时,样式应写成:list-style.:none;margin:0px;padding:0px;
    其中margin属性对IE有效,padding属性对FireFox有效。

    [注]经验证,在IE中,设置margin:0px可以去除列表的上下左右缩进、空白以及列表编号或圆点,设置padding对样式没有影响;在 Firefox 中,设置margin:0px仅仅可以去除上下的空白,设置padding:0px后仅仅可以去掉左右缩进,还必须设置list- style.:none才 能去除列表编号或圆点。也就是说,在IE中仅仅设置margin:0px即可达到最终效果,而在Firefox中必须同时设置margin:0px、 padding:0px以及list-style.:none三项才能达到最终效果。

    2、CSS透明问题

    IE:filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=60)。
    FF:opacity:0.6。
    [注] 最好两个都写,并将opacity属性放在下面。

    3、CSS圆角问题

    IE:ie7以下版本不支持圆角。
    FF: -moz-border-radius:4px,或者-moz-border-radius-topleft:4px;-moz- border- radius-topright:4px;-moz-border-radius-bottomleft:4px;-moz- border- radius- bottomright:4px;。
    [注] 圆角问题是CSS中的经典问题,建议使用JQuery框架集来设置圆角,让这些复杂的问题留给别人去想吧。不过jQuery的圆角只看到支持整个区域的圆角,没有支持边框的圆角,不过这个边框的圆角可以通过一些简单的手段来实现,下次有机会介绍下。

    4、cursor:hand  VS  cursor:pointer

    问题说明:firefox不支持hand,但ie支持pointer ,两者都是手形指示。
    解决方法:统一使用pointer。

    5、字体大小定义不同

    对字体大小small的定义不同,Firefox中为13px,而IE中为16px,差别挺大。

    解决方法:使用指定的字体大小如14px。

    并列排列的多个元素(图片或者链接)的div和div之间,代码中的空格和回车在firefox中都会被忽略,而IE中却默认显示为空格(约3px)。

    6、CSS双线凹凸边框
    IE:border:2px outset;。
    FF: -moz-border-top-colors: #d4d0c8 white;-moz-border-left-colors: #d4d0c8 white;-moz-border-right-colors:#404040 #808080;-moz-border-bottom-colors:#404040 #808080;

    浏览器bug

    1、IE的双边距bug

    设置为float的div在ie下设置的margin会加倍。这是一个ie6都存在的bug。

    解决方案:在这个div里面加上display:inline;

    例如:

    <#div id=”imfloat”>

    相应的css为

    以下为引用的内容:

    #IamFloat{
    float:left;
    margin:5px;/*IE下理解为10px*/
    display:inline;/*IE下再理解为5px*/
    }

    关于CSS中的问题实在太多了,甚至同样的CSS定义在不同的页面标准中的显示效果都是不一样的。一个合乎发展的建议是,页面采用标准XHTML标 准编写,较少使用table,CSS定义尽量依照标准DOM,同时兼顾IE、Firefox、Opera等主流浏览器。很多情况下,FF和 Opera的CSS解释标准更贴近CSS标准,也更具有规范性。

    2、IE选择符空格BUG
    转载自:http://www.lisijie.org/article/105/
    今天在给博客的段落样式设置首字符样式的时候发现,原来一个空格也可以使样式失效。

    请看以下代码:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="//www.w3.org/1999/xhtml">
    <head>
    <title></title>
    <style. type="text/css">
    <!--
    p{font-size:12px;}
    p:first-letter{font-size:300%}
    -->
    </style>
    </head>
    <body>
    <p>对于世界而言,你是一个人;但是对于某个人,你是他的整个世界。纵然伤心,也不要愁眉不展,因为你不知是谁会爱上你的笑容。</p>
    </body>
    </html>

    这段代码对<p>的首字符样式定义在IE6上看是没有效果的(IE7没测试),而在p:first-letter和{font- size:300%}加上空格,也就是p:first-letter {font-size:300%}后,显示就正常了。但是同样的代码,在FireFox下看是正常的。按道理说,p:first- letter{font-size:300%}的写法是没错的。那么问题出在哪里呢?答案是伪类中的连字符”-”。IE有个BUG,在处理伪类时,如果伪类的名称中带有连字符”-”,伪类名称后面就得跟一个空格,不然样式的定义就无效。而在FF中,加不加空格都可以正常处理

  • Tester weekly report

    2009-11-20 14:00:12

    QA Status Weekly-Report

     

    Team

    auto testing team

    Prepared By

     

    Report Period

    March 12 March 16

    Status

    Red

    q         Green – on schedule with no major issues

    q         Yellow – not on schedule or there are significant issues which manager can handle

    q         Red – not on schedule or missing major milestones.  Need steering assistance

    Summary

    Project status:

    1.       Planning HRMS

    2.       Evaluating TME auto testing framework

    Major Work:

    1. Planning HRMS

    2. Evaluating TME auto testing framework

    Issue:

    1. TestLink can not satisfy customer’s requirements

    Current Workload

    Names

    Project

    Workload

    Percentage

    Riddick.Liu

    HRMS

    Read HRMS test case, Make schedule

    N/A

    TME auto testing framework

    Evaluate TME auto testing framework and Research Testlink

    N/A

     

     

    N/A

     

    Next Week Plan

    Names

    Project

    Items

    Percentage

    Days

    Riddick.Liu

     

     

     

     

     

     

     

     

     

     

     

     

     

  • Checklist for having well-documented test cases

    2009-11-20 13:53:18

    Here is a checklist for having well-documented test cases:
    Quality Attributes

    - Accurate - tests what the description says it will test.
    - Economical - has only the steps needed for its purpose
    - Repeatable, self standing - same results no matter who tests it.
    - Appropriate - for both immediate and future testers
    - Traceable - to a requirement
    - Self cleaning - returns the test environment to clean state
    Structure and testability
    - Has a name and number
    - Has a stated purpose that includes what requirement is being tested
    - Has a description of the method of testing
    - Specifies setup information - environment, data, prerequisite tests, security access
    - Has actions and expected results
    - States if any proofs, such as reports or screen grabs, need to be saved
    - Leaves the testing environment clean
    - Uses active case language
    - Does not exceed 15 steps
    - Matrix does not take longer than 20 minutes to test
    - Automated script. is commented with purpose, inputs, expected results
    - Setup offers alternative to prerequisite tests, if possible
    - Is in correct business scenario order with other tests
    Configuration management
    - Employs naming and numbering conventions
    - Saved in specified formats, file types
    - Is versioned to match software under test
    - Includes test objects needed by the case, such as databases
    - Stored as read
    - Stored with controlled access
    - Stored where network backup operates
    - Archived off-site
  • What is the Unified Modeling Language?

    2008-06-18 12:03:48

    Unified Modeling Language

    From Wikipedia, the free encyclopedia

    Jump to: navigation, search

    In the field of software engineering, the Unified/Universal Modeling Language (UML) is a standardized visual specification language for object modeling. UML is a general-purpose modeling language that includes a graphical notation used to create an abstract model of a system, referred to as a UML model.

    Contents

    [hide]

    [edit] General descrīption

    UML is officially defined at the Object Management Group (OMG) by the UML metamodel, a Meta-Object Facility metamodel (MOF). Like other MOF-based specifications, UML has allowed software developers to concentrate more on design and architecture[citation needed].

    UML models may be automatically transformed to other representations (e.g. Java) by means of QVT-like transformation languages, supported by the OMG.

    UML is extensible, offering the following mechanisms for customization: profiles and stereotype. The semantics of extension by profiles have been improved with the UML 2.0 major revision.

    [edit] History

    After Rational Software Corporation hired James Rumbaugh from General Electric in 1994, the company became the source for the two most popular object-oriented modeling approaches of the day: Rumbaugh's OMT, which was better for object-oriented analysis (OOA), and Grady Booch's Booch method, which was better for object-oriented design (OOD). Together Rumbaugh and Booch attempted to reconcile their two approaches and started work on a Unified Method.

    They were soon assisted in their efforts by Ivar Jacobson, the creator of the OOSE method. Jacobson joined Rational in 1995, after his company, Objectory, was acquired by Rational. The three methodologists were collectively referred to as the Three Amigos, since they were well known to argue frequently with each other regarding methodological preferences.

    In 1996 Rational concluded that the abundance of modeling languages was slowing the adoption of object technology, so repositioning the work on a Unified Method, they tasked the Three Amigos with the development of a non-proprietary Unified Modeling Language. Representatives of competing Object Technology companies were consulted during OOPSLA '96, and were won over by Rumbaugh's a cappella rendition of his version of Joni Mitchell's "Clouds"[citation needed], indicating the victory of his OMT notation of using boxes for representing classes over Grady Booch's Booch method's notation that used cloud symbols.

    Under the technical leadership of the Three Amigos, an international consortium called the UML Partners was organized in 1996 to complete the Unified Modeling Language (UML) specification, and propose it as a response to the OMG RFP. The UML Partners' UML 1.0 specification draft was proposed to the OMG in January 1997. During the same month the UML Partners formed a Semantics Task Force, chaired by Cris Kobryn and administered by Ed Eykholt, to finalize the semantics of the specification and integrate it with other standardization efforts. The result of this work, UML 1.1, was submitted to the OMG in August 1997 and adopted by the OMG in November 1997[1].

    As a modeling notation, the influence of the OMT notation dominates (e. g., using rectangles for classes and objects). Though the Booch "cloud" notation was dropped, the Booch capability to specify lower-level design detail was embraced. The use case notation from Objectory and the component notation from Booch were integrated with the rest of the notation, but the semantic integration was relatively weak in UML 1.1, and was not really fixed until the UML 2.0 major revision.

    Concepts from many other OO methods were also loosely integrated with UML with the intent that UML would support all OO methods. For example CRC Cards (circa 1989 from Kent Beck and Ward Cunningham), and OORam were retained. Many others contributed too with their approaches flavoring the many models of the day including: Tony Wasserman and Peter Pircher with the "Object-Oriented Structured Design (OOSD)" notation (not a method), Ray Buhr's "Systems Design with Ada", Archie Bowen's use case and timing analysis, Paul Ward's data analysis and David Harel's "Statecharts", as the group tried to ensure broad coverage in the real-time systems domain. As a result, UML is useful in a variety of engineering problems, from single process, single user applications to concurrent, distributed systems, making UML rich but large.

    The Unified Modeling Language is an international standard:

    ISO/IEC 19501:2005 Information technology — Open Distributed Processing — Unified Modeling Language (UML) Version 1.4.2.

    UML has matured significantly since UML 1.1. Several minor revisions (UML 1.3, 1.4, and 1.5) fixed shortcomings and bugs with the first version of UML, followed by the UML 2.0 major revision that was adopted by the OMG in 2003. There are four parts to the UML 2.x specification: the Superstructure that defines the notation and semantics for diagrams and their model elements; the Infrastructure that defines the core metamodel on which the Superstructure is based; the Object Constraint Language (OCL) for defining rules for model elements; and the UML Diagram Interchange that defines how UML 2 diagram layouts are exchanged. The current versions of these standards follow: UML Superstructure version 2.1.2, UML Infrastructure version 2.1.2, OCL version 2.0, and UML Diagram Interchange version 1.0[2].

    Although many UML tools support some of the new features of UML 2.x, the OMG provides no test suite to objectively test compliance with its specifications.

    [edit] Methods

    UML is not a method by itself; however, it was designed to be compatible with the leading object-oriented software development methods of its time (for example OMT, Booch, Objectory). Since UML has evolved, some of these methods have been recast to take advantage of the new notation (for example OMT), and new methods have been created based on UML. The best known is Rational Unified Process (RUP). There are many other UML-based methods like Abstraction Method, Dynamic Systems Development Method, and others, designed to provide more specific solutions, or achieve different objectives.

    [edit] Modeling

    It is very important to distinguish between the UML model and the set of diagrams of a system. A diagram is a partial graphical representation of a system's model. The model also contains a "semantic backplane" — documentation such as written use cases that drive the model elements and diagrams.

    UML diagrams represent three different views of a system model:

    Functional requirements view

    Emphasizes the functional requirements of the system from the user's point of view.
    Includes use case diagrams.

    Static structural view

    Emphasizes the static structure of the system using objects, attributes, operations, and relationships.
    Includes class diagrams and composite structure diagrams.

    Dynamic behavīor view

    Emphasizes the dynamic behavīor of the system by showing collaborations among objects and changes to the internal states of objects.
    Includes sequence diagrams, activity diagrams and state machine diagrams.

    UML models can be exchanged among UML tools by using the XMI interchange format.

    [edit] Diagrams

    UML 2.0 has 13 types of diagrams that can be categorized hierarchically as shown in the following Class diagram:

    Structure diagrams emphasize what things must be in the system being modeled:

    behavīor diagrams emphasize what must happen in the system being modeled:

    Interaction diagrams, a subset of behavīor diagrams, emphasize the flow of control and data among the things in the system being modeled:

    The Protocol State Machine is a sub-variant of the State Machine. It may be used to model network communication protocols.

    UML does not restrict UML element types to a certain diagram type. In general, every UML element may appear on almost all types of diagrams. This flexibility has been partially restricted in UML 2.0.

    In keeping with the tradition of engineering drawings, a comment or note explaining usage, constraint, or intent is always allowed in a UML diagram.

    [edit] Concepts

    UML uses many concepts from many sources. For a definitive list, consult the glossary of Unified Modeling Language terms. Notable concepts are listed here.

    For structure

    Actor, attribute, class, component, interface, object, package.

    For behavīor

    Activity, event, message, method, operation, state, use case.

    For relationships

    Aggregation, association, composition, dependency, generalization (or inheritance).

    Other concepts

    [edit] Criticisms

    Although UML is a widely recognized and used modeling standard, it is frequently criticized for the following deficiencies:

    • Language bloat. UML is often criticized as being gratuitously large and complex[3]. It contains many diagrams and constructs that are redundant or infrequently used. This criticism is more frequently directed at UML 2.0 than UML 1.0, since newer revisions include more design-by-committee compromises[citation needed].
    • Problems in learning and adopting. The problems cited above can make learning and adopting UML problematic, especially when required of engineers lacking the prerequisite skills[4].
    • Only the code is in sync with the code. Another perspective holds that it is working systems that are important, not beautiful models. As Jack Reeves succinctly put it, "The code is the design"[5][6]. Pursuing this notion leads to the need for better ways of writing software; UML has value in approaches that compile the models to generate source or executable code. This however, may still not be sufficient since it is not clear that UML 2.0's Action Semantics exhibit Turing completeness. "All models are wrong, but some models are useful."
    • Cumulative Impedance/Impedance Mismatching. As with any notational system, UML is able to represent some systems more concisely or efficiently than others. Thus a developer gravitates toward solutions that reside at the intersection of the capabilities of UML and the implementation language. This problem is particularly pronounced if the implementation language does not adhere to orthodox object-oriented doctrine, as the intersection set between UML and implementation language may be that much smaller.
    • Aesthetically Inconsistent. This argument states that the adhoc mixing of abstract notation (2-D ovals, boxes, etc) make UML appear jarring and that more effort could have been made to construct uniform and aesthetically pleasing representations.
    • Tries to be all things to all programmers. UML is a general purpose modeling language that tries to achieve compatibility with every possible implementation language. In the context of a specific project, the most applicable features of UML must be delimited for use by the design team to accomplish the specific goal. Additionally, the means of restricting the scope of UML to a particular domain is through a formalism that is not completely formed, and is itself the subject of criticism.
    • Dysfunctional interchange format. While the XMI (XML Metadata Interchange) standard is designed to facilitate the interchange of UML models, it has been largely ineffective in the practical interchange of UML 2.x models. Defining a UML 2.x model in one tool and then importing it into another tool typically leads to loss of information.[citation needed] This interoperability ineffectiveness is attributable to two reasons: First, XMI 2.x is large and complex in its own right, since it purports to address a technical problem more ambitious than exchanging UML 2.x models. In particular, it attempts to provide a mechanism for facilitating the exchange of any arbitrary modeling language defined by the OMG's Meta-Object Facility (MOF). Secondly, the UML 2.x Diagram Interchange specification lacks sufficient detail to facilitate reliable interchange of UML 2.x notations between modeling tools. Since UML is a visual modeling language, this shortcoming is substantial for modelers who don't want to redraw their diagrams[7].

    Many modeling experts have written sharp criticisms of UML, including Bertrand Meyer's "UML: The Positive Spin"[3], and a paper presented by Brian Henderson-Sellers at the MoDELS/UML conference in Genova, Italy in October 2006[citation needed].

    [edit] See also

  • What is the object of peer review?

    2008-06-18 11:59:59

    1. Overview(概述)
            In a peer review, co-workers of a person who created a software work product examine that product to identify defects and correct shortcomings. A review:
            在同行评审中,由软件工作产品创建者的同行们检查该工作产品,识别产品的缺陷,改进产品的不足。评审:
            · verifies whether the work product correctly satisfies the specifications found in any predecessor work product, such as requirements or design documents
            · 检验工作产品是否正确的满足了以往的工作产品中建立的规范,如需求或设计文档
            · identifies any deviation from standards, including issues that may affect maintainability of the software
            · 识别工作产品相对于标准的偏差,包括可能影响软件可维护性的问题
            · suggests improvement opportunities to the author
            · 向创建者提出改进建议
            · promotes the exchange of techniques and education of the participants.
            · 促进参与者之间的技术交流和学习
            All interim and final development work products are candidates for review, including:
            所有中间和最终的开发工作产品都可以进行评审,包括:
            · requirements specifications
            · 需求规格说明书
            · user interface specifications and designs
            · 用户界面规范及设计
            · architecture, high-level design, and detailed designs and models
            · 架构,概要设计,详细设计及模型
            · source code
            · 源代码
            · test plans, designs, cases, and procedures
            · 测试计划,设计,用例及步骤
            · software development plans, including project management plan, configuration management plan, and quality assurance plan
            · 软件开发计划,包括项目管理计划,配置管理计划和质量保证计划
            This document defines an overall peer review process. It includes procedures for conducting inspections and two types of informal peer review, a walkthrough and a passaround, as well as guidance for selecting the appropriate approach for each review.
            该文档定义了一个全面的同行评审过程。包括了执行评审的步骤和两种非正式的同行评审,走查和轮查,以及对每个评审选择适当方法的指南。
  • 软件测试工程师的招聘体会

    2008-05-23 13:00:31

      首先说说要做个软件测试工程师,需要了解的方方面面,也可以说是一个职业要求汇总吧。

    基本常识类

      1.  计算机基础知识

      2.  计算机网络基础知识

      3.  软件测试基本知识(软件质量,软件质量管理基础知识,软件测试概念,软件测试标准,软件测试技术及方法,软件测试项目管理)

      4.  软件开发基本知识(软件工程知识,理解软件开发方法及过程)

    技术类

      1.  程序语言

      C/C++,VB,VC,Java,.net,ASP,javas cript等。具体要求要视公司的具体项目或产品来定。但一般以C为基本要求。

      2.  数据库知识

      SQL Server,Oracle,Mysql,Sybase等。一般对测试人员的要求就是要求会使用,然后熟练使用SQL语句进行查询,修改,添加,删除数据操作。

      3.  操作系统

      Windows,Linux(常用的RedHat,SUSE,Debian)/Unix(FreeBSD,Solaris,HP-UX,AIX,Mac)系统。

      自动化测试工具类

      1.  自动化测试概念/自动化测试框架

      好多人觉得自动化测试就是使用自动化测试工具,其实各种工具只是自动化测试实施的一个有效利器,如何建立一个脱离工具的自动化测试框架远远比研究如何使用测试工具复杂,困难的多。

    2.  自动化测试流程

    3.  自动化测试工具的使用

      自动化测试框架(流程)

      GUI的功能测试自动化

      非GUI的功能测试自动化

      性能测试(广义的和狭义的性能测试)

      自动化测试工具(功能测试工具,性能测试工具,缺陷管理工具,测试管理工具)

      (HP)Mercury Interactive QuickTest Pro,WinRunnerLoadRunner,Quality Center(Test Director),SiteScope

      Compuware QACenter(TestPartner QARun QALoad QADirector TrackRecord),DevPartner studio

      (IBM)Rational TestSuite(Robot TestManager FunctionalTester PerformeranceTester ClearQuest ClearCase ...)

      (Borland)Segue SilkTest SilkPerformer SCTestManager

      其它:JUnit,NUnit,Auto It,Test Architect,OpenSTA等

    实战类(工作经验)

      1.  公司的测试流程

      2.  公司的具体缺陷管理流程(提交bug报告,追踪bug状态)

      3.  测试环境的搭建及管理

      4.  测试计划,测试用例,测试报告等相关文档的编写

    语言类

      1.  英语

      2.  日语

      3.  。。。

    性格类

      通过30分钟至1个小时的面试,试着了解面试者的性格是否适合软件测试的工作。

      1.  细心,关注细节

      2.  耐心,不怕麻烦

      3.  良好的沟通能力

      4.  优秀的学习能力,逻辑思维强

      5.  工作积极主动

      6.  上进性强,永远不满足现状


  • 软件测试工程师面试英语

    2008-05-23 12:59:21

    1. What types of documents would you need for QA, QC, and Testing?
    2. What did you include in a test plan?
    3. Describe any bug you remember.
    4. What is the purpose of the testing?
    5. What do you like (not like) in this job?
    6. What is quality assurance?
    7. What is the difference between QA and testing?
    8. How do you scope, organize, and execute a test project?
    9. What is the role of QA in a development project?
    10. What is the role of QA in a company that produces software?
    11. Define quality for me as you understand it
    12. Describe to me the difference between validation and verification.
    13. Describe to me what you see as a process. Not a particular process, just the basics of having a process.
    14. Describe to me when you would consider employing a failure mode and effect analysis.
    15. Describe to me the Software Development Life Cycle as you would define it.
    16. What are the properties of a good requirement?
    17. How do you differentiate the roles of Quality Assurance Manager and Project Manager?
    18. Tell me about any quality efforts you have overseen or implemented. Describe some of the challenges you faced and how you overcame them.
    19. How do you deal with environments that are hostile to quality change efforts?
    20. In general, how do you see automation fitting into the overall process of testing?
    21. How do you promote the concept of phase containment and defect prevention?
    22. If you come onboard, give me a general idea of what your first overall tasks will be as far as starting a quality effort.
    23. What kinds of testing have you done?
    24. Have you ever created a test plan?
    25. Have you ever written test cases or did you just execute those written by others?
    26. What did your base your test cases?
    27. How do you determine what to test?
    28. How do you decide when you have ‘tested enough?’
    29. How do you test if you have minimal or no documentation about the product?
    30. Describe me to the basic elements you put in a defect report?
    31. How do you perform regression testing?
    32. At what stage of the life cycle does testing begin in your opinion?
    33. How do you analyze your test results? What metrics do you try to provide?
    34. Realising you won’t be able to test everything - how do you decide what to test first?
    35. Where do you get your expected results?
    36. If automating - what is your process for determining what to automate and in what order?
    37. In the past, I have been asked to verbally start mapping out a test plan for a common situation, such as an ATM. The interviewer might say, “Just thinking out loud, if you were tasked to test an ATM, what items might you test plan include?” These type questions are not meant to be answered conclusively, but it is a good way for the interviewer to see how you approach the task.
    38. If you’re given a program that will average student grades, what kinds of inputs would you use?
    39. Tell me about the best bug you ever found.
    40. What made you pick testing over another career?
    41. What is the exact difference between Integration & System testing, give me examples with your project.
    42. How did you go about testing a project?
    43. When should testing start in a project? Why?
    44. How do you go about testing a web application?
    45. Difference between Black & White box testing
    46. What is Configuration management? Tools used?
    47. What do you plan to become after say 2-5yrs (Ex: QA Manager, Why?)
    48. Would you like to work in a team or alone, why?
    49. Give me 5 strong & weak points of yours
    50. Why do you want to join our company?
    51. When should testing be stopped?
    52. What sort of things would you put down in a bug report?
    53. Who in the company is responsible for Quality?
    54. Who defines quality?
    55. What is an equivalence class?
    56. Is a “A fast database retrieval rate” a testable requirement?
    57. Should we test every possible combination/scenario for a program?
    58. What criteria do you use when determining when to automate a test or leave it manual?
    59. When do you start developing your automation tests?
    60. Discuss what test metrics you feel are important to publish an organization?
    61. In case anybody cares, here are the questions that I will be asking:
    62. Describe the role that QA plays in the software lifecycle.
    63. What should Development require of QA?
    64. What should QA require of Development?
    65. How would you define a “bug?”
    66. Give me an example of the best and worst experiences you’ve had with QA.
    67. How does unit testing play a role in the development/software lifecycle?
    68. Explain some techniques for developing software components with respect to testability.
    69. Describe a past experience with implementing a test harness in the development of software.
    70. Have you ever worked with QA in developing test tools? Explain the participation Development should have with QA in leveraging such test tools for QA use.
    71. Give me some examples of how you have participated in Integration Testing.
    72. How would you describe the involvement you have had with the bug-fix cycle between Development and QA?
    73. What is unit testing?
    74. Describe your personal software development process.
    75. How do you know when your code has met specifications?
    76. How do you know your code has met specifications when there are no specifications?
    77. Describe your experiences with code analyzers.
    78. How do you feel about cyclomatic complexity?
    79. Who should test your code?
    80. How do you survive chaos?
    81. What processes/methodologies are you familiar with?
    82. What type of documents would you need for QA/QC/Testing?
    83. How can you use technology to solve problem?
    84. What type of metrics would you use?
    85. How to find that tools work well with your existing system?
    86. What automated tools are you familiar with?
    87. How well you work with a team?
    88. How would you ensure 100% coverage of testing?
    89. How would you build a test team?
    90. What problem you have right now or in the past? How you solved it?
    91. What will you do during the first day of job?
    92. What would you like to do five years from now?
    93. Tell me about the worst boss you’ve ever had.
    94. What are your greatest weaknesses?
    95. What are your strengths?
    96. What is a successful product?
    97. What do you like about Windows?
    98. What is good code?
    99. Who is Kent Beck, Dr Grace Hopper, Dennis Ritchie?
    100. What are basic, core, practises for a QA specialist?
    101. What do you like about QA?
    102. What has not worked well in your previous QA experience and what would you change?
    103. How you will begin to improve the QA process?
    104. What is the difference between QA and QC?
    105. What is UML and how to use it for testing?
    106. What is CMM and CMMI? What is the difference?
    107. What do you like about computers?
    108. Do you have a favourite QA book? More than one? Which ones? And why.
    109. What is the responsibility of programmers vs QA?
    110. What are the properties of a good requirement?
    111. Ho to do test if we have minimal or no documentation about the product?
    112. What are all the basic elements in a defect report?
  • Software Testing Principles

    2008-05-23 10:39:09


    1 A necessary part of a test case is a definition of the
    expected output or result.

    a test case must consist
    of two components:
    1. A descrīption of the input data to the program.
    2. A precise descrīption of the correct output of the program
    for that set of input data.
    2 A programmer should avoid attempting to test his or her
    own program.
    3 A programming organization should not test its own
    programs.
    4 Thoroughly inspect the results of each test.
    5 Test cases must be written for input conditions that are
    invalid and unexpected, as well as for those that are valid
    and expected.
    6 Examining a program to see if it does not do what it is
    supposed to do is only half the battle; the other half is
    seeing whether the program does what it is not supposed
    to do.
    7 Avoid throwaway test cases unless the program is truly a
    throwaway program.
    8 Do not plan a testing effort under the tacit assumption
    that no errors will be found.
    9 The probability of the existence of more errors in a
    section of a program is proportional to the number of
    errors already found in that section.
    10 Testing is an extremely creative and intellectually
    challenging task.

  • 如何管理不太听话,又比较有个性的测试工程师

    2007-09-09 10:08:18

    一般情况下,每个公司或者测试组都可能会有比较有个性的测试工程师,往往这样的员工都是技术还算可以,至少在某些方面还是做的不错的,只是缺少了做测试人员应该有的一些素质,但是他们往往容易有自认为自己的经验很多,而且觉得会了一两门自动化测试脚本的编写,就常常会觉得在这个团队是委屈了自己,所以对主管的管理都是嗤之以鼻,甚至有的人会把主管的话当作耳旁风,在项目特别紧的时候也不加班,有一种傲气凌人,大不了走人的气势,有时候这种人也还不至于消极怠工的程度,分给他的任务还是能在规定时间内完成,但是绝对不会自己再去延伸更多的,对工作并不是特别的认真负责,做事有时候总是会留下尾巴,让开发人员来踩。
    当然很多管理者对这种人基本上比较难容忍,并不是技术,而是态度问题,那么大家一般都如何处理这样的问题呢?
     
    我通过自己的经验,大概总结出几点:
    1. 多多沟通,循循善诱
       沟通很重要,平时多与这样的员工聊一些技术之外的一些经验和教训,让他了解,做测试并不仅仅是做技术,需要学会沟通,发散思维等等一些技术之外的技能,同时也可以聊一些除了工作以外的其他一些事情,让员工感觉到你们之间不仅仅是主管与组员的关系,人非草木,孰能无情,多和你的组员一起吃工作餐,其实就是一个很好的沟通机会。
     
    2. 责任制分工
       如果你对这样的员工还算是新人,不妨先尝试把一些任务彻底的交给他,同时也应该在自己所能掌控的范围之内,再分给他1-2个组员由他支配,最后只向他要结果,这样可以提高他的责任心,也会让他觉得自己有成就感。
     
    3. 给有创造力的任务
       可以找一些比较有挑战或者创造力的工作,这样可以避免他对测试任务的厌烦情绪,比如一些有开发性质的工作,或者针对他的兴趣点,分给他愿意做的工作过,这样他的工作效率会跟高,也不会觉得在这个项目里做的无聊
     
    4. 让他与经验和能力比他更高的人一起工作
       还有就是把他与经验更多,技术能力比他还高的人一起工作,让他觉得自己其实还是有很多方面不足的,同时也能给他一种压力,同时也可以防止这种员工会把自己掌握了某些方面的工作,而不听从任务的安排和主管的管理,还可以防止他突然离职而给项目带来不必要的损失。
      
     
    以上只是我个人想到的或者曾经用过的一些方法,管理无止境,我对这方面还需要努力提高,欢迎大家提出您的宝贵意见,也希望大家能有更好的管理方法分享出来。
  • 让linux系统支持ASP

    2007-05-15 16:36:53

    自从Micorsoft推出ASP技术后,由于ASP在创建动态交互式站点上的强大功能及其代码编写的简便性,使ASP在越来越多的Internet/Intranet/Extranet网站上得到了极其广泛的应用,尤其是涉及到数据库操作的网站应用系统更是倾向于采用ASP技术。但由于众所周知的原因,ASP只能工作于Microsoft的Windows NT平台+IIS Web Server服务器软件,在Windows9X+PWS也能使用,但那只能是调试或者学习用的,因而就决定了ASP应用的局限性。

    据有关资料显示,采用Windows操作系统平台和服务器软件的网站在15%左右,也就是说有将近85%的网站将不能采用ASP技术。大多数商用的网站采用的是Unix、Linux、Soris和Netware等操作系统及相应的服务器,这说明ASP技术在应用上确实有很大的限制。

    难道ASP就不能运用于非Windows 平台吗?当然不是.目前为止我们至少有两种选择,Chilisoft4公司的chili ASP和Halcycon公司的iASP(Instant ASP).Halcyonsoft公司提出“ASP Anytime,Anywhere”的口号,开发出iASP,使ASP不仅可以在采用Windows操作系统平台和服务器软件的网站上使用,还可以在采用其它操作系统如Unix、Linux、Soris、Netware操作系统及相应服务器的网站上使用。

    iASP全面继承了ASP的优势,并与ASP完全兼容,因而ASP应用系统几乎可以直接移植到非Windows操作系统平台下的iASP环境中运行,使得ASP应用系统真正成为了一种跨平台的 Internet、Intranet或Extranet应用系统。

    iASP与ASP相比,不仅在支持操作系统平台上具有优势,在使用第三方组件构建ASP应用系统上同样具有明显的优势。iASP不仅支持流行的 ActiveX组件,同样支持流行的Enterprise JavaBeans组件和CORBA兼容组件,从而使用ASP应用系统功能更为强大,应用更为广泛。除了MS Visual系列开发工具和Borland系列开发工具外,还可以用Java系列开发工具,让组件开发人员有更多的选择从而可以更为得心应手地开发有关组件。

    iASP有两种版本,一种适用于Windows操作系统平台和服务器软件,另一种适用于Unix、Linux、Soris、Netware操作系统及相应服务器软件。目前最新的版本为1.0.9,最近刚推出一个Linux上的FREE版,可以在 http://www.halcycon.com站点上免费下载,其功能与正式版本相比基本相同,想在网络特别Unix、Linux局域网络中使用ASP的网络开发人员不妨去下载一个试用一下,文件大小有9M多。

    一、iASP软件环境要求

    iASP软件完全是用Java程序语言编制而成的,需要JDK1.1.X或以上版本的支持,因而需要系统上预先安装JDK1.1.X或以上版本。 Linux平台下的JDK11.X可以在 http://xfer.nitric.com/pub/java-linux/ 下载,基于Windows9X/NT平台的JDK1.1.X的下载地址为 ftp://202.103.111.173/Download/DEVE...1-win32-x86.exe 。同时需要相应的Web Server软件,如IIS、Apache、Netscape、Xitami、Sambar等。

    二、iASP安装程序支持的系统平台和服务器软件

    iASP软件是用JAVA程序语言编制而成的,原则上可运行在所有JAVA平台上。iASP可自动配置服务器软件,使之能使用iASP解释和转换 ASP页面;iASP可以使用Halcycon软件公司开发的iASP Servlet接口与服务器进行连接和通信,也可以使用其它Servlet接口与服务器进行连接和通信。iASP支持以下平台及Web Server:

    (一) Sun Solaris Sparc系统平台

    1、Apache服务器软件

    iASP可对Apache服务器软件的1.3.0、1.3.9、1.3.11、1.3.12等九个常用版本进行自动配置使之使用iASP解释ASP页面;并通过iASP中的Servlet接口与之连接和通信。

    2、Netscape Fast Track(FT)和Enterprise Server(EP)服务器软件

    iASP可对FT3.0.X、EP3.5.X、EP3.6.X进行自动配置使之使用iASP解释ASP页面;并通过iASP中的Servlet接口与之连接和通信。

    3、Sun Web Server2.1服务器软件

    iASP可对Sun Web Server2.1服务器软件进行自动配置使之使用iASP解释ASP页面;并通过服务器软件的Servlet接口与之连接和通信。

    4、Zeus服务器软件

    iASP可对Zeus服务器软件进行自动配置使之使用iASP解释引擎解释ASP页面;并通过Zeus和Apache JServ Servlet接口与之连接和通信。
  • 如何fedora5 下安装Apache-2.2.4+php-5.2.1+GD+mysql 5.0.27

    2007-05-15 16:34:29

    我在用fedora5时,想用这些程序的时候,在fedora 5 下,这些程序放在太多文件夹下,对一名对fedora 5不熟的人很是麻烦。所以决定把这些程序删了重装。
    我之所以写这些文字,因为我在google 搜了太多不能实现的教程,希望这篇文章对初学者有点帮助。

    主要软件包:

    mysql-standard-5.0.27-linux-i686-glibc23.tar.gz
    url:http://dev.mysql.com/downloads/mysql/5.0.html#downloads
    下找个镜像

    php-5.2.1.tar.gz
    url
    http://www.php.net/downloads.php  
    用第2个,第一个包好像少东西,我就是第一个不成功,所以才用第2个包,
    这个包一定要选好,安装时候大部分问题都出在这个包

    httpd-2.2.4.tar.gz
    url
    http://www.apache.org/dyn/closer.cgi 选个镜像

    PS:
    源程序尽量到官方网站下,国内站点编辑好多不负责任,源程序少东西

    安装php所需的软件包
    (其中libxml2是安装php5必须的)
    libxml2-2.6.26.tar.gz
    libxslt-1.1.17.tar.gz
    curl-7.16.1.tar.gz
    以上安装包在安装FC5的时候都安装了 没有安装的 请下载后安装

    GD
    库所需要软件包
    (有人说PHP源码包里自带了GD2.0.28zlib
    只要安装GD的三个支持包:jpg,pngfreetype,但是我们还是下载)
    gd-2.0.34.tar.gz
    freetype-2.3.1.tar.gz
    jpegsrc.v6b.tar.gz
    libpng-1.2.16.tar.gz
    zlib-1.2.3.tar.gz

    PS:
    这些源程序只要你在www.google.com 里搜 名称+download(例如:libxml2-2.6.26.tar.gz ,就输入:libxml download,1页就可以找到官方网站)

    卸载:
    我们需要把原来系统自带的或者后来采用rpm方式安装的Apache | mysql | php软件卸载掉,我听说不卸载rpm也是可以的,不会影响源码包或者二进制包的安装,就是将来你不起动那些进程就没问题了,但我还是建议卸载,因为 rpm方式安装的软件把各种文件放在很多奇怪的地方,我感觉是非常不好管理的。

    下面的卸载范例是Fedora core2默认安装的包。

    卸载Mysql
    [root@yourdomainname/]# rpm -qa | grep mysql
    mysql-3.23.58-9
    php-mysql-4.3.4-11
    mod_auth_mysql-20030510-4.1
    mysql-server-3.23.58-9

     
    说明:rpm qa | grep mysql 命令是为了把mysql相关的包都列出来,我上面的例子是Fedora core2默认安装mysqlrpm软件包列表,如果是别的Linux版本列出来的列表有可能会不一样,不过不用担心,不管是什么,卸载都从最下面的一个包开始,直到卸载掉第一个为止。

     
    比如:在这个例子中,我们应该先卸载mysql-server-3.23.58-9 方法如下:
    rpm –e mysql-server

     
    说明:rpm e 是卸载rpm包的命令,后面是包名称,最后的版本号是不用打的,比如我们下一步卸载mod_auth_mysql-20030510-4.1包,方法如下:

    rpm –e mod_auth_mysql

    卸载Apache
    [root@ yourdomainname /]# rpm -qa | grep httpd
    httpd-2.0.49-4
    system-config-httpd-1.2.0-3
    httpd-manual-2.0.49-4
    说明:方法跟卸载Mysql一样,不用说了吧

    卸载PHP
    [root@ yourdomainname /]# rpm -qa | grep php
    php-odbc-4.3.4-11
    php-4.3.4-11
    php-mysql-4.3.4-11
    php-pear-4.3.4-11
    php-ldap-4.3.4-11
    php-pgsql-4.3.4-11

     
    说明:方法跟卸载Mysql一样,不用说了吧

    ⑶伊谐鲆览档陌拿疲刃对靥崾疽览档陌涂梢粤恕?

     
    如果实在实在有卸载不掉的包,可以加—nodeps这个参数来卸载,比如我们卸载php-4.3.4-11,实在卸不掉了。就用:
    [root@ yourdomainname /]# rpm -e php-4.3.4-11
    nodeps 命令很强硬,应该行的。卸载这段话是抄网上的,我在fedora5 上照葫芦划瓢,还可以,你不要担心会不会把不该删的删掉了,因为即使你删了不该删的,你用上时,可以到网上找相应模块,加到相应的位置就行了,linux下没有注册表这一说,不像windows

    安装:  
    假定你压缩的源代码放在:/software
    # mkdir -p /software
    进入 /software目录
    # cd /software
    解压httpd-2.2.4.tar.gz
    # tar -zvxf httpd-2.2.4.tar.gz
    进入httpd-2.2.4目录
    # cd httpd-2.2.4
    配置APACHE安装文件
    # ./configure --prefix=/usr/local/apache2 / (apache
    安装目录)
    --with-mpm=worker /(
    这里我使用的多线程多进程的多路处理模块)  
    --enable-mods-shared=all / (
    使所有模块都编译成DSO)
    --enable-rewrite /(rewrite
    模块)
    --enable-proxy /(proxy
    模块)
    --enable-proxy_http /(proxy_http
    模块)
    --enable-ssl /(SSL
    模块)
    --with-perl(
    支持PERL)

    *
    这里使用"/"是命令行转行 方便查看及修改

    编译
    #make;make install

    一般安装APACHE不会有什么问题出现

    2.
    安装MYSQL
    # cd /software
    # tar -zvxf mysql-standard-5.0.27-linux-i686-glibc23.tar.gz
    # mv mysql-standard-5.0.27-linux-i686-glibc23 /usr/local/mysql
    # cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
    #cd /usr/local/mysql

    添加mysql用户及用户组
    # groupadd mysql
    # useradd -g mysql mysql

    生成mysql系统数据库
    # /usr/local/mysql/scrīpts/mysql_install_db --user=mysql&

    修改mysql目录权限
    # chown -R root /usr/local/mysql
    # chgrp -R mysql /usr/local/mysql
    # chown -R mysql /usr/local/mysql/data

    启动mysql服务
    # /usr/local/mysql/bin/mysqld_safe --user=mysql&
    如果没出现错,代表正常启动mysql服务了, Ctrl + C 跳出

    3.
    安装GD
    a.
    安装 jpeg6
    建立目录:
    # mkdir -p /usr/local/module/jpeg6
    # mkdir -p /usr/local/module/jpeg6/bin
    # mkdir -p /usr/local/module/jpeg6/lib
    # mkdir -p /usr/local/module/jpeg6/include
    # mkdir -p /usr/local/module/jpeg6/man
    # mkdir -p /usr/local/module/jpeg6/man1
    # mkdir -p /usr/local/module/jpeg6/man/man1

    # cd /software
    # tar -zvxf jpegsrc.v6b.tar.gz
    # cd jpeg-6b
    # ./configure --prefix=/usr/local/module/jpeg6 --enable-shared --enable-static
    # make; make install

    * jpeg6
    安装文件中没有写创建目录的命令

    b.
    安装libpng


    安装步骤如下
    # cd /software
    # tar -zvxf libpng-1.2.16.tar.gz
    # cd libpng-1.2.16
    # cp scrīpts/makefile.std makefile
    # make; make install


    c.
    安装 freetype
    # cd /software
    # tar -zvxf freetype-2.3.1.tar.gz
    # cd freetype-2.3.1
    # ./configure --prefix=/usr/local/module/freetype
    # make;make install

    d.:
    安装zlib
    这个一般不用安装
    # cd /software
    #tar -zxvf zlib-1.2.3.tar.gz
    #cd zlib.1.2.3
    # .
    /configure
    # make;make install

    e.
    安装Curl
    这个一般不用安装
    # cd /software
    # tar -zvxf curl-7.16.1.tar.gz
    # mkdir -p /usr/local/curl
    # ./configure --prefix=/usr/local/curl
    # make; make install

    f.
    安装GD

    # cd /software
    # tar -zvxf gd-2.0.34.tar.gz
    # mkdir -p /usr/local/module/gd
    # cd gd-2.0.33
    # ./configure --prefix=/usr/local/module/gd /
    > --with-png /
    > --with-jpeg-dir=/usr/local/module/jpeg6 /
    > --with-freetype=/usr/local/module/freetype /
    > --with-zlib
    # make; make install

    4.
    安装php5php5必须有libxml2支持!编译通不过大部分是由于这个模块


    a.
    安装libxml2
    # cd /software # tar -zxf libxml2-2.6.26.tar.gz
    # cd libxml2-2.6.26
    # mkdir -p /usr/local/module/libxml2
    # ./configure --prefix=/usr/local/module/libxml2
    # make; make install

    b.
    安装 libxslt(可选安装,你可以不安装)
    # cd /software
    # tar -zxf libxslt-1.1.15.tar.gz
    # mkdir -p /usr/local/module/libxslt
    # cd libxslt-1.1.17
    # ./configure --prefix=/usr/local/module/libxslt --with-libxml-prefix=/usr/local/module/libxml2
    # make; make install

    c.
    安装php5
    # cd /software
    # tar -zvxf php-5.2.1.tar.gz
    # mkdir -p /usr/local/php
    # cd php-5.2.1
    # ./configure --prefix=/usr/local/php /
    --with-apxs2=/usr/local/apache2/bin/apxs /
    --with-mysql=/usr/local/mysql /
    --with-xml /
    --with-png /
    --with-jpeg-dir=/usr/local/module/jpeg6 /
    --with-zlib /
    --with-freetype-dir=/usr/local/module/freetype /
    --with-gd=/usr/local/module/gd /
    --with-curl /
    --enable-track-vars /
    --disable-debug /
    --enable-url-includes /
    --enable-sockets /
    --enable-force-cgi-redirect /
    --enable-calendar /
    --with-config-file-path=/etc /
    --enable-magic-quotes /
    --enable-ftp /
    --enable-gd-native-ttf /
    --with-ttf /
    --with-gdbm /
    --with-gettext /
    --with-iconv /
    --enable-mbstring=all /
    --enable-memory-limit /
    --with-libxml-dir=/usr/local/module/libxml2 /
    --with-xsl=/usr/local/module/libxslt /
    --enable-xslt

    # make
    # make install
    # cp php.ini-dist /usr/local/php/lib/php.ini
    (别忘记了呵呵)

    如果通不过,运行下面2
    # cp php.ini-dist /usr/local/lib/php.ini
    # cp php.ini-dist /etc/php.ini




    其中./configure 后的
    --prefix=/usr/local/php
    --with-apxs2=/usr/local/apache2/bin/apxs
    --with-mysql=/usr/local/mysql
    --with-xml
    是必要的选项

    --with-png /
    --with-jpeg-dir=/usr/local/module/jpeg6 /
    --with-gd=/usr/local/modules/gd /
    --with-zlib /
    --with-freetype-dir=/usr/local/module/freetype /
    这是让PHP支持GD库的配置选项

    后面都是一些 要使用的PHP 函数库 可以根据自己的喜好 删除或增加


    重新配置apache2让他支持php?

    ?

    配置 httpd.conf apache支持PHP
    # vi /usr/local/apache2/conf/httpd.conf
    找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    重启apache
    # /usr/local/apache2/bin/apachectl restart
    查看(908) 评论(0) 收藏 分享 管理

  • 用户菜单

    我的栏目

    我的存档

    数据统计

    RSS订阅

    Open Toolbar