YONGFEIUALL

izheyi.com


  • Home

  • Archives

  • Categories

  • Tags

  • About

  • Search

QTP菜单项消失

Posted on 2013-02-09 | In QTP |

有时候QTP的菜单栏的下拉菜单为空。

解决方法:

在菜单栏点击右键,选择“Customize”,在Customize窗口的ToolBarTab页,点击“Restore All”后即可。

VSTO 操作Excel 的常用属性

Posted on 2013-01-10 | In Excel |

生成excel的时候有时候需要设置单元格的一些属性,可以参考一下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
range.NumberFormatLocal = "@";     //设置单元格格式为文本 

range = (Range)worksheet.get_Range("A1", "E1"); //获取Excel多个单元格区域:本例做为Excel表头

range.Merge(0); //单元格合并动作

worksheet.Cells[1, 1] = "Excel单元格赋值"; //Excel单元格赋值

range.Font.Size = 15; //设置字体大小

range.Font.Underline=true; //设置字体是否有下划线

range.Font.Name="黑体"; 设置字体的种类

range.HorizontalAlignment=XlHAlign.xlHAlignCenter; //设置字体在单元格内的对其方式

range.ColumnWidth=15; //设置单元格的宽度

range.Cells.Interior.Color=System.Drawing.Color.FromArgb(255,204,153).ToArgb(); //设置单元格的背景色

range.Borders.LineStyle=1; //设置单元格边框的粗细

range.BorderAround(XlLineStyle.xlContinuous,XlBorderWeight.xlThick,XlColorIndex.xlColorIndexAutomatic,System.Drawing.Color.Black.ToArgb()); //给单元格加边框

range.EntireColumn.AutoFit(); //自动调整列宽

Range.HorizontalAlignment= xlCenter; // 文本水平居中方式

Range.VerticalAlignment= xlCenter //文本垂直居中方式

Range.WrapText=true; //文本自动换行

Range.Interior.ColorIndex=39; //填充颜色为淡紫色

Range.Font.Color=clBlue; //字体颜色

xlsApp.DisplayAlerts=false; //保存Excel的时候,不弹出是否保存的窗口直接进行保存

workbook.SaveCopyAs(temp);/**////填入完信息之后另存到路径及文件名字

Excel Format(格式)的设置

Posted on 2013-01-10 | In Excel |
1
2
3
4
5
6
7
8
9
10
11
12
oExcel.RANGE(oExcel.Cells(1,1),oExcel.Cells(nRows,nColumns)).BORDERS.LineStyle=1
oExcel.RANGE(oExcel.Cells(1,1),oExcel.Cells(nRows,nColumns)).HorizontalAlignment=3 &&水平(1-默认、2-靠左、3-居中、4-靠右、5-填充、6=两端对齐、7=跨列居中、8=分散对齐)
oExcel.RANGE(oExcel.Cells(1,1),oExcel.Cells(nRows,nColumns)).VerticalAlignment=2 &&垂直(1=靠上、2=居中、3=靠下、4=两端对齐、5=分散对齐)
oExcel.ActiveSheet.PageSetup.RightFooter="第&P页 / 共&N页"
oExcel.ActiveSheet.PageSetup.TopMargin=2/0.035 &&设置顶边距为2厘米
oExcel.ActiveSheet.PageSetup.BottomMargin=2/0.035 &&设置左边距为2厘米
oExcel.ActiveSheet.PageSetup.HeaderMargin=1/0.035 &&设置页眉到顶端边距为1厘米
oExcel.ActiveSheet.PageSetup.FooterMargin=1/0.035 &&设置页脚到底边距为1厘米
oExcel.ActiveSheet.PageSetup.LeftMargin=2/0.035 &&设置左边距为2厘米
oExcel.ActiveSheet.PageSetup.RightMargin=2/0.035 &&设置右边距为2厘米
oExcel.ActiveSheet.PageSetup.CenterHorizontally=.t. &&设置页面水平居中
oExcel.ActiveSheet.PageSetup.CenterVertically=.t. &&设置页面垂直居中

Find a File Recursively(递归查找文件)

Posted on 2013-01-10 | In VBS |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'-----------------------------------------------------------------------
  'Function: FindFileRecursively
  'Finds the first instance of a file within the root folder or one of its subfolders
  '
  'Remarks:
  '   Uses recursion
  '
  'Arguments
  '   ByVal strRootFolder - As String (absolute folder)
  '   ByVal strFilename - As String
  '
  'Returns:
  '   String with full file pathname based on root folder and file name
  '
  'Owner:
  '
  'Date:
  '
  '-----------------------------------------------------------------------    
   Public Function FindFileRecursively(ByVal strRootFolder, ByVal strFilename)
      Dim FSO    
      Dim strFullPathToSearch    
      Dim objSubFolders, subfolder    
   
      Set FSO = CreateObject("Scripting.FileSystemObject")    
      'Initialize function    
      FindFileRecursively = ""    
      'Check that filename is not empty    
      If strFileName = "" Then Exit Function    
      'Get full file pathname    
      strFullPathToSearch = strRootFolder & "\" & strFilename    
      'Check if root folder exists    
      If FSO.FolderExists(strRootFolder) Then        
          'Check if file exists under root folder        
          If FSO.FileExists(strFullPathToSearch) Then            
              FindFileRecursively = strFullPathToSearch        
          Else            
              'Get subfolders            
              Set objSubFolders = FSO.GetFolder(strRootFolder).SubFolders            
              For Each subfolder in objSubFolders                
                  strFullPathToSearch = strRootFolder & "\" & subfolder.name                
                  FindFileRecursively = FindFileRecursively(strFullPathToSearch, strFilename)                
                  If FindFileRecursively <> "" Then                    
                      Exit For                
                  End If            
              Next        
          End If    
      End If
  End Function

Random WebList & Write to Report(随机选择Weblist并写入测试报告)

Posted on 2013-01-10 | In QTP |
1
2
3
4
5
6
7
8
9
' 用 封装"items count" 属性来获取WebList下有几个选项
itemCount =  Browser("XXX").Page("XXX|").WebList("XXX").GetROProperty("items count")

' 用RandomNumber随机选取范围内的index
tValue = RandomNumber(0, itemCount - 1)
Browser("XXX").Page("XXX").WebList("XXX").Select tValue

' 将随机选择的结果写入测试报告
Reporter.ReportEvent micDone, "本次运行随机选择了INDEX: <" & tValue & ">", " "

使用Excel 2007完成多人协同录入工作

Posted on 2013-01-09 | In Excel |

下面我们来介绍下Excel 2007的共享功能。

Read more »

QTP使用小提示

Posted on 2013-01-09 | In QTP |

不要使用Reuable Action

  用Function,不要用Reusable Action。没有一种通用的语言里有Reusable Action这个概念。而且通过Function等一些标准的程序设计语言的元素,你能够实现任何Reusable Action可以实现的功能,而且更好,更快,更易于维护。

不要用Smart Identification

   有一天,我发现一个奇怪的现象,一个testcase里某一个点击logout button的步骤运行非常慢,大概要20秒,但是最终它还能成功点击。不巧的是每一个testcase几乎都会点击这个button,所有我还必须把这个问题找出来。最后发现这是因为button的name有了变化,但是因为Smart Identification是被enable,所以QTP会试图去适应这个变化,但是这个“适应”的效果非常不理想。

  我认为测试开发者应该完全控制对象的识别。把选择权交给对被测程序业务一无所知的工具是毫无道理的。我想不到任何使用SmartIdentification的原因。所以,从那之后,任何Testcase的Smart Identification我都禁止了。

不要在base目录里添加两个或以上目录

  Base目录是用来只能识别相对路径的目录。其配置在Menu: Tools->Options->Folders。我的建议是这里只放项目根目录。其他目录都不要放进去。

不要用keyword view,而是提供业务逻辑封装层

  如果你要让你的testcase简单,直接,那么你应该通过合理的抽象提供完善的业务逻辑封装层,它会使得你的testcase script读起来像testcase descript一样。这个时候,你根本不需要keyword view。

VBS Adding Quotes(为字符串加双引号)

Posted on 2013-01-05 | In VBS |
1
newSAtr = Chr( 34 ) & Environment( "ProductDir" ) & Chr( 34 )

Execute Result

QTP添加Resource或Action时,不弹出相关路径窗

Posted on 2012-12-31 | In QTP |

在以下步骤中设置:

“Options -> Folders” 页面,选中底部的选择框“Remind me to ….”

Java设置环境变量

Posted on 2012-11-19 | In Java |

path,当要求系统运行一个程序而没有告诉它程序所在的完整路径时,系统除了在当前目录下面寻找此程序外,还应到path中指定的路径去找。用户通过设置环境变量,来更好的运行进程。

环境变量配置步骤:

  1. 首先下载安装JDK安装包。
  2. 打开我的电脑–属性–高级–环境变量。
  3. 新建系统变量JAVA_HOME 和CLASSPATH
    变量名:JAVA_HOME
    变量值:C:\Program Files (x86)\Java\jdk1.7
    变量名:CLASSPATH
    变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
    其中变量值为你自己安装jdk的文件目录这里要注意。
  4. 选择“系统变量”中变量名为“Path”的环境变量,双击该变量,把JDK安装路径中bin目录的绝对路径,添加到Path变量的值中。
    变量名:Path
    变量值:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
  5. 现在测试环境变量的配置成功与否。在DOS命令行窗口输入“JAVAC”,输出帮助信息即为配置正确。
1…37383940
唐胡璐

唐胡璐

i just wanna live while i am alive

393 posts
42 categories
74 tags
RSS
LinkedIn Weibo GitHub E-Mail
Creative Commons
© 2022 唐胡璐
Powered by Hexo
|
Theme — NexT.Pisces v5.1.4