发布新日志

  • 我的学习方法

    2012-11-08 13:09:06

    目的

    目的就是这个技术完成什么功能,解决哪类问题。拿JSON举个例子:

    http://www.json.org/ 写道
    JSON (JavaScript. Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript. Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.



    JSON(JavaScript. Object Notation) 是一种轻量级的数据交换格式。易于人阅读和编写,同时也易于机器解析和生成。它基于JavaScript(Standard ECMA-262 3rd Edition - December 1999)的一个子集。 JSON采用完全独立于语言的文本格式,但是也使用了类似于C语言家族的习惯(包括C, C++, C#, Java, JavaScript, Perl, Python等)。这些特性使JSON成为理想的数据交换语言。

     

    从定义我们可以总结出几个关键点:

       轻量级

       数据交换格式

       易于编写和阅读

       基于JavaScript的一个子集

       纯文本独立于语言和平台

    重点是它以纯文本存储,可以独立于任何语言和平台,且主要用于数据交换。

     

    再比如Spring:

     http://www.oschina.net/p/spring/写道
    Spring Framework 是一个开源的Java/Java EE全功能栈(full-stack)的应用程序框架,以Apache许可证形式发布,也有.NET平台上的移植版本。该框架基于 Expert One-on-One Java EE Design and Development(ISBN 0-7645-4385-7)一书中的代码,最初由 Rod Johnson 和 Juergen Hoeller等开发。Spring Framework 提供了一个简易的开发方式,这种开发方式,将避免那些可能致使底层代码变得繁杂混乱的大量的属性文件和帮助类。
    Spring 中包含的关键特性:
    ……请前往http://www.oschina.net/p/spring/浏览

        Spring Framework官网 http://www.springsource.org/spring-framework

     

    从定义我们可以总结几个关键点:

    Java/JavaEE一站式解决方案(即不管是开发普通Java应用还是JavaEE企业应用都能提供解决方案)    

    框架基于 Expert One-on-One Java EE Design and Development(告诉我们需要去读这本书 这本书介绍了Spring设计思想)

    IoC容器(此时我们需要问什么是IoC容器)

    数据库事务的一般化抽象层(此时需要问自己怎么个一般化抽象)

    JDBC 抽象层(怎么个抽象法,比普通JDBC调用有哪些好处)

    等等……

     

    再比如Jsoup:

    http://jsoup.org/ 写道
    jsoup 是一款 Java 的HTML 解析器,可直接解析某个URL地址、HTML文本内容。它提供了一套非常省力的API,可通过DOM,CSS以及类似于JQuery的操作方法来取出和操作数据。

     从定义上可以总结几个关键点:

       Java版的HTML解析器

       提供了类似于DOM、CSS及类似于Jquery的操作方法来取出和操作数据(重点是DOM、CSS、Jquery我们都有所了解,再学这个应该不难)

     

    从一个技术的定义上,找关键词,我们能总结出它的核心目的。而且能提出一系列问题,有了这一系列问题我们能知道我们接下来要学习什么,只有了解了这些功能才能真正理解设计的目的和是什么。

     

    适用场景

    就是我们这个技术的适应的环境,可以在哪些场景中使用。

     

    比如JSON适用于:

      数据交换,尤其跨平台的数据交换 

      表示JavaScript对象

     

    比如Spring:

      在Java/JavaEE开发的整个过程中都有帮助。此时需要问有哪些帮助?为什么?

     

    比如Jsoup:

      只要我们想在Java里解析HTML就可以考虑使用它。

     

     

    如何使用

    到这一步其实是最简单的,可以按照如下步骤学习:

    1、根据官网的hello world进行简单入门,了解最基本的使用,到此我们入门了;

    2、如果官网提供了单元测试用例,最好的学习方式就是跟着单元测试挨着试,到此该技术的所有特性就有所了解了;

    3、写自己的功能,根据之前学的知识开始开发自己需要的功能;

    4、如果需要经常使用/涉及项目核心技术,一定要读读官方文档,有时间读读API做到心中有数。

     

    此处就不给例子了。

     

    类似的技术

    每当我们学习完一个新技术的时候,都要留一手,防止一个技术有bug/性能问题造成后续无替代方案。

     

    比如Jsoup类似的技术有:

    HTMLParser 

    NekoHTML

    这两个解析工具功能十分强大,但是使用上没有Jsoup简单。

     

    比如我要实现论坛内容过滤功能:

      过滤掉所有的事件注册,如<a nclick="……"> 需要删除onclick

      删除form相关的表单元素,防止恶意用户注入表单窃取用户数据

    这个功能我使用Jsoup实现的。

     

    比如我要抓取iteye的论坛内容(主题、内容、发布人、发布时间)等,使用Jsoup十分方便,因为它的选择器语法类似于Jquery语法,十分方便,而且学习成本很低,基本上只要会Jquery,10几分钟就能上手。

     

    优缺点

    我们应该对我们经常使用的核心技术做到心中有数,即了解优缺点,对于普通的技术只要基本会用即可(有时间可以做对比)。

     

    比如hibernate和ibatis,springMVC和struts2等等,做个对比,总结不出来几点说明自己对这个玩意还是了解不深,需要继续学习和研究。

     

    为什么

    对于一些项目中使用的核心技术,需要掌握:

    做好了解为什么,即为什么有这个东西,即了解发展历史和产生的背景

    如何实现的,读源码,知其所以然

    重复发明个轮子,这样可以更好的了解原理,而且学习效果更佳,这样比读N遍源码效果更好

     

    有朋友会说我看不到咋办?不会写啊! 

       告诉你个笨办法:

          之前我学习CGLIB,是照着人家单元测试挨着敲和试的;

          还有学习源码建议从低版本开始,因为功能少都是核心,好研究。

     

     

    在此学习过程中一定要把握度:

     有些东西只需了解目的和怎么如何即可; 

      有些需要理解到为什么,像spring、junit、slf4j/logback、ehcache、proxool、tomcat、ibatis等等,有时间多读点源代码或者自己造个轮子;尽量做到每一个方面都有涉及(出问题我不怕),但要专一,如spring。

     

     

    我的学习历程

    写自己的代码

    代码量非常重要,前期要写足一定量代码,再看一些书籍/读一些源码才有感觉。我是如何写代码的:

    1、项目代码,这个没得说,在写的过程中思考我们在读书时遇到的一些问题;

    2、在写项目的时候我们可能发现我们经常重复做一些事情,此时就需要考虑建立自己的代码工具库,如通用代码库、代码生成工具、常用工具类等; 不要重复自己,遇到重复的就考虑往自己工具箱添加可复用的组件;

    3、按照自己兴趣发展一个方向,此时可以考虑写一些相关的轮子;通过轮子再反过来深入学习其他相关的技术。

    4、如果有能力就考虑构建自己的平台,简化重复劳动,提升开发效率。

     

    发明轮子我觉得是很有必要的,光看不练没什么多大效果,发明个轮子可以帮助我们更好的理解,轮子不一定非得用到我们的项目,此时的轮子是帮助我们学习的。

     

    阅经典的书籍

    读大师经典著作,如

    《国外程序员推荐:每个程序员都应读的书》

    《一些经典的计算机书籍》

    或者关注如iteye等网站,推荐的一些好书。 我经常到 互动  itpub  图灵社区 等看一些新书。

     

    读书不是到用的时候再读,而是按照自己的方向和兴趣选择相关的书籍进行阅读,学习前人经验和思想,开阔自己思路。

     

    读书不是只读一遍,有些好书如《Effective Java》、《设计模式——可复用面向对象软件的基础》、《企业应用架构模式》、《敏捷软件开发:原则、模式与实践》、《面向对象软件构造》等需要重复读,因为时间段不同积累的经验不同,理解会产生改变,每次读都有不同的收获。

     

    读书读不懂没关系,先放一放,过一段时间再来看,经验到了自然就明白,不要刻意去背,刻意去记,一定要理解着记,记住要理论指导实践,实践检验理论,不可脱节。

     

    不能心急,一下子啃N页,像看小说似的,这样什么都学不到,记不住,即使今天记住了过了几天就忘了,所以要温故而知新。

     

    读书要思考自己之前遇到过类似的场景吗?对比着记更容易,而且记忆的成本会很低。

     

    不要光看自己使用的技术相关的,其他方面的如产品,测试,数据库等相关书籍也建议阅读。在此推荐一本产品入门书:

    《Don't Make Me Think》

     

    尤其在学习Java技术时,建议大家有时间把JDK的核心API(如java.lang/java.util等这些我们经常用的)读一下/还有相关的规范(规范是最权威的指南)。

     

    读优秀的代码

    阅读优秀的源代码可以帮助我们消化书籍中学到的理论,更好的去使用它,而且能开阔我们的思路,完善我们的思想。

     

    读源代码思路:

    1、从使用进行阅读,按照调用关系深入到源代码中,不要一口吃胖子;

    2、跟着单元测试走;

    3、只需读最核心部分即可,无需读所有代码;

    4、从简单的源码入手,刚开始放低难度,如阅读junit、slf4j、ehcache等相对简单的源码,再深入阅读如spring等源代码;

    5、阅读源代码要分而治之,一次读一块,不要混读,不要杂读。

     

    记自己的博客

    记博客可以思维缜密,完善知识体系,扎实技术;而且可以分享自己的经验想法,如果有错误会有朋友指正,非常好的学习方式。

     

    记博客思路:

    1、记录自己工作中遇到的问题及解决方案;自己既然遇到了别人也可能遇到;

    2、不要怕写的简单,没面子,我觉得要厚脸皮 

    3、任何东西都可以记,留作回忆。

     

    向同事的学习

    既然能作为同事,说明大家水平差不多,学习同事的优点。

     

    向同事学习思路:

    1、没事聊聊技术,听听它的想法;

    2、看他的源代码,从中学习;

    3、如果你的老大/同事都不上进,你又是很上进的,建议物以类聚,人以群分,换个环境好好发展自己。

     

    善于观察细节

    善于观察细节,比如从最基本的同事怎么操作的那么快(观察他是如何进行操作的,如发现自己不会的快捷键)?

     

    观察细节思路:

    1、眼要尖,善于发现自己不会的;

    2、嘴要勤,善于问自己不了解的(此处不是没事就去问,而是自己思考过,实在不会的,不要憋在肚子里,问一下又不会怀孕);

    3、没事读同事的源代码,这个可是免费的,从中能学到好的编码习惯和好的解决问题思路。

     

     

    学习没有捷径,我不聪明,但我刻苦;刻苦还是不够,得善于思考和总结。

    学习不要怕丢人,学到手是自己的,学会厚脸皮。

     

    希望对需要的人有所帮助,每个人都有自己的学习方法,可以借鉴学习,但不要临摹,适合自己的才是最好的。

     

    下一篇会《分享我是如何解决问题的》。

     

    PS:以上是本人总结,不对之处谢谢指正。

     

    新的一天又来了,上班去啦。,各位天天好心情!

     

    http://jinnianshilongnian.iteye.com/blog/1709268

  • Address already in use JVM_Bindnull80 解决方案

    2012-11-08 11:16:14

    1.  打开 开始---运行---cmd

    2.  进入Dos界面,输入  netstat -ano

    3.  查看被占用端口的 pid

    4.  然后进入任务管理器  查看---选择列--勾选PID

    5.  找到对应的PID,结束进程。 

  • QTP中对QC附件操作的几个函数(2)

    2012-07-03 18:30:40

    1. End If  
    2. End Function  
    3.   
    4. '***************************************************************************************************************** 
    5. '名称:AddAttachmentOnQC  
    6. '说明:向QC服务器上的指定对象(Test、TestSet或者Defect)中添加附件  
    7. '输入:  
    8. '                                TestObject - QC上的对象:Test、TestSet或Defect  
    9. '                                FileName - 上传目标文件名(完全路径文件名,Full Path Name)  
    10. '返回:  
    11. '                                Bool类型,True代表上传附件成功,False代表上传附件失败  
    12. '示例:AddAttachmentOnQC QCUtil.CurrentTest, "d:/temp/data_file_attached.xls"  
    13. '设计人员:LYH  
    14. '设计时间:08/10/23  
    15. '***************************************************************************************************************** 
    16. Public Function AddAttachmentOnQC(TestObject, FileName)  
    17.    On Error Resume Next  
    18.   
    19.    '初始化函数返回值  
    20.    AddAttachmentOnQC = False  
    21.   
    22.    '通过AddItem(Null)方法取得Attachment对象  
    23.         Set AttachmentFactory = TestObject.Attachments  
    24.         Set Attachment = AttachmentFactory.AddItem(Null)  
    25.           
    26.         '上传文件并更新  
    27.         Attachment.FileName = FileName  
    28.         Attachment.Type = 1  
    29.         Attachment.Post  
    30.         Attachment.Refresh  
    31.         AddAttachmentOnQC = True  
    32.   
    33.         '错误情况处理  
    34.         If Err.Number <> 0 Then  
    35.                 Err.Clear  
    36.                 GetAttachmentOnQC = False  
    37.                 On Error GoTo 0  
    38.         End If          
    39. End Function  
    40.   
    41. '***************************************************************************************************************** 
    42. '名称:ReplaceAttachmentOnQC  
    43. '说明:替换QC服务器上指定对象(Test、TestSet或者Defect)的附件  
    44. '输入:  
    45. '                                TestObject - QC上的对象:Test、TestSet或Defect  
    46. '                                OldFileName - 待删除文件名  
    47. '                                NewFileName - 待上传文件名(完全路径文件名,Full Path Name)  
    48. '返回:  
    49. '                                Bool类型,True代表替换附件成功,False代表替换附件失败  
    50. '示例:ReplaceAttachmentOnQC QCUtil.CurrentTest, "data_file_attached.xls", "d:/temp/data_file_attached.xls"  
    51. '设计人员:LYH  
    52. '设计时间:08/10/23  
    53. '***************************************************************************************************************** 
    54. Public Function ReplaceAttachmentOnQC(TestObject, OldFileName, NewFileName)  
    55.    On Error Resume
  • QTP中对QC附件操作的几个函数

    2012-07-03 18:27:46

    1. '***************************************************************************************************************** 
    2. '名称:GetAttachmentFromQC  
    3. '说明:从QC服务器上的指定对象(Test、TestSet或者Defect)中找到指定名称的附件,下载到指定目录  
    4. '输入:  
    5. '                                TestObject - QC上的对象:Test、TestSet或Defect  
    6. '                                FileName - 下载目标文件名(附件)  
    7. '                                DstFolder - 下载目标文件夹  
    8. '返回:  
    9. '                                Bool类型,True代表取附件成功,False代表取附件失败  
    10. '示例:GetAttachmentOnQC QCUtil.CurrentTest, "data_file_attached.xls", "d:/temp"  
    11. '设计人员:LYH  
    12. '设计时间:08/10/23  
    13. '***************************************************************************************************************** 
    14. Public Function GetAttachmentOnQC(TestObject, FileName, DstFolder)  
    15.    On Error Resume Next  
    16.    '初始化函数返回值  
    17.    GetAttachmentOnQC = False  
    18.   
    19.    '为DstFolder变量添加路径斜杠"/"  
    20.    If Right(DstFolder, 1) <> "/" Then  
    21.            DstFolder = DstFolder & "/"  
    22.    End If  
    23.      
    24.    '取得AttachmentList对象,即TestObject的所有附件  
    25.         Set AttachmentFactory = TestObject.Attachments  
    26.         Set AttachmentList = AttachmentFactory.NewList("SELECT * FROM CROS_REF")  
    27.           
    28.         '先删除本地的文件.  
    29.         Set fso = CreateObject("Scripting.FileSystemObject")  
    30.         If fso.FileExists(DstFolder & Filename) then  
    31.                 fso.DeleteFile DstFolder & Filename   '删除文件  
    32.         End if  
    33.         Set fso = Nothing  
    34.           
    35.         '遍历TestObject对象的所有附件,找到名称为FileName的附件。附件  
    36.         For Each Attachment in AttachmentList  
    37.                 If InStr(1,Attachment.Name, FileName, 1) >= 1 Then  
    38.                         Set AttachmentStorage = Attachment.AttachmentStorage  
    39.                         AttachmentStorage.ClientPath=DstFolder  
    40.                         AttachmentStorage.Load Attachment.Name,True  
    41.             '下载后重命名,去掉QC附件前缀。类似Test_#_Filename  
    42.                         RenameFile DstFolder & Attachment.Name, DstFolder & Filename  
    43.                         GetAttachmentOnQC = True  
    44.             Exit Function  
    45.                 End If  
    46.         Next  
    47.   
    48.         '错误情况处理  
    49.         If Err.Number <> 0 Then  
    50.                 Err.Clear  
    51.                 GetAttachmentOnQC = False  
    52.                 On Error  查看(299) 评论(0) 收藏 分享 管理

    53. QTP Reusable functions

      2012-07-03 15:40:20

      Automation testing using QTP has always been talked upon the most in the testing industry. There are numerous features available within this very toolset, but most of us might not be aware of this very feature which has been discussed in this very articles on automation testing using QTP which is functions created in Vbscript , and is very useful in code customization to meet our automation testing requirements , as it reduces the script. maintenance effort..
       
      1. BEEP from QTP

      ' Three methods of issuing a BEEP from QTP

      ' Method 1
      Extern.Declare micLong,"MessageBeep","User32","MessageBeep",micLong
      retVal = Extern.MessageBeep(&HFFFFFFFF)
      MsgBox retVal 'The return value should be 1.

      ' Method 2
      Err.Number = 0
      On Error Resume Next
      Extern.Declare micLong,"MessageBeep","User32","MessageBeep",micLong
      Extern.MessageBeep(&HFFFFFFFF)
      If (Err.Number <> 0) Then
      MsgBox Err.Description
      End If

      ' Method 3
      Extern.Declare micLong,"Beep","Kernel32","Beep",micLong,micLong
      retVal = Extern.Beep(1000,250) 'The first number is frequency the second is duration.

      MsgBox extract_number("This user belongs to 10 groups")
      MsgBox extract_number("206 features assigned to the user.")

      2. Check for Required URL

      startURL = "www.google.com" ' Amend this to your required URL

      ' If no browser open, open browser and navigate to required URL
      If Not Browser("CreationTime:=0").Exist Then
         Call launch(startURL)
      Else

      ' Get the URL of the current open browser
      currentURL=Browser("CreationTime:=0").GetROProperty("OpenURL")
      ' If not correct URL navigate to required URL
      If Not currentURL = "www.google.com" Then
         Call launch(startURL)
      End If
      End If

      Function launch(startURL)
       ' Create IE object and navigate
       ' to required URL
       set IE = CreateObject("InternetExplorer.Application")
       IE.Visible = true
       IE.Navigate startURL
      End function

      3. Close QTP with QTP script

      Private Function CloseQTP
         Set bjWMIService = GetObject("winmgmts:\\.\root\CIMV2")
         Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'QTPro.exe'")
         For Each objProcess in colProcess
          objProcess.Terminate()
         Next
         Set bjWMIService = Nothing
         Set colProcess = Nothing
      End Function

      4. Open any Appllication through QTP

         ' Function OpenApp
         ' ------------------
         ' Open a specified application
         ' Parameter: application - the application full name (including location)
         '@Description Opens an application
         '@Documentation Open the application.

         Function OpenApp (application)
           systemUtil.Run application
          End Function

      5. Adding any information to QTP Results

         ' AddToTestResults
         ' --------------
         ' Add a Report.Event step to the Test Results
         'Parameters:
         ' status - Step status (micPass, micFail, micDone or micWarning)
         ' StepName - Name of the intended step in the report (object name)
         ' details - Description of the report event    '
         '@Description Reports an event to the Test Results
         '@Documentation Report an event to the Test Results.

         Public Function AddToTestResults (status, StepName, details)
             Reporter.ReportEvent status, StepName, details
         End Function

      6. Enable Doubleclick Event in QTP

      Enable the ondblclick event in the Web Event Recording Configuration

      To enable special event handling, use the Web Event Recording Configuration utility.
      1. Go to Tools -> Web Event Recording Configuration.
      2. Click .
      3. Expand the Standard Objects branch.
      4. Select the object you want to configure.
      5. Go to Event -> Add -> ondblclick. The event will be added to the list on the right.
      6. Select "If Handler" in the Listen column.
      7. Select "Enabled" in the Record column.
      8. Click to close the dialogs.

      7. DSN - Less Connection

      Public sconn
      uid = "UID"
      pwd = "PWD"
      ServerName = "Server Name"

      Connection()

      Function Connection()
      Set sconn = CreateObject("ADODB.connection")
      sconn.Open "Driver=Microsoft ODBC for Oracle;Server="& ServerName &";Uid="& uid &";Pwd="& pwd &""
      End Function

      8. High-Level Automation Framework Information

      At a very high level the framework components can be divided into two categories software part and documentation part. Here is my list of components ? you can add your item if anything is missing.

      ---------------------------------------------
      All software code part
      ---------------------------------------------
      Supporting libraries for Logging, error handling, Execution management
      1. Tool specific code
      2. Setup and configuration scripts
      3. Test management code
      4. Test data and Test data management code
      5. Platform/OS specific scripts

      ---------------------------------------------
      Non software part
      ---------------------------------------------
      Folder structure
      Documents
      i. Coding guidelines
      ii. Procedure for creating scripts
      iii. Planning, design and review procedures
      iv. Approach for automation
      v. Approach for Testing automation code
      vi. Automation documentation - how scripts work
      vii. Setup and implementation procedures
      viii. Defect tracking procedure for Automation scripts
      ix. Source control procedures
      x. Project plan
      xi. Templates for effort estimation
      xii. Template for test case categorization
      xiii. Template for ROI calculation

      9. Get Input Parameter Data and Use in Script

      Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
      Set pDefColl = qtApp.Test.ParameterDefinitions
      Set pDef = pDefColl.Item(1)
      MsgBox pDef.DefaultValue

      10. Pass Test Data from MQC to QTP?

      1) Create Test parameters in QTP (via file>Settings>Parameters) [These are the parameters that you see in QC, on the automated tab of the Configuration page in the Test Instance Propertirs.]

      2) Create action parameters (Action Properties> Parameters)

      3)Link action & test parameters together. To do this, go into Action Call Properties>Parameters. You'll see your action parameters here. Click in the Value column for a parameter and press the Configure Value button. This will open up the Value Configuration Options dialogue. In the parameter drop down list, select Test/action parameter and then, from the following Test parameters; Parameter drop down list, select the Test parameter that you want to link to your Action parameter.

      This should then link the Test parameters to the Action parameters.

      Then in your script, you'll use the parameters as follows: -

      Browser("Browser_Name").Page("Page_Name").WebEdit("Edit_Name").Set Parameter("Parameter_Name")

      11. Get the Attachement from QC to local machine

      To get attachment from test

      Public Function GetTestAttachmentPath(TDAttachmentName) 'Returns File Path
      'Test Director TDAPIOLELib object variables
      Dim otaAttachmentFactory 'As TDAPIOLELib.AttachmentFactory
      Dim otaAttachment 'As TDAPIOLELib.Attachment
      Dim otaAttachmentList 'As TDAPIOLELib.List
      Dim otaAttachmentFilter 'As TDAPIOLELib.TDFilter
      Dim otaExtendedStorage 'As TDAPIOLELib.ExtendedStorage
      Dim strPath 'As String

      Set taAttachmentFactory = QCUtil.CurrentTest.Attachments
      Set taAttachmentFilter = otaAttachmentFactory.Filter
      otaAttachmentFilter.Filter("CR_REFERENCE") = "'TEST_" & QCUtil.CurrentTest.Id & "_" & TDAttachmentName & "'"
      Set taAttachmentList = otaAttachmentFilter.NewList
      If otaAttachmentList.Count = 1 Then
      Set taAttachment = otaAttachmentList.Item(1)
      otaAttachment.Load True, ""
      strPath = otaAttachment.FileName
      ElseIf otaAttachmentList.Count > 1 Then
      Reporter.ReportEvent micFail, "Failure in library function 'GetTestAttachmentPath'", _ "Found more than one attachment '" & TDAttachmentName & "' in test '" & _ QCUtil.CurrentTest.Name & "'."
      strPath = ""
      ElseIf otaAttachmentList.Count < 1 Then
      Reporter.ReportEvent micFail, "Failure in library function 'GetTestAttachmentPath'", _ "Found 0 attachments '" & TDAttachmentName & "' in test '" & _ QCUtil.CurrentTest.Name & "'."
      strPath = ""
      End If

      GetTestAttachmentPath = strPath
      Set taAttachmentFactory = Nothing
      Set taAttachment = Nothing
      Set taAttachmentList = Nothing
      Set taAttachmentFilter = Nothing

      End Function

      To get attachment from folder

      Public Function GetFolderAttachmentPath(TDAttachmentName, TDFolderPath) 'Returns File Path

      'Test Director TDAPIOLELib object variables
      Dim otaAttachmentFactory 'As TDAPIOLELib.AttachmentFactory
      Dim otaAttachment 'As TDAPIOLELib.Attachment
      Dim otaAttachmentList 'As TDAPIOLELib.List
      Dim otaAttachmentFilter 'As TDAPIOLELib.TDFilter
      Dim otaTreeManager 'As TDAPIOLELib.TreeManager
      Dim otaSysTreeNode 'As TDAPIOLELib.SysTreeNode
      Dim otaExtendedStorage 'As TDAPIOLELib.TreeManager
      Dim intNdId
      Dim strPath 'As String
      Set taTreeManager = QCUtil.TDConnection.TreeManager
      Set taSysTreeNode = otaTreeManager.NodeByPath(TDFolderPath)
      Set taAttachmentFactory = otaSysTreeNode.Attachments
      Set taAttachmentFilter = otaAttachmentFactory.Filter
      intNdId = otaSysTreeNode.NodeID
      otaAttachmentFilter.Filter("CR_REFERENCE") = "'ALL_LISTS_" & intNdId & "_" & TDAttachmentName & "'"
      Set taAttachmentList = otaAttachmentFilter.NewList
      If otaAttachmentList.Count > 0 Then
      Set taAttachment = otaAttachmentList.Item(1)
      otaAttachment.Load True, ""
      strPath = otaAttachment.FileName
      Else
      Reporter.ReportEvent micFail,"Failure in library function 'GetFolderAttachmentPath'", _ "Failed to find attachment '" & TDAttachmentName & "' in folder '" & TDFolderPath & "'."
      End If
      GetFolderAttachmentPath = strPath
      Set taAttachmentFactory = Nothing
      Set taAttachment = Nothing
      Set taAttachmentList = Nothing
      Set taAttachmentFilter = Nothing
      Set taTreeManager = Nothing
      Set taSysTreeNode = Nothing

      End Function




      Learn More On QTP Reusable Function creation codes :

      QTP-reusable-functions-codes-5
      QTP-reusable-functions-codes-4
      QTP-reusable-functions-codes-3
      QTP-reusable-functions-codes-2
      QTP-reusable-functions-codes-1
    54. java中Iterator的用法

      2011-10-29 15:24:03

      java中Iterator的用法  

      java.util包中包含了一系列重要的集合类。本文将从分析源码入手,深入研究一个集合类的内部结构,以及遍历集合的迭代模式的源码实现内幕。

         下面我们先简单讨论一个根接口Collection,然后分析一个抽象类AbstractList和它的对应Iterator接口,并仔细研究迭代子模式的实现原理。

         本文讨论的源代码版本是JDK 1.4.2,因为JDK 1.5在java.util中使用了很多泛型代码,为了简化问题,所以我们还是讨论1.4版本的代码。

        集合类的根接口Collection

         Collection接口是所有集合类的根类型。它的一个主要的接口方法是:

      DE>boolean add(Object c)DE>
         add()方法将添加一个新元素。注意这个方法会返回一个boolean,但是返回值不是表示添加成功与否。仔细阅读doc可以看到,Collection规定:如果一个集合拒绝添加这个元素,无论任何原因,都必须抛出异常。这个返回值表示的意义是add()方法执行后,集合的内容是否改变了(就是元素有无数量,位置等变化),这是由具体类实现的。即:如果方法出错,总会抛出异常;返回值仅仅表示该方法执行后这个Collection的内容有无变化。

         类似的还有:

      DE>boolean addAll(Collection c);
      boolean remove(Object o);
      boolean removeAll(Collection c);
      boolean remainAll(Collection c);
      DE>
         Object[] toArray()方法很简单,把集合转换成数组返回。Object[] toArray(Object[] a)方法就有点复杂了,首先,返回的Object[]仍然是把集合的所有元素变成的数组,但是类型和参数a的类型是相同的,比如执行:

      DE>String[] o = (String[])c.toArray(new String[0]);DE>
         得到的o实际类型是String[]。

         其次,如果参数a的大小装不下集合的所有元素,返回的将是一个新的数组。如果参数a的大小能装下集合的所有元素,则返回的还是a,但a的内容用集合的元素来填充。尤其要注意的是,如果a的大小比集合元素的个数还多,a后面的部分全部被置为null。

         最后一个最重要的方法是iterator(),返回一个Iterator(迭代子),用于遍历集合的所有元素。

        用Iterator模式实现遍历集合
       
         Iterator模式是用于遍历集合类的标准访问方法。它可以把访问逻辑从不同类型的集合类中抽象出来,从而避免向客户端暴露集合的内部结构。

         例如,如果没有使用Iterator,遍历一个数组的方法是使用索引:

      DE>for(int i=0; i<array.size(); i++) { ... get(i) ... }DE>
         而访问一个链表(LinkedList)又必须使用while循环:

      DE>while((e=e.next())!=null) { ... e.data() ... }DE>
         以上两种方法客户端都必须事先知道集合的内部结构,访问代码和集合本身是紧耦合,无法将访问逻辑从集合类和客户端代码中分离出来,每一种集合对应一种遍历方法,客户端代码无法复用。

         更恐怖的是,如果以后需要把ArrayList更换为LinkedList,则原来的客户端代码必须全部重写。

         为解决以上问题,Iterator模式总是用同一种逻辑来遍历集合:

      DE>for(Iterator it = c.iterater(); it.hasNext(); ) { ... }DE>
         奥秘在于客户端自身不维护遍历集合的"指针",所有的内部状态(如当前元素位置,是否有下一个元素)都由Iterator来维护,而这个Iterator由集合类通过工厂方法生成,因此,它知道如何遍历整个集合。

         客户端从不直接和集合类打交道,它总是控制Iterator,向它发送"向前","向后","取当前元素"的命令,就可以间接遍历整个集合。

         首先看看java.util.Iterator接口的定义:

      DE>public interface Iterator {
        boolean hasNext();
        Object next();
        void remove();
      }
      DE>
         依赖前两个方法就能完成遍历,典型的代码如下:

      DE>for(Iterator it = c.iterator(); it.hasNext(); ) {
        Object o = it.next();
        // 对o的操作...
      }
      DE>
         在JDK1.5中,还对上面的代码在语法上作了简化:

      DE>// Type是具体的类型,如String。
      for(Type t : c) {
      // 对t的操作...
      }
      DE>
         每一种集合类返回的Iterator具体类型可能不同,Array可能返回ArrayIterator,Set可能返回SetIterator,Tree可能返回TreeIterator,但是它们都实现了Iterator接口,因此,客户端不关心到底是哪种Iterator,它只需要获得这个Iterator接口即可,这就是面向对象的威力。

        Iterator源码剖析

         让我们来看看AbstracyList如何创建Iterator。首先AbstractList定义了一个内部类(inner class):

      DE>private class Itr implements Iterator {
      ...
      }
      DE>
         而iterator()方法的定义是:

      DE>public Iterator iterator() {
        return new Itr();
      }
      DE>
         因此客户端不知道它通过Iterator it = a.iterator();所获得的Iterator的真正类型。

         现在我们关心的是这个申明为private的Itr类是如何实现遍历AbstractList的:

      DE>private class Itr implements Iterator {
        int cursor = 0;
        int lastRet = -1;
        int expectedModCount = modCount;
      }
      DE>
         Itr类依靠3个int变量(还有一个隐含的AbstractList的引用)来实现遍历,cursor是下一次next()调用时元素的位置,第一次调用next()将返回索引为0的元素。lastRet记录上一次游标所在位置,因此它总是比cursor少1。

         变量cursor和集合的元素个数决定hasNext():

      DE>public boolean hasNext() {
        return cursor != size();
      }
      DE>
         方法next()返回的是索引为cursor的元素,然后修改cursor和lastRet的值:

      DE>public Object next() {
        checkForComodification();
        try {
         Object next = get(cursor);
         lastRet = cursor++;
         return next;
        } catch(IndexOutOfBoundsException e) {
         checkForComodification();
         throw new NoSuchElementException();
        }
      }
      DE>
         expectedModCount表示期待的modCount值,用来判断在遍历过程中集合是否被修改过。AbstractList包含一个modCount变量,它的初始值是0,当集合每被修改一次时(调用add,remove等方法),modCount加1。因此,modCount如果不变,表示集合内容未被修改。

         Itr初始化时用expectedModCount记录集合的modCount变量,此后在必要的地方它会检测modCount的值:

      DE>final void checkForComodification() {
        if (modCount != expectedModCount)
         throw new ConcurrentModificationException();
      }
      DE>
         如果modCount与一开始记录在expectedModeCount中的值不等,说明集合内容被修改过,此时会抛出ConcurrentModificationException。

         这个ConcurrentModificationException是RuntimeException,不要在客户端捕获它。如果发生此异常,说明程序代码的编写有问题,应该仔细检查代码而不是在catch中忽略它。

         但是调用Iterator自身的remove()方法删除当前元素是完全没有问题的,因为在这个方法中会自动同步expectedModCount和modCount的值:

      DE>public void remove() {
      ...
      AbstractList.this.remove(lastRet);
      ...
      // 在调用了集合的remove()方法之后重新设置了expectedModCount:
      expectedModCount = modCount;
      ...
      }
      DE>
         要确保遍历过程顺利完成,必须保证遍历过程中不更改集合的内容(Iterator的remove()方法除外),因此,确保遍历可靠的原则是只在一个线程中使用这个集合,或者在多线程中对遍历代码进行同步。

         最后给个完整的示例:

      DE>Collection c = new ArrayList();
      c.add("abc");
      c.add("xyz");
      for(Iterator it = c.iterator(); it.hasNext(); ) {
        String s = (String)it.next();
        System.out.println(s);
      }
      DE>
          如果你把第一行代码的ArrayList换成LinkedList或Vector,剩下的代码不用改动一行就能编译,而且功能不变,这就是针对抽象编程的原则:对具体类的依赖性最小。

      http://blog.163.com/heu_wgc/blog/static/463517620091051166545/

    55. Test Automation ROI Methodology

      2011-10-21 16:00:11

      ROI Methodology

      ROI can be calculated as Total benefit derived from automation / Total cost of automation. The benefits matrix below depicts the distribution of direct and indirect benefits across people, process, and technology drivers, which can be translated to customer benefits.

      Benefits of Automation

      Automated testing tools are capable of running continuously without any productivity loss or fatigue, with minimal or no manual intervention. This implies that organizations can plan testing activities beyond the traditional eight-hour work shift, reducing the elapsed duration for testing by as much as two-thirds of the time required for manual testing.

      Test automation enables organizations to redeploy engineers for specialized tasks that cannot be accomplished through automation testing.

      These tasks include interoperability testing involving external systems, testing for event driven processes in real time, intuitive testing, and more.

      Costs of Automation

      Fixed costs of automation include one-time investments to establish the automation environment. Recurring costs are incurred during the testing lifecycle. The below cost matrix depicts the distribution of fixed and recurring costs across people, process, and technology drivers.

      A Case in Point

      In this section, we illustrate savings in test execution time for automation.

      Benefits

      We assume a sample size of 500 test cases per test cycle. Benefit of automation for each test cycle is given by:

      TS = TM - TA

      Where,

      TS = Time saved due to test automation

      White Paper: ROI on Test Automationcalculations for the following frequencies of execution:

      18 test cycles/ year

      30 test cycles/ year

      50 test cycles/ year

      As evident from the graph above, ROI for test automation increases with increasing

      Automation Frameworks

      Software organizations with an independent testing practice can enhance the benefits of automation further through the use of automation frameworks. Automation Frameworks can provide reusable code bases which support the deployment of the testing tool into the engagement.

      In the following section, we detail the salient features of our automation framework, illustrating ROI enhancements over standard test automation approaches.

      Multi-platform. support (Windows, Java, etc.) –so that scripts can be ported across platforms with minor changes

      TM = Time taken for manual testing

      TA = Time taken for automated testing

      Cost of Automation

      Cost of automation is given by:

      CA = CHS + CDM+ CT

      Where,

      CA = Cost of automation

      CHS = Cost of hardware and software (this can be apportioned over many testing engagements)

      CDM = Cost of developing and maintaining automation script

      CT = Cost of training staff on automation tools (this can be apportioned over many testing engagements)

    56. qtp scripts

      2011-10-20 13:54:30

      用vbs调qtp

      '编写自动执行指定的QTP脚本的VBS:
      '利用QTP本身的Quicktest.Application 对象
      Dim qtApp
      Set qtApp = CreateObject ("Quicktest.Application")
      qtApp.Launch
      qtApp.Visible = True
      qtApp.Open "H:\QTP\QTPscript\Test1"
      qtApp.Test.Run ,True

      '*********************************************************'************************************
      ' 目的: 查找在UserList数组中出现的第一个指定的用户。
      ' 输入: strUserList(): 被搜索的用户列表。
      '             strTargetUser: 待搜索的用户名。
      ' 返回: 指定为strTargetUser 的用户在strUserList数组中出现的第一个位置,
      '             如果目标用户未找到,则返回-1。
      '*********************************************************'************************************
      Function intFindUser (strUserList(), strTargetUser)
          Dim i   ' 循环计数器
          Dim blnFound   ' 目标是否找到的标志
          intFindUser = -1
          i = 0   ' 初始化循环计数器
          Do While i <= Ubound(strUserList) and Not blnFound
            If strUserList(i) = strTargetUser Then
               blnFound = True   ' 设置为True
               intFindUser = i   ' 赋值为当前循环计数器的值
            End If
            i = i + 1   ' 计数器加一
          Loop
      End Function
      ******************************************************************************************************************

      '利用DotNetFactory 对象 ,可以创建.NET对象并访问其方法和属性
      'Remarks
      'You can use this object to access the static methods and properties of a class that does not have an instance constructor,
      ' for example, System.Environment, as well as a class that does.

      'CreateInstance方法用于放回.NET对象的COM接口
      'Remarks
      'If you want to use a .NET object as an argument for a method in QuickTest, you must first create a COM interface for the .NET object
      ' using the CreateInstance method. Then you pass that interface as the method argument.

      'CreateInstance 的使用方法如下
      'Set var_CreateInstance = DotNetFactory.CreateInstance (TypeName [,Assembly] [,args])
      ' 其中TypeName为必须输入的参数,是.NET对象类型的全称,例如:System.Windows.Forms.Form
      ' Assembly是可选的输入参数,如果程序集已经注册,则不需要输入,否则需要输入全名
      ' args是可选的输入参数,是指定TypeName或Assembly所需的参数

      '创建Form实例
      Set var_CreateInstance = DotNetFactory.CreateInstance("System.Windows.Forms.Form","System.Windows.Forms")
      '显示Form实例
      var_CreateInstance.Show
      ' 等待5秒
      wait  5
      ' 关闭Form实例
      var_CreateInstance.Close

      ' 调用System.Environment的CurrentDirectory返回当前所在目录
      Set var_CreateInstance = DotNetFactory.CreateInstance("System.Environment")
      msgbox var_CreateInstance.CurrentDirectory

      *****************************************************************************************************************************************

       ' 获取操作系统名称
      OS = Environment.Value("OS")
      ' 获取操作系统版本
      OSVersion =  Environment.Value("OSVersion")
      ' 获取测试脚本名
      TestName = Environment.Value("TestName")
      Reporter.ReportEvent micDone,"Environment","运行测试脚本" &TestName  & "的操作系统为:" & OS & "版本为:" & OSVersion


      ' 设置环境变量MyVariable的值为10
      Environment.Value("MyVariable")=10
      MyValue=Environment.Value("MyVariable")
      MsgBox MyValue

      ************************************************************************************************************************
      ' 导入外部文件
      Environment.LoadFromFile("D:\QTP\C10\EnvironmentObjectTest1\MyVariables.xml")
      ' 读取其中的环境变量值MyUserName
      MyUserName = Environment.Value("MyUserName")
      ' 读取其中的环境变量值MyPassword
      MyPassword= Environment.Value("MyPassword")
      ' 读取其中的环境变量值MyVariant
      MyVariant= Environment.Value("MyVariant")
      Reporter.ReportEvent micDone,"读取MyVariables.xml文件","MyUserName = "&MyUserName&",MyPassword = " & MyPassword & ",MyVariant = "&MyVariant


      ' 读取当前导入的环境变量文件名
      fileName = Environment.ExternalFileName
      Reporter.ReportEvent micDone,"当前导入的环境变量文件名",fileName
      ' 如果为空,则导入
      If (fileName = "") Then
             Environment.LoadFromFile("D:\QTP\C10\EnvironmentObjectTest1\MyVariables.xml")
      End If
      ' 导入后就可以直接使用其中的环境变量
      msgbox Environment("MyUserName")

      *******************************************************************************************************************

      ExecuteFile "MyFunctions.vbs"
      x = AddTest( 2,2)
      Print "调用MyFunctions.vbs中的函数AddTest,返回值为:" & x
      *******************************************************************************************************************

      '声明FindWindow 方法,调用user32.dll中的FindWindowA函数
      Extern.Declare micHwnd, "FindWindow", "user32.dll", "FindWindowA", micString, micString
      '声明SetWindowText 方法
      Extern.Declare micLong, "SetWindowText", "user32.dll", "SetWindowTextA", micHwnd, micString
      '获取记事本的窗口句柄
      hwnd = Extern.FindWindow("Notepad", vbNullString)
      if hwnd = 0 then
       MsgBox "未能找到记事本窗口!"
      end if
      '改变记事本窗口的标题
      res = Extern.SetWindowText(hwnd, "Hello World!")
      ****************************************************************************************************************

      ' 查找文件,返回文件所在的全路径
      x=PathFinder.Locate ("Parameters.mtr")
      MsgBox  x
      ' 下面查找的文件位于C:\Windows\System32目录中
      y= PathFinder.Locate ("user32.dll")
      MsgBox  y
      *******************************************************************************************************************


      ' 定位到Flights Table窗口的WinList控件
      Set FlightsList = Window("Flight Reservation").Dialog("Flights Table").WinList("From")
      '  获取WinList控件中的所有项,并通过Print方法显示出来
      For i = 1 to FlightsList.GetItemsCount
                    Print FlightsList.GetItem(i - 1)
      Next

      Dim str
      ' 定位到Flights Table窗口的WinList控件
      Set FlightsList = Window("Flight Reservation").Dialog("Flights Table").WinList("From")
      '  获取WinList控件中的所有项,并通过Print方法显示出来
      For i = 1 to FlightsList.GetItemsCount
                    str = str + FlightsList.GetItem(i - 1)+ vbCRLF
      Next
      MsgBox str

      *****************************************************************************************************************************

      Reporter.ReportEvent micDone,"Start Action1 ...","开始运行Action1测试脚本."
      Reporter.ReportEvent micDone,"Action1 Testing...","Action1测试中..."
      Reporter.ReportEvent micDone,"End Action1","Action1测试结束"
      *****************************************************************************************************************

      ' 获取名为IterNumber的环境变量的值
      IterNumber = Environment.Value("IterNumber")
      ' 如果返回值小于20,则设置环境变量值为20
      If IterNumber < 20 Then
       Environment.Value("IterNumber") = 20
      End If
      Msgbox Environment.Value("IterNumber")


      ' 相当于临时的全局变量
      With Setting
      ' 判断名为IterNumber的Item是否存在,如果不存在,则添加一个,并且设置其值为1
      If Not .Exists("IterNumber") then
             .Add "IterNumber",1
      ' 如果存在,则把其值累加1
      Else
             .Item("IterNumber")=.Item("IterNumber")+1
      End if
      End With
      Msgbox Setting("IterNumber")

      ****************************************************************************************************************

      ' 设置QTP在判断一个对象是否存在的最大时间
      Milliseconds = 30000
      Setting("DefaultTimeout") = Milliseconds

      ' 获取DefaultTimeout
      DefaultTimeout=Setting("DefaultTimeout")
      If DefaultTimeout < 50000 Then
       MsgBox (DefaultTimeout)
       Milliseconds = 50000
       Setting("DefaultTimeout") = Milliseconds
      End If

      ******************************************************************************

      ConnectionString = "Data Source=.;Initial Catalog=Northwind;Persist Security Info=True;User ID=sa;PassWord="
      Set SqlConnection = DotNetFactory.CreateInstance("System.Data.SqlClient.SqlConnection","System.Data",ConnectionString)

      SqlConnection.Open

      Set SqlCommand = DotNetFactory.CreateInstance("System.Data.SqlClient.SqlCommand","System.Data","Select * from Orders",SqlConnection)
      Set SqlDataAdapter= DotNetFactory.CreateInstance("System.Data.SqlClient.SqlDataAdapter","System.Data",SqlCommand)
      Set DataSet = DotNetFactory.CreateInstance("System.Data.DataSet","System.Data")
      SqlDataAdapter.Fill DataSet

      SqlConnection.Close

      MsgBox DataSet.Tables.get_Item(0).Rows.Count
      MsgBox DataSet.Tables.get_Item(0).Rows.get_Item(0).ItemArray.Length

       

      ******************************************************************************

      ' 打开Windows计算器
      SystemUtil.Run "calc"
      ' 使用Windows默认的文本编辑器打开某个文本文件
      SystemUtil.Run "C:\type.txt", "", "", "",3

      ******************************************************************************

      Rem 定位到登录窗口
      Dialog("Login").Activate

      Dialog("Login").Activate ' 定位到登录窗口
      Dialog("Login").WinEdit("Agent Name:").Set "MERCURY" ' 输入代理机构名称
      Dialog("Login").WinEdit("Password:").SetSecure "47cd0fce1ff0eb2a7823682a4e90d4b57aa62c89" ' 输入密码
      Dialog("Login").WinButton("OK").Click ' 确认登录

      ******************************************************************************

      ' 使用XMLUtil对象的CreateXML方法来创建XMLData对象
      Set doc = XMLUtil.CreateXML()
      ' 加载XML文件用于检查
      doc.LoadFile "Test.XML"
      '检查XML文档是否满足指定的XML schema
      ans = doc.Validate ("D:\Program Files\Mercury Interactive\QuickTest Professional\dat\ObjectRepository.xsd")
      '如果检查满足Schema,则提示检查成功,否则列出不满足的原因
      If ans Then
             MsgBox "XML文件匹配指定的Schema!"
      else
             errNo = doc.GetValidationErrorsNumber
              For i = 1 to errNo
                    errStr = doc.GetValidationError(i)
                    MsgBox errStr
             Next
      End If

      ******************************************************************************

      ' 创建Clipboard对象
      Set MyClipboard = CreateObject("Mercury.Clipboard")
      ' 清空Clipboard中的所有数据
      MyClipboard.Clear
      ' 设置Clipboard中的文本为“TEST”
      MyClipboard.SetText "TEST"
      ' 获取Clipboard中的文本
      MsgBox MyClipboard.GetText

      ******************************************************************************

      ' 使用CheckProperty检查控件的属性是否与指定的值相一致
      If Dialog("Login").WinEdit("Agent Name:").CheckProperty("text","MERCURY") then
       ' 如果一致,则在测试结果中标识为Pass
       Reporter.ReportEvent micPass,"Agent Name", "Agent Name 输入框的值为 'MERCURY' "
      Else
       ' 否则标识为Fail
       Reporter.ReportEvent micFail ,"Agent Name", "Agent Name 输入框的值不等于 'MERCURY' " 
      End If 

      ******************************************************************************

      Desktop.CaptureBitmap "C:\TestCaptureBitmap.bmp",true

      ' 创建描述对象
      Set bjDesc = Description.Create()
      ' 指定为标题为"无标题 - 记事本"的对象
      objDesc("text").Value = "无标题 - 记事本"
      ' 通过Desktop对象的ChildObjects方法获取当前桌面中所有名为“无标题 - 记事本”的窗口
      Set bjectCollection = Desktop.ChildObjects(objDesc)
      MsgBox ObjectCollection.Count


       

      ******************************************************************************

      ' 激活窗口
      Window("Flight Reservation").Activate
      ' 选择菜单
      Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..."
      ' 运行名为“Track1”的Analog脚本
      Desktop.RunAnalog "Track1"
      ******************************************************************************

      ' 判断某个控件是否存在
      If Dialog("Login").Exist(3) Then
       MsgBox ("Login窗口存在.")
      Else
       MsgBox ("Login窗口不存在.")
      End If

      ******************************************************************************

      Dim LoginTitle
      Dialog("Login").Activate
      ' 获取Login窗口的标题
      LoginTitle = Dialog("Login").GetROProperty("text")
      Msgbox LoginTitle

      ******************************************************************************

      'Dialog("Login").Activate
      'Dialog("Login").Static("Static").Check CheckPoint("Static")
      '' 单击OK按钮
      'Dialog("Login").WinButton("OK").Click 5,5

      '' 设置日期
      'Window("我的电脑").WinCalendar("SysDateTimePick32").SetDate "3-Mar-2008"
      'Window("我的电脑").WinCalendar("SysDateTimePick32_2").SetDate "4-Mar-2008"
      '' 设置为当天日期
      'Window("我的电脑").WinCalendar("SysDateTimePick32").SetDate Date

      '' 定位到Open Order窗口
      'Window("Flight Reservation").Dialog("Open Order").Activate
      '' 把Customer Name选择框勾选上
      'Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set "ON"
      'Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "CNJ"

      '' 从下拉框中选择起飞地点
      'Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
      '' 从下拉框中选择终点
      'Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
      'Window("Flight Reservation").WinButton("FLIGHT").Click
      '
      '' 获取下拉框中的所有项总数
      'MsgBox Window("Flight Reservation").WinComboBox("Fly To:").GetItemsCount

      '' 从下拉框Index获取对应的内容
      'ItemStr = Window("Flight Reservation").WinComboBox("Fly To:").GetItem(1)
      'If  ItemStr="Denver" Then
      '  Msgbox "OK"
      ' Else
      '  Msgbox ItemStr
      'End If

      '' 定位到记事本的窗口
      'Window("记事本").Activate
      '' 最大化记事本的窗口
      'Window("记事本").Maximize
      '' 恢复记事本窗口大小
      'Window("记事本").Restore'' 获取记事本窗口的标题
      'Msgbox Window("记事本").GetROProperty("text")

      '' 在Name输入框中输入文本“CNJ”
      'Window("Flight Reservation").WinEdit("Name:").Set "CNJ"

      'Dialog("Login").Activate
      'Dialog("Login").WinEdit("Agent Name:").Set "MERCURY"
      '' 在Password输入框中输入加密后的密码字符串
      'Dialog("Login").WinEdit("Password:").SetSecure "47d0bb547b92729a4951b5e2fd088faed8c80334"
      'Dialog("Login").WinButton("OK").Click

      '' 往记事本中输入一段文字
      'Window("记事本").WinEditor("Edit").Type "1234567890ABCDEFG"
      '' 然后键入“Enter”键
      'Window("记事本").WinEditor("Edit").Type  micReturn


      'Window("Flight Reservation").Dialog("Flights Table").Activate
      '' 选择WinList列表中的某项内容,通过名称指定
      'Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "15797   DEN   08:00 AM   FRA   08:45 AM   AA     $104.60"
      'Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
      '
      'Window("Flight Reservation").Dialog("Flights Table").Activate
      '' 选择WinList列表中的某项内容,通过名称指定
      'Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select 2
      'Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click

      '' 通过名称指定选择SysListView32中的某项内容
      'Window("我的电脑_2").WinListView("SysListView32").Select "本地磁盘 (C:)"
      '' 通过Index指定选择SysListView32中的某项内容
      'Window("我的电脑_2").WinListView("SysListView32").Select 2

      '' 模拟用户按下CTRL键进行多选
      'Window("我的电脑_3").WinListView("SysListView32").Select "本地磁盘 (C:)"
      'Window("我的电脑_3").WinListView("SysListView32").ExtendSelect "本地磁盘 (D:)"


      'Window("记事本").Activate
      '' 通过指定菜单名称来选择菜单
      'Window("记事本").WinMenu("Menu").Select "文件(F);新建(N) Ctrl+N"
      '
      '' 通过指定菜单Index来选择菜单
      'Window("记事本").WinMenu("Menu").Select "<Item 1>;<Item 2>"

      'MenuPath = Window("记事本").WinMenu("Menu").BuildMenuPath("文件(F)","新建(N) Ctrl+N")
      ' Window("记事本").WinMenu("Menu").Select MenuPath
      '
      'MenuPath = Window("记事本").WinMenu("Menu").BuildMenuPath(1,2)
      ' Window("记事本").WinMenu("Menu").Select MenuPath


      'Window("Flight Reservation").Activate
      '' 选择“First”选项
      'Window("Flight Reservation").WinRadioButton("First").Set

      'Window("Book1").Activate
      'Window("Book1").WinScrollBar("ScrollBar").NextLine 1
      '
      'Window("Book1").Activate
      'Window("Book1").WinScrollBar("ScrollBar").NextPage 1

      'Window("Book1").Activate
      '' 获取ScrollBar的maxscrollpos属性
      'max = Window("Book1").WinScrollBar("ScrollBar").GetROProperty("maxscrollpos")
      '' 设置滚动条位置为中间
      'pos = max/2
      'Window("Book1").WinScrollBar("ScrollBar").Set pos


      'Dialog("日期和时间 属性").Activate
      '' 如果是2008年,则往后选择
      'If Dialog("日期和时间 属性").WinEdit("Edit").GetROProperty("text") = 2008 then
      '    Dialog("日期和时间 属性").WinSpin("msctls_updown32").Next
      'end if
      '
      '' 直接把日期设置到1997年
      ' Dialog("日期和时间 属性").WinSpin("msctls_updown32").Set 1997


      'Status =Window("记事本").WinStatusBar("msctls_statusbar32").GetContent
      'Msgbox Status

      '' 使用GetItemsCount方法获取到状态栏部分的个数
      'StatusItemCount =  Window("C:\").WinStatusBar("msctls_statusbar32").GetItemsCount
      '' 循环取得每一个部分的状态栏信息
      'For I = 0 to StatusItemCount -1
      ' StatusItem = Window("C:\").WinStatusBar("msctls_statusbar32").GetItem(I)
      '    Msgbox StatusItem
      'Next

      'Dialog("日期和时间 属性").WinTab("SysTabControl32").Select "时区"
      'Dialog("日期和时间 属性").WinTab("SysTabControl32").Select "Internet 时间"
      'Dialog("日期和时间 属性").WinTab("SysTabControl32").Select "时间和日期"
      '
      'Dialog("日期和时间 属性").WinTab("SysTabControl32").Select 1
      'Dialog("日期和时间 属性").WinTab("SysTabControl32").Select 2
      'Dialog("日期和时间 属性").WinTab("SysTabControl32").Select 0

      ''选择第二个页签
      'Dialog("日期和时间 属性").WinTab("SysTabControl32").Select 1
      '' 通过GetSelection方法获取当前所选的页签名称
      'SelectedTab = Dialog("日期和时间 属性").WinTab("SysTabControl32").GetSelection
      'Reporter.ReportEvent micDone,"目前选择的Tab页是: ",SelectedTab

      'Window("C:\").WinToolbar("ToolbarWindow32").Press "向上"
      'Window("我的电脑").WinToolbar("ToolbarWindow32").Press "后退"
      'Window("C:\").WinToolbar("ToolbarWindow32").Press "搜索"

      'Window("C:\").WinToolbar("ToolbarWindow32").Press 3
      'Window("我的电脑").WinToolbar("ToolbarWindow32").Press 1
      'Window("C:\").WinToolbar("ToolbarWindow32").Press 4

      '' 在资源管理器中选择某个磁盘
      'Window("我的电脑").WinTreeView("SysTreeView32").Select "桌面;我的电脑"
      'Window("我的电脑").WinTreeView("SysTreeView32").Select "桌面;我的电脑;本地磁盘 (C:)"

      '' 依次展开“我的电脑”、“本地磁盘 (C:)”节点
      'Window("我的电脑").WinTreeView("SysTreeView32").Expand "桌面;我的电脑"
      'Window("我的电脑").WinTreeView("SysTreeView32").Expand "桌面;我的电脑;本地磁盘 (C:)"

      'Window("我的电脑").WinTreeView("SysTreeView32").ExpandAll "桌面;我的电脑;本地磁盘 (C:)"

      'Window("我的电脑").WinTreeView("SysTreeView32").Collapse "桌面;我的电脑;本地磁盘 (C:)"

       

       

       


      *************************************************************************

    57. Automation Testing Framework

      2011-10-19 17:51:57

      http://www.automatedtestinginstitute.com/home/index.php?option=com_content&view=article&id=69&Itemid=75

       

      Frameworks Introduction      
      Automated testing is most effective when implemented within a framework. Although, in automated testing, the term framework is often used to describe the collective structures that compose unit testing tools, this section will largely focus on a different kind of framework. Here we will discuss the types of frameworks that may be defined as a set of abstract concepts, processes, procedures and environment in which automated tests will be designed, created and implemented. In addition, this framework definition includes the physical structures used for test creation and implementation, as well as the logical interactions among those components. Over the years, automated testing (and thus automated test frameworks) has evolved, becoming increasingly defined and sophisticated with each new evolutionary phase. These phases can be described in terms of three generations, each generation wielding a set of advantages and challenges, thus each generation remains relevant despite new developments. These generations generally apply to Functional System Test Automation, but in some instances may expand to address Unit Test Automation. For more information scroll to the lower half of the Frameworks menu page.
       

      Frameworks


      Linear
       
      The Linear "framework" typically yields a one-dimensional set of automated tests Readmore

      Data-driven
       
      Frameworks built on Data-driven scripting are similar to Linear scripts, in that Readmore


      Keyword-driven
      Often called “Table-driven”, this framework tends to be more application-ind Readmore

  • China's IT Outsourcing Firms Aim to Move Up the Value Chain

    2011-10-19 15:10:22

    Microsoft, IBM and other multinational companies have long been customers for VanceInfo, one of China's largest IT outsourcing firms. With more than 11,000 employees, VanceInfo leverages China's low-cost work force to develop products and enterprise software for many of its clients.

    IDG News Service — Microsoft (MSFT), IBM (IBM) and other multinational companies have long been customers for VanceInfo, one of China's largest IT outsourcing firms. With more than 11,000 employees, VanceInfo leverages China's low-cost work force to develop products and enterprise software for many of its clients.

    But continuing to rely on low-cost labor to attract business is becoming outdated, said Ken Schulz, vice president of global marketing for the company.

    Facing rising labor wages and increased competition, Chinese IT outsourcing firms like VanceInfo intend to provide more that just cost savings for their customers.

    "In order to tap the market, we can't just focus on staffing," Schulz said. "We don't want to get paid for the people, but get paid for the solutions we can provide."

    While India is home to the world's largest outsourcing firms, multinational companies have also looked to outsourcing firms in China, not only due to the country's equally low-cost labor force, but also with the aim of tapping the country's vast market.

    Companies like VanceInfo, which was founded in 1995, have seen demand for their services surge as a result. In 2011, the company's revenues are forecasted to reach US$275 million, a year-on-year increase of 30 percent. Staffing has also increased from 3,700 in 2007 to 11,600 in 2010.

    VanceInfo's past work has included localizing products for the Chinese market. But as foreign companies have relied on outsourcing firms like VanceInfo, so have China's own domestic IT companies, which have also exploded in growth. In 2006, only 5 percent of VanceInfo's customer base came from China, Schulz said. Now that number has reached 45 percent, with VanceInfo's U.S. customers at 34 percent.

    "Chinese companies have their own IT departments, but they want to build up their IT capabilities. They are facing competition and they want to go global," Schulz said.

    HiSoft, another major Chinese IT outsourcing company, has seen the same kind of growth. While most of the company's customers come from the U.S. and Japan, now 17 percent of HiSoft's client base is from China, which include Internet companies, banks and telecommunication companies. Two years ago, that percentage was zero, said HiSoft CEO Tiak Koon Loh.

    "We have served international clients like Microsoft and GE (General Electric) (GE). They have been outsourcing to vendors for a long time. So we took the best practices and what we learned from them and leveraged that to build capabilities to serve our Chinese customers," he said.

    China's market growth, its huge talent pool and Chinese government tax incentives have all helped drive the industry, according to outsourcing firms in the country. But to stay competitive, outsourcing companies have had to cut costs as they deal with rising wages due to the Chinese Yuan's appreciation.

    In the cases of VanceInfo and HiSoft, both companies have migrated parts of their business further inland to smaller cities, where wages are lower compared with Beijing and Shanghai.

    But in the future, China's cost-saving advantage will grow weaker, said Chen Ximin, COO of Neusoft, another major Chinese outsourcing company with more than 18,000 employees. Furthermore, multinational companies want more than just low-cost labor, but complete product solutions, Chen said.

    "We have to leave behind this thinking of just offering a simple cost-saving advantage," he said. "The advantage won't last, and it's something we have all been aware of."

    To meet the challenge, Chinese IT outsourcing companies have shifted toward being providers of customized enterprise software. Products can involve building online banking programs or creating software used to support telecommunication networks. At the same time, the companies have been more active in investing in research and development projects.

    But while Chinese IT outsourcing firms try to leverage their own advantages, they still fall behind their Indian rivals in terms of scale. Infosys, one of India's largest IT outsourcing firms, employs 130,000 people, ten times more than the largest IT outsourcing companies in China. This allows the Indian firm to take on bigger projects.

    Chinese companies like Neusoft and VanceInfo aim to better compete by expanding near-shore offices in countries like the U.S. and Europe, where Indian outsourcing companies already have a presence.

    In spite of the challenges, the market for China's IT outsourcing firms is only expected to grow, said Tina Tang, an analyst with research firm Gartner (IT).

    "China will obviously become a bigger player," she said. "Even as it will have to compete with other countries, China can become a provider of high-level IT services."

     

    http://bx.businessweek.com/china-outsourcing/view?url=http%3A%2F%2Fwww.cio.com%2Farticle%2F687246%2FChina_s_IT_Outsourcing_Firms_Aim_to_Move_Up_the_Value_Chain

  • Business Etiquette and Corporate Style Tips

    2011-10-18 10:50:39

    Q: I occasionally brainstorm ideas with a co-worker, but he recently presented one of mine as his own. How do I handle this?

    A: First, be certain that you made it clear that the idea in question was yours and one you intended to present.

    If you did not, assume that your co-worker genuinely did not remember how the idea came to him, and let it go.

    If, however, you are certain of the impropriety(不得体), approach your co-worker in a nonconfrontational manner. Let him know that you believe the idea was originally yours and that he may have unintentionally presented it as his own.

     If he is open, see how you can work together to rectify the situation. Regardless, be sure to build on the idea and make your contributions known to others. While you may not receive credit for the initial concept, colleagues will remember your role as a team player and strategic thinker.

     To avoid a similar predicament(尴尬的处境,困境,窘境 ) in the future, share your ideas in a group setting, rather than with just one person. In addition, take the initiative to schedule a short meeting with your manager to share your most viable ideas.

    —Carol Davidson, StyleWorks of Union Square

  • Daily Words

    2011-10-18 10:26:01

    make lame excuses 
    1.瘸的,跛的
    2.(指借口或论据)蹩脚的,软弱无力的,无说服力的
    appreciate your candor
    n. 坦白,直率,公正
  • Headhunters Job Search Tips and Interview Advice (5)

    2011-10-18 10:06:28

    Getting on the A-list at work is ridiculously simple. Take on a miserable-but-important project that nobody wants or where others have failed … and succeed.

    —Mark Jaffe, Wyatt & Jaffe

    Give Yourself a Break

    Come down off that ledge. Please remember that what’s happening out there is a reflection of the overall economy. It’s not a commentary on your specific qualifications.

    —Mark Jaffe, Wyatt & Jaffe

    Behave Like an Invested Party

    At job interviews, show prospective employers you want to add value to their organizations. Act like you’re already on the payroll.

    —Mark Jaffe, Wyatt & Jaffe

    Hold Your Own at the Interview

    The more you want to be taken seriously as a candidate, the more you should forget that you are one. Imagine instead that you’re a consultant and that you’ve just been paid a huge, nonrefundable fee to attend this meeting.

    —Mark Jaffe, Wyatt & Jaffe

    Make It a Bit Personal

    Don’t address letters to “Dear Recruiter.” Acknowledge the recipient by name, and he or she might actually remember yours.

    —Mark Jaffe, Wyatt & Jaffe

    A Few Words About Cover Letters

    Cover letters need to be way brief. Think haiku. Didn’t you hear that the whole world now has ADD? Mention that your résumé is attached and say goodbye.

    —Mark Jaffe, Wyatt & Jaffe

    Empathize With the Résumé Reader

    Think of whoever reads your résumé as an audience, then manage their eye movements. Did someone tell you those horrid little bullets would make it easier to scan? That’s exactly why you don’t want to use them. Shameless self-promotions, garish buzzwords, and “inventive” graphics are as image-positive as polyester leisure suits.

    —Mark Jaffe, Wyatt & Jaffe

    Be Realistic About Your Trajectory

    If you’re a dermatologist in Buffalo who wants to pitch for the Yankees, you’ll need a wicked slider because even the best résumé won’t help. And no, 10 years of accounting experience broken down into core competencies doesn’t qualify you to become the next CFO at Google. Putting fantasy on paper won’t make it come true. Ask yourself honestly, “Can I get there from here?”

    —Mark Jaffe, Wyatt & Jaffe

    Advance by Achieving. It’s That Simple

    Don’t rely on recruiters to package or promote you. Seriously. We are not the answer to your prayers. Most of us never even answer our phones. Do brilliant work in your industry or discipline and we will find you when we have the right opportunity.

    —Mark Jaffe, Wyatt & Jaffe

    Make Your Résumé Just the Facts, Ma’am

    Write your résumé the way Jack Webb spoke on Dragnet: simple, direct statements in government-style, gray-flannel prose. No embellishing. The number of pages doesn’t matter; substance does. Tell your story and get out of there.

    —Mark Jaffe, Wyatt & Jaffe

    Don’t Jump at the First Offer

    Take a lesson from Smokey Robinson and “Shop Around.” Avoid jumping into a job where you think you’ll be miserable. Chances are there’s at least one more option around the corner.

    —Mark Jaffe, Wyatt & Jaffe

    Know That You Will Get a Job Soon Enough

    Understand that despite what you see on the cable networks, we are not living in the End of Days. Yes, it’s miserable out there—worse than most of us have ever seen—but it will be a bad memory sooner than you or CNBC imagines.

    —Mark Jaffe, Wyatt & Jaffe

    Work Swiftly but Patiently

    Listening too closely to your inner “job clock” can get you wound way too tight. Yes, time is of the essence—there’s not a minute to waste—but most people underestimate how long it takes to find the right gig. Pace yourself and spare the whip.

    —Mark Jaffe, Wyatt & Jaffe

    Don’t Throw Out the Baby …

    Revitalize yourself, but don’t reinvent. Companies need the experience and accomplishments you’ve earned over time. Leave the instant makeovers for people who have something to hide. Leverage what you already have instead of focusing on what you fear you may lack.

    —Mark Jaffe, Wyatt & Jaffe

    Rein in Expectations

    Be realistic and set your goals at achievable levels. Naked ambition is a great thing, especially on reality TV, but baby steps may be more effective at the moment. Besides, starting at the top is overrated.

    —Mark Jaffe, Wyatt & Jaffe

    Job Hunters, Calm the Heck Down

    Bleak as the employment market may seem, the solution is not finding elaborate gimmicks or reaching the perfect pitch of frenzy. Forget the video cover letter, the chocolate-chip cookie résumé, and the Robin Williams interview style.

    —Mark Jaffe, Wyatt & Jaffe

  • Headhunters Job Search Tips and Interview Advice (4)

    2011-10-18 10:05:35

    —Tara McKernan, DHR International

    Talk About the Team

    Whether interviewing or happily employed, learn to communicate without using the words “I” and “me.” Talk about the players and the total effort, acknowledging and crediting others. It will become contagious and you’ll get your share of the glory, too.

    —Mark Jaffe, Wyatt & Jaffe

    Strapped for Time on the Job Hunt?

    Use services such as resumerabbit.com and jobdrone.com that post your résumé to multiple job sites at once. They can save you hours of data entry.

    —Tara McKernan, DHR International

    Forget Easy Tricks, Quick Fixes

    There are no success secrets. It’s about experience, performance, maturity, and attitude—rather than techniques, protocol, gimmicks, and magic talismans.

    —Mark Jaffe, Wyatt & Jaffe

    Take Community Action

    Look for a community service project sponsored by the employer you’re interested in and offer your skills to it. You will learn about the company culture and make some key contacts.

    —Tara McKernan, DHR International

    Post your photo on LinkedIn?

    If it’s a solid asset, great, then use it. Please make sure we can see your face clearly, the mug shot was professionally done, and it conveys a “strictly business” demeanor. When in doubt, leave it out.

    —Mark Jaffe, Wyatt & Jaffe

    Radiate Cash-Cow Karma

    How do you get a recruiter’s attention? Look like a meal ticket for future search business once he or she installs you in that sleek new corporate role.

    —Mark Jaffe, Wyatt & Jaffe

    Plain Old Hard Work

    Perspiration still wins over inspiration. Being a professional doesn’t mean you have to be super-motivated in everything you do. It means playing at the top of your game and performing as if you were inspired.

    —Mark Jaffe, Wyatt & Jaffe

    Come Clean Constructively

    Don’t be freaked out by the interview question, “What wrong turns or unfortunate choices have you made in your career?” Ability to answer this confidently demonstrates your capacity for honest self-analysis and introspection.

    —Mark Jaffe, Wyatt & Jaffe

    Stay Positive

    Play to your strengths. Don’t focus on what you perceive to be your weaknesses and limitations. It’s a huge waste of energy.

    —Mark Jaffe, Wyatt & Jaffe

    About Cover Letters

    Think haiku. Didn’t you hear the whole world has ADD? Since attention spans max out at about three seconds, mention that your résumé is attached and say goodbye.

    —Mark Jaffe, Wyatt & Jaffe

    How do you get a recruiter’s attention?

    It’s a distinctly unglamorous method but oh-so-reliable. Do memorable work in your industry or profession and we will find you despite your employer’s best efforts to conceal your brilliance from the rest of the world.

    —Mark Jaffe, Wyatt & Jaffe

    Second-Place Blues?

    If you were runner-up for a position that was exactly in your sweet spot, you have nothing to lose by calling the hiring manager 90 days later and asking how that new hotshot is working out. You may be surprised to learn that she wishes she had gone with you after all. Stranger things have happened.

    —Mark Jaffe, Wyatt & Jaffe

    Tell Your Boss the Truth

    Here’s an opportunity for an up-and-comer who doesn’t have the universe to lose: Earn your boss’s trust by saying the hard thing, the thing nobody else has the insight or courage to say.

    —Mark Jaffe, Wyatt & Jaffe

    While preparing a résumé or interviewing, resist the urge to tell me you’re a “highly motivated, results-driven, visionary, world-class entrepreneur.” May I decide that for myself, after I’ve had time to consider your many accomplishments?

    —Mark Jaffe, Wyatt & Jaffe

    Pull Off a Feat

  • Headhunters Job Search Tips and Interview Advice (3)

    2011-10-18 10:03:35

    —Tara McKernan, DHR International

    Remember: Worrying Produces Nothing

    No matter how legitimate your need to panic—money, health, children—stressing and obsessing will only paralyze you. Has gunning the fear engine ever done anything to relieve the pain?

    —Mark Jaffe, Wyatt & Jaffe

    Plan What to Ask

    Make a list of questions to ask at your job interview. Avoid long-winded ones; get to the point. Ask upbeat questions the interviewer can answer with positive information about the organization.

    —Tara McKernan, DHR International

    Can the Holier-Than-Thou Stuff

    Don’t be sanctimonious. Hey, what’s the weather like up there on Mt. Olympus? Nobody can stand that crap, so just don’t start.

    —Mark Jaffe, Wyatt & Jaffe

    Remember It’s Not Over Till It’s Over

    Write a follow-up note when you don’t get the job. This is so unusual that you’ll stand out, and perhaps the interviewer will know of other opportunities and recommend you. Don’t be afraid to ask that question in the note.

    —Tara McKernan, DHR International

    Quit Groveling

    Consider giving up manipulation entirely. Flattery, appeasement, and old-fashioned boot-licking are especially poisonous to a relationship, even if your manager is a modern-day Caligula.

    —Mark Jaffe, Wyatt & Jaffe

    Keep It Rosy During Job Interviews

    Maintain a positive, upbeat attitude. Everyone wants to be around a winner. Never criticize your current or former manager or employer.

    —Tara McKernan, DHR International

    Enough with the Anxiety

    When you worry, you’re just recycling the past. This is now. Extricate yourself and do something useful.

    —Mark Jaffe, Wyatt & Jaffe

    Don’t Get Ahead of Yourself

    One small negative step can sink a job search. Never ask about telecommuting, job sharing, whether or not relocation is necessary, what sort of car will be part of the package, or whether this a cubicle or windowed-office position.

    —Tara McKernan, DHR International

    Don’t Toady in the Presence of a Giant

    The key to dealing with larger-than-life people who rule your destiny is this: Never suck up, but remember the conversation is always about their issues, not yours.

    —Mark Jaffe, Wyatt & Jaffe

    Avoid the ‘Department of Redundancy Department’

    Keep track of your career networking efforts so you never send out duplicate e-mails or notes, as this will be perceived as disorganization or worse, sloppiness.

    —Tara McKernan, DHR International

    Win Via Discretion

    Assume that people never keep anything you tell them in confidence. Gain mastery over this secret weapon, and you will become powerful beyond your wildest dreams.

    —Mark Jaffe, Wyatt & Jaffe

    Let Job Sites Work for You

    Use major job search agents, such as www.theladders.com or www.execunet.com, where you sign up and receive job listings by e-mail. You’ll get to more jobs, more recruiters, and more opportunities.

    —Tara McKernan, DHR International

    Rise in the Wee Hours

    Every successful person since the advent of opposable thumbs has risen at the crack of dawn. Set your alarm and get moving.

    —Mark Jaffe, Wyatt & Jaffe

    Feeling out of the Loop?

    Contact former professors with whom you had particularly good bonds. Odds are they can advise you on how to get current in a changing job market.

    —Tara McKernan, DHR International

    Make Them Feel Important

    Please remember that headhunters, like lecherous old men, need a little love, too. (Occasionally it’s an overlapping demographic.) When a recruiter calls, say the magic words: “Hold on a second. I have to close my door.”

    —Mark Jaffe, Wyatt & Jaffe

    Get with the Gratitude

    Thank-you notes are a must. E-mail is fine, but be specific as to what excited you about the opportunity, how you can hit the ground running, and what impact you can make immediately.

  • Headhunters Job Search Tips and Interview Advice (2)

    2011-10-18 10:02:18

    —Tara McKernan, DHR International

    Dump the Young-Person Baggage

    Are you defensive? Insecure? Always worried about how you look to others? Cut that out!

    —Mark Jaffe, Wyatt & Jaffe

    Ooze Confidence, Not Arrogance

    Cocky is never O.K. During interviews, don’t use superlatives such as “great at” or “wonderful” when describing yourself.

    —Tara McKernan, DHR International

    Try This Little To-Do List

    1. Let people underestimate your abilities. 2. Vastly exceed their expectations. 3. Get promoted and enjoy the last laugh.

    —Mark Jaffe, Wyatt & Jaffe

    Come on, Get Real

    Please don’t waste your valuable time applying for jobs for which you fit none of the qualifications. This will only demoralize you when you get no response.

    —Tara McKernan, DHR International

    Help, Don’t Opine

    Co-workers don’t value your input nearly so much as your cooperation. It’s all about how you make the other person feel about him- or herself.

    —Mark Jaffe, Wyatt & Jaffe

    Turn Rejection into Enlightenment

    Didn’t make it past the initial phone screen? Don’t take it to heart; try to get feedback on why. Always strike a friendly, open, positive tone when probing for feedback.

    —Tara McKernan, DHR International

    Take the High Road

    The simplest and most elegant way to stand above the crowd will always be through the virtue of your actions. It means taking individual responsibility, making good on promises, not exaggerating, always having your mouth and your heart in perfect agreement.

    —Mark Jaffe, Wyatt & Jaffe

    Prepare for the Big Interview Question

    The most frequently asked question is, “Tell me about yourself.” The wrong answer is, “What do you want to know?” This tells the prospective employer you’re unprepared for the interview.

    —Tara McKernan, DHR International

    Watch Your Words—and Tone

    Real life is like high school. Get ready to be judged on popularity. Recognize that how you say things is often more important than what you say. Above all, don’t tell people what’s “wrong” with them.

    —Mark Jaffe, Wyatt & Jaffe

    Put Real Effort into Cover Letters

    Generic cover letters are a big no-no. They turn off the prospective employer as they demonstrate that you didn’t even have enough interest to research the job or hiring firm.

    —Tara McKernan, DHR International

    Turn a Negative into a Positive on the Interview

    Instead of saying, “No, I’ve never done that” and feeling miserable afterward, try, “You know, I haven’t had the opportunity to do that before but have always wanted to learn. Would I be able to here?”

    —Mark Jaffe, Wyatt & Jaffe

    Go Traditional

    What is the new look for interviewing? The old rule remains true: dark suit with plain shirt or blouse. You’d be surprised how many candidates get this wrong.

    —Tara McKernan, DHR International

    Let Interviewers Reach Their Own Conclusions

    Your next boss wants to be enamored, not assaulted. In business as in love, infatuation rarely results from a hard sell or a soft-shoe routine. Always explain, but resist the urge to exclaim.

    —Mark Jaffe, Wyatt & Jaffe

    Explain Résumé Job Gaps Skillfully

    Make it brief, honest, and positive. For example: “I felt I would be doing my employer a disservice by staying on once I decided it was time to move on and decided to make the job search a full-time endeavor.”

    —Tara McKernan, DHR International

    Do Like a Boy Scout

    A scout is trustworthy, loyal, helpful, friendly, courteous, kind, obedient, cheerful, thrifty, brave, clean, and reverent. Need we say more?

    —Mark Jaffe, Wyatt & Jaffe

    Write a Can-Do Résumé

    A good résumé advertises not what you’ve done but what you can do for your future employer.

  • Headhunters Job Search Tips and Interview Advice (1)

    2011-10-18 09:49:25

    Headhunters Job Search Tips and Interview Advice

    Executive recruiters share words of wisdom about networking, finding a job, interviewing, improving your résumé, and climbing the corporate ladder (updated with a new tip every week

     

    “Train” Your Thoughts on Transportation Overseas

    If you’re interviewing in a foreign country, make sure ahead of time that the trains are running. I just had a candidate lose out on a job in Paris because of arriving an hour late. France’s state-owned railway, SNCF, was having a strike.

    —Tara McKernan, DHR International

    Each Job a Whole New Ball Game

    Every business endeavor comes with its own set of values and challenges. There has never been an empirical “scale” by which we could gauge the potential worth of individuals to corporations.

    —Mark Jaffe, Wyatt & Jaffe

    Sell Yourself

    At the top of your résumé, list your attributes. Include such assets as tenacity and the ability to think critically and work well collaboratively and individually.

    —Tara McKernan, DHR International

    Practice Saying ‘Aw, Schucks’

    Two words: humble gratitude. Don’t be the larger-than-life ego that sucks all the air from the room. Give others credit.

    —Mark Jaffe, Wyatt & Jaffe

    Take a Dry Run
    Drive to the prospective employer’s office before the big day so you know exactly where you are going. Arrive 10 minutes early to give yourself an opportunity to freshen up and take a deep breath.

    —Tara McKernan, DHR International

    Spare Us the Buzzwords

    While you may think you’re staying ahead of the curve by discussing mission-critical strategies and scalable synergies, at the end of the day it wrongsizes your core competencies and value-added learnings by diminishing stakeholder traction. Understand that? No one does. People who use lots of business clichés sound like empty suits.

    —Mark Jaffe, Wyatt & Jaffe

    Come with 10 Questions

    Have a list of at least 10 questions that show your interest in the company and the position for which you’re interviewing.

    —Tara McKernan, DHR International

    Seize the Day, Every Day

    Don’t wait until you’re at the top of your game to play like you mean it.

    —Mark Jaffe, Wyatt & Jaffe

    Forget About What’s in It for You

    What never to ask about during the first interview: salary or vacation policy.

    —Tara McKernan, DHR International

    Build Your Reputation

    If nobody much has ever heard of you, we’re inclined to suspect there’s a good reason.

    —Mark Jaffe, Wyatt & Jaffe

    Be Proactive

    At the end of the job interview, always ask about the next step in the process.

    —Tara McKernan, DHR International

    Use the Three Magic Words

    “I don’t know.” Learn how to say it, when to say it, and why. Nothing could be a greater proof of your overall credibility.

    —Mark Jaffe, Wyatt & Jaffe

    Remember the Simplest Way to Impress

    During an interview, pay attention, listen, make eye contact, and don’t fidget.

    —Tara McKernan, DHR International

    Stop Comparing Yourself

    There will always be somebody who does it better, faster, more artfully, or for bigger profits. Does that mean you’re a loser? Define success on your own terms and live a fulfilled life.

    —Mark Jaffe, Wyatt & Jaffe

    Calculate Your Compensation

    Remember that employers are not accountable for your financial responsibilities. Determine a reasonable salary requirement by investigating market trends in your field.

    —Tara McKernan, DHR International

    Lighten Up

    Be respectful and sensitive to co-workers, but don’t take yourself so seriously. If you find it hard to laugh at yourself, it may be that others will wind up doing it for you.

    —Mark Jaffe, Wyatt & Jaffe

    Don’t Panic Over Tough Questions

    Never say anything negative when asked such questions as, “What do you think of your last manager?” Answer in a way that demonstrates your respect for authority and ability to work for different types of management styles.

  • China vs. the U.S.: The Case for Second Place

    2011-10-14 09:37:50

    It is now a foregone conclusion that China’s economy will become the biggest in the world sometime very soon. According to the World Bank, the size of China’s economy is $10.1 trillion, compared with $14.6 trillion for the U.S., based on purchasing power parity (which adjusts exchange rates to account for the different prices people pay for goods and services across countries). But China is narrowing the gap in a hurry. Over the past 10 years, the annual real growth of China’s gross domestic product averaged 10.5 percent, compared with 1.7 percent in the U.S. The Chinese economy increased at an annual rate of 9.6 percent in the first half of 2011, vs. a rate of less than 1 percent in the U.S. America’s days as top dog of global output are numbered, at best.

    Should we care? People from Thomas Friedman to Niall Ferguson cite the looming change at the top of the world economic rankings as a bellwether of broader American decline. “We are the United States of Deferred Maintenance. China is the People’s Republic of Deferred Gratification. They save, invest, and build. We spend, borrow, and patch,” complained Friedman in a recent New York Times column. And yet having the world’s largest economy isn’t all it’s cracked up to be—and you need look no further than the history of China and the U.S. to see that. The swelling size of China’s economy may be a source of pride to the Chinese people, but America is still by far the better place to live—and will remain so for a long time.

    Although economists are skeptical about China’s ability to sustain its current levels of growth, most agree it is only a matter of a few years before the Middle Kingdom’s 1.3 billion or so people produce more than the 310 million living in the U.S. That means history is repeating itself. The U.S.’s reign as the largest world economic power began a little before 1890, when it supplanted the previous global giant: China. According to data from the late Angus Maddison, an economic historian at the University of Groningen in the Netherlands, China boasted the largest economy in the world all the way back to 1500. Prior to the 20th century, its run at No. 1 was interrupted only for a brief period around 1700, when India took a turn at the top.

    And yet during those five centuries when its economy was the world’s biggest, China was never even close to being the world’s wealthiest country. Italy was almost twice as rich in 1500, the Netherlands almost three times as rich in 1700, and the U.K. six times as rich by 1870. Today, though the GDPs of the U.S. and China are roughly equal, the average person in China lives on an income that can buy only 16 percent of the goods and services of the average person in the U.S., and it will take decades for that gap to close. If you’re an American feeling down about losing top economy status, go take a holiday in Guizhou, a poor western Chinese province where incomes are about one-fortieth as high as the U.S. average. You’ll feel a lot better.

    Nevertheless, pessimists warn that being knocked off the top spot could still have all sorts of ill effects for the U.S. Being the biggest economy, they argue, has been vital to American prosperity because, since the close of World War II, the dollar has been predominant in international financial reserve holdings, allowing the U.S. to borrow and trade in its own currency. Arvind Subramanian of the Peterson Institute for International Economics predicts that as China’s economy overtakes the U.S.’s, so too will the relative importance of the renminbi. He argues that within 10 years, the renminbi could replace the dollar as the world’s largest reserve currency.

    But the impact of that change might be less than dramatic. It’s probably true that if the dollar loses its dominance, American companies will have to start hedging against exchange rate risk, and government borrowing might become a little more expensive. But foreign companies already have to hedge currency risk and yet still manage to compete, while less borrowing would surely be a good thing for the U.S. in the medium run. And a renminbi whose value rises—as it will have to if it is to become a reserve currency—should help even up the U.S.-China trade balance.

    What China will soon discover is that being the world’s biggest economy and holding its favored reserve currency have little bearing on a country’s actual economic performance. For proof, just look at the U.S. Between 1890, when America became the world’s largest economy, and 2008, the U.S.’s annualized per capita income growth was about a quarter of a percentage point lower than China’s. America’s growth performance during those 118 years ranked just 15th out of 37 countries for which the University of Groningen’s Maddison has data—behind economies including Denmark, Canada, Sweden, and (wait for it) Greece. Even a number of really small countries have done better than America. Luxembourg has a GDP four-tenths of a percent the size of the U.S. economy, about the same output as the state of Delaware. And yet it is more than twice as rich per person as the U.S.

    For a while in the 1940s, the U.S. showed that the combination of being the biggest and richest power can yield dividends—it was decisive in defeating two other world powers in war and making a global peace largely of America’s own design. And yet being the planet’s largest economy encouraged, or perhaps obliged, the U.S. to try to act as the world’s policeman, which even the most unrepentant neoliberal would acknowledge has been a burden as much as a blessing. Not least, it meant that more American soldiers died abroad last year than troops from any other nation, according to data from Sweden’s Uppsala University. Meanwhile, U.S. military spending now accounts for more than two-fifths of the world total, and it sucks up a larger percentage of GDP than any other member of the Organization for Economic Cooperation and Development.

    If anything, supremacy confers even fewer benefits on the world’s dominant power than it did a century ago. Thanks in large part to the postwar international system the U.S. drove to create, any country’s ability to use size to strike unfair trading arrangements is considerably constrained by the requirements of the World Trade Organization. And China will likely be even more limited—because its economy is so reliant on exports, it needs the multilateral provisions of the WTO even more than does the U.S.

    Of course, it must be nice for President Barack Obama to still be the guy at the Group of 20 afterparty who everyone wants to talk to. And it’s surely a boost to the ego for the U.S. ambassador to the United Nations to sit behind a country nameplate that is permanently screwed to the table in the Security Council. At the same time, being No. 1 makes you a target of abuse and criticism. Perhaps an America that is No. 2 would be more popular. Country polls conducted for the BBC suggest that America’s image abroad has improved markedly since 2007, when it came out only marginally ahead of North Korea and Iran, though it’s still way behind less powerful countries such as Canada and Germany. Meanwhile, China’s popularity ratings have been falling since 2005, perhaps in part a reflection of its growing economic muscle.

    Ultimately, the best argument for Americans to let go of the idea of being No. 1 is that in the areas that really matter, we aren’t. When it comes to measures of the broader quality of life, the U.S. ranks in the bottom half of the OECD club of rich countries on such health indicators as life expectancy. It ranks around 15th worldwide in terms of the proportion of people who say they are happy, according to Jaime Díez Medrano, director of the World Values Survey archive. That puts the U.S. behind a bunch of small economies, including Norway, Ireland, Singapore, Switzerland, and (once again) Luxembourg.

    On the bright side, the U.S. still outperforms China on almost every conceivable quality-of-life indicator, including happiness polls (where China is in 70th place). The average American lives five years longer than the average Chinese person, while under-five mortality rates are less than half the Chinese levels. And though you may take a dim view of the abilities of Congress and the President to manage the economy—or even manage their way out of a paper bag—they remain the voters’ to throw out. The same cannot yet be said of the leadership of the Communist Party of China. So rather than wring their hands over the decline of the U.S.’s relative economic weight, Americans should remember the wisdom of the Founding Fathers and focus on preserving the country’s advantages in life, liberty, and the pursuit of happiness instead.

     

     

  • ie6,ie7兼容性总结

    2011-10-13 10:59:49

    其实浏览器的不兼容,我们往往是各个浏览器对于一些标准的定义不一致导致的,因此,我们可以进行一些初始化,很多问题都很轻松解决。

    下面是14条特殊情况仅供参考:

    1. 文字本身的大小不兼容。同样是font-size:14px的宋体文字,在不同浏览器下占的空间是不一样的,ie下实际占高16px,下留白3px,ff 下实际占高17px,上留白1px,下留白3px,opera下就更不一样了。解决方案:给文字设定 line-height 。确保所有文字都有默认的 line-height 值。这点很重要,在高度上我们不能容忍1px 的差异。

    2.ff下容器高度限定,即容器定义了height之后,容器边框的外形就确定了,不会被内容撑大,而ie下是会被内容撑大,高度限定失效。所以不要轻易给容器定义height。

    3.横向上的撑破容器问题,。如果float 容器未定义宽度,ff下内容会尽可能撑开容器宽度,ie下则会优先考虑内容折行。故,内容可能撑破的浮动容器需要定义width。

    小实验:有兴趣大家可以看看这段实验。在不同浏览器下分别测试以下各项代码。

    a.<div style=”border:1px solid red;height:10px”></div> b. <div style=”border:1px solid red;width:10px”></div>

    c. <div style=”border:1px solid red;float:left”></div> d. <div style=”border:1px solid red;overflow:hidden”></div>

    上面的代码在不同浏览器中是不一样的,实验起源于对小height 值div 的运用,<div style=”height:10px;overflow:hidden”></div>,小height 值要配合overflow:hidden一起使用。实验好玩而已,想说明的是,浏览器对容器的边界解释是大不相同的,容器内容的影响结果各不相同。


    4.最被痛恨的,double-margin bug。ie6下给浮动容器定义margin-left 或者margin-right 实际效果是数值的2倍。解决方案,给浮动容器定义display:inline。

    5.mirror margin bug,当外层元素内有float元素时,外层元素如定义margin-top:14px,将自动生成margin-bottom:14px。 padding也会出现类似问题,都是ie6下的特产,该类bug 出现的情况较为复杂,远不只这一种出现条件,还没系统整理。解决方案:外层元素设定border 或 设定float。

    引申:ff 和ie 下对容器的margin-bottom,padding-bottom的解释有时不一致,似乎与之相关。

    6. 吞吃现象。还是ie6,上下两个div,上面的div设置背景,却发现下面没有设置背景的div 也有了背景,这就是吞吃现象。对应上面的背景吞吃现象,还有滚动下边框缺失的现象。解决方案:使用zoom:1。这个zoom好象是专门为解决ie6 bug而生的。

    7.注释也能产生bug~~~“多出来的一只猪。”这是前人总结这个bug使用的文案,ie6的这个bug 下,大家会在页面看到猪字出现两遍,重复的内容量因注释的多少而变。解决方案:用“<!–[if !IE]> picRotate start <![endif]–>”方法写注释。


    8.img 下的留白,大家看这段代码有啥问题:

    <div>
    <img src=”" mce_src=”" />
    </div>

    把div的border打开,你发现图片底部不是紧贴着容器底部的,是img后面的空白字符造成,要消除必须这样写

    <div>
    <img src=”" mce_src=”" /></div>

    后面两个标签要紧挨着。ie7下这个bug 依然存在。解决方案:给img设定 display:block。

    9. 失去line-height。<div style=”line-height:20px”><img />文字</div>,很遗憾,在ie6下单行文字 line-height 效果消失了。。。,原因是<img />这个inline-block元素和inline元素写在一起了。解决方案:让img 和文字都 float起来。

    引申:大家知道img 的align 有 text-top,middle,absmiddle啊什么的,你可以尝试去调整img 和文字让他们在ie和ff下能一致,你会发现怎么调都不会让你满意。索性让img 和文字都 float起来,用margin 调整。


    10.clear层应该单独使用。也许你为了节省代码把clear属性直接放到下面的一个内容层,这样有问题,不仅仅是ff和op下失去margin效果,ie下某些margin值也会失效
    <div style=”background:red;float:left;”>dd</div>
    <div style=”clear:both;margin-top:18px;background:green”>ff</div>

    11.ie 下overflow:hidden对其下的绝对层position:absolute或者相对层 position:relative无效。解决方案:给overflow:hidden加position:relative或者position: absolute。另,ie6支持overflow-x或者overflow-y的特性,ie7、ff不支持。

    12.ie6下严重的bug,float元素如没定义宽度,内部如有div定义了height或zoom:1,这个div就会占满一整行,即使你给了宽度。float元素如果作为布局用或复杂的容器,都要给个宽度的。

    13.ie6下的bug,绝对定位的div下包含相对定位的div,如果给内层相对定位的div高度height具体值,内层相对层将具有100%的width值,外层绝对层将被撑大。解决方案给内层相对层float属性。

    14.width:100%这个东西在ie里用很方便,会向上逐层搜索width值,忽视浮动层的影响,ff下搜索至浮动层结束,如此,只能给中间的所有浮动层加width:100%才行,累啊。opera这点倒学乖了跟了ie。

    -----------------------------------------------------------------------------------------------------------------

    ie的float bug(ie6,ie7)使前端工程师们为之困扰,最常见的现象就是:当浮动元素的父级元素在拖动滚动条的时候出现边框的缺失,对于此类问题的解决方案就是使浮动元素获得布局.

            在诸多的情况中,因为页面需要宽度自由伸缩而不能申明宽度为固定值,但我们可以设置*height:1%;,*在这里可谓是举足轻重,因为*只能被ie7及以下版本解析,ie8并不识别此类写法,所以可以使用这个写法来区别ie8和其他版本号的ie浏览器.对网上流行的ie8 beta1的hack,也算是一个补充.

            一些常用的hack测试

            * html  p {color:red;}           支持 IE6        不支持FF IE7 IE8b
            *+html p {color:red;}    支持 IE7 IE8b        不支持FF IE6
            p {*color:red;}                      支持 IE7 IE6        不支持FF IE8b

            IE8 中增加了 CSS3 中的子串匹配的属性选择器(substring matching attribute selectors),具体规则与正则中的匹配很相似:

            E[att^=’val’] //子串以’val’ 开始
            E[att$=’val’] //子串以’val’ 结束
            E[att*=’val’] //子串中包含’val’

            IE8 支持绝大多数基本的 CSS2.1 选择器,不支持的包括但不限于:[:first-line] 、[:first-letter]。
            对于 CSS2.1 中的 generated content 部分,即通过使用伪元素 :before 和 :after 添加文本内容,IE8 中支持 并未完全 。
            而对于几乎在其他浏览器中都支持的 opacity 和 RGBA ,IE8 中依旧没有支持。
            对于原来用来区分 IE 的 HACK 在 IE8 中基本失效(比如*property:value、*property:value等)。
            原有 IE 的 list-item whitespace bug 在 IE8 中依旧存在。 
            原有 IE 的 z-index bug 在 IE8 中依旧存在。
            IE8 中产生新的 bug:当 line-heigth 小于正常值时,超出的部分将被裁切掉。
            IE8 中依然不支持 display:table 。
            IE8 中依然不支持 border 的 transparent 值。
            IE8 中 @import 只支持三层嵌套。
            IE8中 border的 transparent 不被支持
            IE8中产生新的BUG:line-heigth BUG
            /*/p{ color:#1e90ff}/*/ 只针对IE8的hack,可以是属性也可以是类

    ------------------------------------------------------------------------------------------

    BUG描述:

    页面中某DIV使用了position:relative,结合top=-25px等元素定位。在FF和IE7下表现正常,但是在IE6中该DIV会随鼠标滚动而滚动。

     

    分析:

    这是IE6一个已知的BUG:当某position:relative元素 被带有overflow:auto/scroll属性的块级元素包含时,会表现出postion:absolute的行为。

     

    解决方法:

    1.为包含块元素添加属性position:relative

    2.把该元素的position:relative属性去掉,使用默认的static定位,并通过margin-top等属性实现类似的效果。

    ————————————————————————————————————————————————————————————————

    ie6的末日即将来临,对我们前端开发人员来说,无疑是一个慰藉人心的喜讯.但这个末日也并非朝日可至,所以我们还是争取最后的胜利,用各种hack和方法来规避ie6下双边距,背景透明,重复文字等等一堆bug.下面是转载自前端观察(译自http://www.sitepoint.com/)中的10个修复ie6下bug技巧:
    1. 使用DOCTYPE
    你应该在一直每个HTML文件的头部都使用DOCTYPE,并且我们推荐使用strict 版本,比如:

    <!DOCTYPE   HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

    或者,对于XHTML使用:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    你需要处理的最棘手的事情就是IE6进入quirks模式——它已经够诡异了。
    2. 设置position: relative
    将一个元素设置为”position:relative”可以解决很多问题,特别是你曾经遇到隐藏的或对齐诡异的盒子。显然,你需要非常小心点儿,因为绝对定位的子节点可能会因此重新定位。
    3. 将浮动元素设置为display:inline
    具有margin属性的浮动元素可能引起著名的IE6双倍margin问题,比如,你为一个元素指定margin-left为5px,但是IE6中实际上却表现为10px。”display:inline”将解决这个问题,尽管这不是必须的,你的CSS仍然是有效的。
    4. 将一个元素设置为hasLayout
    很多IE6(和IE7)的渲染问题可以通过设置元素的hasLayout来解决。 这是一个IE内部属性(IE隐藏的,更多关于haslayout的资料,可以参阅这里),用来确定相对于其他元素,内容是如何布局和定位的。如果你需要设置一个inline元素(比如一个链接)为block元素,或者是应用透明效果,设置hasLayout也可能是必须的。
    最简单的设置hasLayout的方法是为CSS设置一个高度或宽度(zoom也可以用,但是zoom并不是CSS标准的一部分)。我们推荐设置实际尺寸,但是问题是这是不现实的,你可能需要使用”height:1%”。如果父元素并没有设置高度,该元素的实际高度并不受影响,而且这个时候hasLayout已经被启用。
    5. 修正重复文字bug
    复杂的布局可以触发在浮动元素的最后一些字符可能出现在出现在清除元素下面的bug。这里有几个解决方法,有些是完美的,但是做一些反复试验也是必须的:
             .确保所有的元素使用”display:inline;”
             .在最后一个元素上使用一个”margin-right:-3px;”
             .为浮动元素的最后一个条目使用一个条件注释,比如:

    <!--[if !IE]>Put your commentary in here...<![endif]-->

             .在容器的最后元素使用一个空的div(它也有必要设置宽度为90%或类似宽度。
    >>>>>>你还可以访问positioniseverything.net 查看该问题的完整介绍。
    6. 在可点击和悬停的元素上只使用<a>标签
    IE6只认识对a标签的CSS hover效果。
    你也可以在基于JavaScript的组件内使用他们来控制,以使他们保持键盘的可操作性。是有一些可替代的选择,但是<a>标签比其它方案更可靠。
    7. 使用!important 或高级选择器来区分IE6
    不使用传统Hack或在额外文件中的条件CSS的方法,写出特别针对IE6的可行的代码也还是有可能的。比如最小高度可以通过这段代码来定义:

    #element {
         min-height: 20em;
         height: auto !important; /* 所有浏览器都理解这段代码 */
         height: 20em; /* IE6 错误的使用这个值 /*
    }


    IE6 不理解min-height并错误的用20em覆盖”auto”高度,但是,如果内容需要更多的空间的话,它会自动增加高度。
    另外一个可选的方法是使用高级选择器,比如e.g.

    #element {
         min-height: 20em;
         height: 20em;
    }
    /* IE6 无视下面的代码*/
    #element[id] {
         height: auto;
    }


    8. 避免百分比单位
    百分比会把IE搞糊涂的。除非你可以确切的控制每一个父元素的大小,才可能做到最佳预防。你可以通过!important在其他浏览器中继续使用百分比,比如:

    body {
         margin: 2% 0 !important;
         margin: 20px 0; /* IE6 only */
    }

    9. 尽早测试并不断测试
    不要等到你的网站或应用完成了才测试IE6;这样的话问题可能更糟糕,而且会花更多时间来修正。如果你的网站能够在Firefox和IE6中正常运行,那么一般在其它浏览器就不会有问题。
    10. 重构你的代码
    经常发生的事情是,修正bug要比重新考虑一个布局问题要花更长的时间。对HTML做些小改动和一些简单的CSS常常更有效。这可能意味着你要放弃完美的代码,但是会出现较少的长期问题而且将来你会很清楚如果处理这些可能出现的问题。

    -------------------------------------------------------------------------------------------------------

    让IE6支持PNG格式的图片

    用法:

           
    先复制下面的代码在记事本中,然后另存为pngbehavior.htc(名字可以任意):

    <public:component lightWeight="true">
    <public:attach event="onpropertychange" nevent="propertyChanged()" />
    <public:attach event="onbeforeprint" nevent="beforePrint()" for="window"/>
    <public:attach event="onafterprint" nevent="afterPrint()" for="window"/>
    <script>

    /*
    * PNG Behavior
    *
    * This script. was created by Erik Arvidsson (http://webfx.eae.net/contact.html#erik)
    * for WebFX (http://webfx.eae.net)
    * Copyright 2002-2004
    *
    * For usage see license at http://webfx.eae.net/license.html
    *
    * Version: 1.02
    * Created: 2001-??-??    First working version
    * Updated: 2002-03-28    Fixed issue when starting with a non png image and
    *                      switching between non png images
    *          2003-01-06    Fixed RegExp to correctly work with IE 5.0x
    *          2004-05-09 When printing revert to original
    *
    */

    var supported = /MSIE ((5\.5)|[6789])/.test(navigator.userAgent) &&
                    navigator.platform. == "Win32";

    var realSrc;
    var blankSrc = "blank.gif";
    var isPrinting = false;

    if (supported) fixImage();

    function propertyChanged() {
        if (!supported || isPrinting) return;

        var pName = event.propertyName;
        if (pName != "src") return;
        // if not set to blank
        if (!new RegExp(blankSrc).test(src))
            fixImage();
    };

    function fixImage() {
        // get src
        var src = element.src;

        // check for real change
        if (src == realSrc && /\.png$/i.test(src)) {
            element.src = blankSrc;
            return;
        }

        if ( ! new RegExp(blankSrc).test(src)) {
            // backup old src
            realSrc = src;
        }

        // test for png
        if (/\.png$/i.test(realSrc)) {
            // set blank image
            element.src = blankSrc;
            // set filter
            element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft." +
                        "AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
        }
        else {
            // remove filter
            element.runtimeStyle.filter = "";
        }
    }

    function beforePrint() {
        isPrinting = true;
        element.src = realSrc;
        element.runtimeStyle.filter = "";
        realSrc = null;
    }

    function afterPrint() {
        isPrinting = false;
        fixImage();
    }

    </script>
    </public:component>


            最后在你的css文件里面加上这么一段代码:

    img {
    behavior. url("pngbehavior.htc");
    }
     
    http://www.cnblogs.com/li0803/archive/2009/08/22/1552094.html
  • In search of the American Dream - in China

    2011-10-13 09:48:05

    (CBS News) 

    SHANGHAI - Every day, Ben Paul bikes to work at a Shanghai advertising agency. CBS News correspondent Celia Hatton reports it's a major change from 2009, when he was laid off in Los Angeles.

    "Job hunting in L.A. was really disheartening(使人沮丧的)," he explained. "One, because there's very little to look for in the first place and the really hard thing was that you almost don't hear back or at least I almost didn't hear back from anyone."

    After six months of looking for a job in America, Ben and his wife, Arcelia, gave China a try.

    They made the right decision. Arcelia was in high demand as a therapist for autistic (孤独症患者(常指儿童))children despite having no Chinese language skills. It took Ben just a month to land the senior position he always wanted, even though he only speaks conversational Mandarin.

    More than 71,000 Americans work in China as permanent residents, and hundreds of thousands more are employed under temporary visas. China's leadership is smoothing the way for more white-collar foreign workers to arrive by easing the visa process and extending Chinese social security to all.

    "If you can show people you have the kind of skills that might not show up on your resume," Ben said, "but you believe in yourself, that you have them, there will be someone here that will be willing to listen to you."

    Ben has had a relatively easy ride but not everyone is so fortunate. Americans who come to China searching for jobs have to compete with a growing number of well-educated Chinese people. Six million new college graduates flood China's job market every year.

    "Here in China I really think I can get into a company as they're starting to expand," Pennsylvania native Phil Geanacopolous said. Geanacopoulos has yet to find a job. Every day, he's hitting the pavement in Shanghai, resume in hand, looking to match his ambitions. "If I prove myself within one or two years I can be the executive vice president or head of marketing."

    Geanacopolous is studying Chinese to improve hs prospects and his eventual paycheck. And in China, a salary that may be small by U.S. standards can support a comfortable lifestyle.

    And that's key - Ben and Arcelia miss their family and friends back home, but the trade-off's worth it to benefit from China's growing economy.

     

    http://www.cbsnews.com/stories/2011/10/11/eveningnews/main20118864.shtml

  • 271/212>

    数据统计

    • 访问量: 9970
    • 日志数: 32
    • 建立时间: 2007-07-26
    • 更新时间: 2012-12-27

    RSS订阅

    Open Toolbar