文档库 最新最全的文档下载
当前位置:文档库 › Selenium Notice

Selenium Notice

Selenium Notice
Selenium Notice

1.使用Selenium IDE录制完成后,导出java代码,使用Junit4(WebDriver)格式。

2.使用Selenium IDE转化成java测试代码,命名以Test结尾。

eg: UserLoginTest.java

3.所有Junit测试用例需要继承基类

Admin test case:

extends BaseAdminClass

User test case:

extends BaseUserClass

4.删除Seleniun IDE自动生成的@Before setUp()和@After tearDown()函数,保留@Test函数。

5.删除Seleniun IDE自动生成的成员定义driver,baseUrl

privateWebDriver driver;

private String baseUrl;

6.文件,类和方法的注释:

类需要包括作者和对应T estLink里的Test case ID。

/**

* @author Carol.Jia

* @TestCaseID1-4616

*/

The comments setting Path in Java:

Window->Preferences->Java->Code Style->Code Templates

Import the file codetemplates.xml, then use ‘Shift+Alt+J’ can easily add comments in java file.

7.引用到的字符需要从资源文件取得。

a) 查找资源文件,得到所要的key(注意check中英文):

WebCommonResource _en_US.properties --WCR_XXX

ValidationResource_en_US.properties --VAR_XXX

TextResource _en_US.properties --TER_XXX

b) 取得key对应的字符串:

String strResourse = ge.getResourse("WCR_VIEW_LOCATION");

8.数据配置文件的使用

Properties文件路径:src/com/TestData

eg:

Properties properties = new Properties();

try {

properties.load(BaseAdminClass.class.getResourceAsStream("/com /TestData/LoginData.properties"));

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

properties.get("ADMIN_USER_NAME"));

9.同一case执行多次Eg:AddLocationTest.java。

10.Before do the automatic test, change window.isDebug = false to window.isDebug = true in login.jsp, default.jsp, adminlogin.jsp, adminmain.jsp

10.253.125.6

/opt/apache-tomcat-6.0.26/webapps/WealthStationGlobal

11.使用class控件定位方法,以x-test-开头

Eg:css=.x-test-background

12.注意中英文的输入格式不一样,如birthday En: "05/10/1977",CN:"1977-05-10"

13.语言,服务器等配置文件:

InitialConfig.properties

14.脚本运行出错时,出错页面屏幕拷贝方法实现。

When excusing the test case, if the test case failed, a Screenshot can be generated, if the test case is passed, the Screenshot won’t be generated.

The output Path of Screenshot:Java class path

\report\Screenshot\ClassName_MethodName_CurrentTime.jpg

Please update the source in SVN.

Steps(This should be add for all the test cases):

Step1: Import this class: import com.Core.CaptureScreenshot;

Step2: At the beginning of @Test Method get the Screenshot name.

Step3: At the Ending of @Test Method set the print flag “PrintFlag” to false.

相关文档