如何用 Selenium RC 进行自动化测试

2025-05-14 08:27:11

1、打开eclipse,新建一个项目tests,点击File—>New —> Java Project,输入Project name 为 tests,JRE选择Use a project specific JRE,选择jre6,点击Finish。

如何用 Selenium RC 进行自动化测试如何用 Selenium RC 进行自动化测试如何用 Selenium RC 进行自动化测试

4、用selenium IDE 录制脚本,并将代码导出为junit 4类型的代码,保存为login.java。

如何用 Selenium RC 进行自动化测试

6、将selenium IDE里导出的login.java文件,导入到com.example.tests包里。代码内容如下:packagecom.example.tests;importcom.thoughtworks.selenium.*;importorg.junit.After;importorg.junit.Before;importorg.junit.Test;importstaticorg.junit.Assert.*;importjava.util.regex.Pattern;publicclasslogin{privateSeleniumselenium;@BeforepublicvoidsetUp()throwsException{selenium=newDefaultSelenium("localhost",4444,"*chrome","http://test.51ebill.com:55554/ebillwww/manage/login.in");selenium.start();}@TestpublicvoidtestLogin()throwsException{selenium.open("/ebillwww/manage/login.in");selenium.type("id=name","yuguotai");selenium.type("id=psw","88@88.com");selenium.click("id=submitForm");selenium.waitForPageToLoad("30000");selenium.click("link=[退出]");selenium.waitForPageToLoad("30000");}@AfterpublicvoidtearDown()throwsException{selenium.stop();}}

如何用 Selenium RC 进行自动化测试

8、cd 定位到…selenium-remote-control-1.0.3\selenium-server-1.0.3>目录下。

如何用 Selenium RC 进行自动化测试

10、使用eclipse运行login.java文件,当浏览器为默认chrome浏览器时,无法调用。

如何用 Selenium RC 进行自动化测试

12、当浏览器选择为iexplore时,能够正确调到浏览器进行运行。

如何用 Selenium RC 进行自动化测试如何用 Selenium RC 进行自动化测试
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢