使用selenim作为项目测试框架,适用asp.net c# 网站测试
来源:互联网 发布:npm install 淘宝镜像 编辑:程序博客网 时间:2024/04/29 07:29
第一步:
下载 selenium-remote-control-1.0-beta-1,解压缩,
第二步:
做个批处理文件启动测试服务器,批处理文件内容:
java -jar E:/selenium/selenium-remote-control-1.0-beta-1-dist/selenium-remote-control-1.0-beta-1/selenium-server-1.0-beta-1/selenium-server.jar
以后,双击bat文件,直接启动测试服务器。
第三步:编写测试用例
使用c#控制台程序,建立测试框架平台
public class CaiHaoTest { private ISelenium selenium;
public void Start() { selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.caihao.com"); selenium.Start(); }
public void stop() { selenium.Stop(); }
/// <summary> /// 验证登录 /// </summary> public void Login() { selenium.Open("http://www.caihao.com");
selenium.Type("tbUserName", "wuzhi"); selenium.Type("tbPassword", "11111111");
selenium.Click("btnLogin"); Thread.Sleep(1000);//等待页面加载完 Console.WriteLine("登录测试————"+(selenium.IsTextPresent("安全退出")?"通过":"未通过")); }
/// <summary> /// 验证个人会员功能 /// 注册,简历设计, /// </summary> public void ValidatePerson() { selenium.Open("http://www.caihao.com"); selenium.Click("xpath=//a[@href='http://www.caihao.com/Ps/Registration.aspx']");
selenium.WaitForPageToLoad("3000"); //selenium.Open("http://www.caihao.com/Ps/Registration.aspx"); DateTime now=DateTime.Now; Thread.Sleep(1000); string userName = "test" + now.Day+now.Hour+now.Second; string nickName = "昵称" + now.Day + now.Hour + now.Second; ; selenium.Type("txtUserName", userName);
selenium.Type("txtNick", nickName); selenium.Type("txtPassword", "11111111"); selenium.Type("txtConfirmPassword", "11111111"); Thread.Sleep(10); selenium.Click("btRegistration"); Thread.Sleep(1000);//等待页面加载完
selenium.Open("http://www.caihao.com/Ps/index.aspx"); Console.WriteLine("个人会员注册测试————" + (selenium.IsTextPresent(nickName) ? "通过" : "未通过")); selenium.Click("xpath=//a[@href='http://www.caihao.com/ps/rsm/PersonalInfo.aspx']");
selenium.WaitForPageToLoad("3000");
//简历设计 selenium.Type("tbFullName", "张飞" + now.Day); selenium.Check("rblGender_0"); selenium.Select("ddlDegree", "index=1"); selenium.Select("ddlSpecialType", "index=1"); selenium.Type("tbSpecialName", "电子科技专业名称"+now.Day); selenium.Select("ddlGraduateYear", "index=20"); selenium.Select("ddlGraduateMonth", "index=10"); selenium.Select("ddlLinkType", "index=1"); selenium.Type("tbLink", "1389999911"); selenium.Click("btnSaveAndNext"); Console.WriteLine("个人会员简历信息设计测试通过");
selenium.WaitForPageToLoad("3000"); //教育背景 http://www.caihao.com/ps/rsm/EducationStory.aspx selenium.Type("tbSchool", "毕业学校" + now.Day); selenium.Select("ddlDegree","index=2"); selenium.Select("ddlBeginYear", "index=20"); selenium.Select("ddlBeginMonth", "index=1"); selenium.Select("ddlSpecialType", "index=1" ); selenium.Select("ddlEndYear", "index=5"); selenium.Select("ddlEndMonth", "index=10"); selenium.Type("tbSpecial", "专业名称"+now.Day);
selenium.Type("tbDescription", "专业描述"+now); selenium.Click("btnSave"); Console.WriteLine("-----------------个人会员简历信息教育背景设计测试通过-----------------"); selenium.WaitForPageToLoad("3000"); //求职意向 if (selenium.IsTextPresent("您还需要填写求职意向")) selenium.Click("xpath=//a[@href='http://www.caihao.com/ps/rsm/Intent.aspx']"); else { Console.WriteLine("-----------------个人会员简历信息教育背景设计测试没有通过!-----------------"); } //selenium.Type("tbWorkYears", "10"); selenium.WaitForPopUp("Industry_panleIndustry","300"); //selenium.w("3000"); selenium.Select("ddlBeginMonth", "index=1"); selenium.Select("ddlSpecialType", "index=1"); selenium.Select("ddlEndYear", "index=5"); selenium.Select("ddlEndMonth", "index=10");
// selenium.WaitForPageToLoad("3000");
} }}
- 使用selenim作为项目测试框架,适用asp.net c# 网站测试
- Selenim IDE测试环境搭建
- 使用NetBox测试ASP网站
- ASP.NET网站压力测试简述
- c# asp.net 测试程序执行时间
- 使用selenium进行web测试项目框架
- webservice项目开发测试 使用xfire框架
- asp.net网站框架
- ASP.NET压力测试
- asp.net 测试代码
- ASP.NET测试
- 把ASP.NET项目发布到IIS服务器上后,测试显示此问题,无法浏览网站的原因
- 从零开始写C# MVC框架之--- 使用Areas分离ASP.NET MVC项目
- ASP.NET MVC5 网站开发实践(一) - 项目框架
- ASP.NET WinForm C# 上传文件测试代码。
- c# asp.net 新建项目与新建网站区别
- 微软ASP.NET站点部署指南(5):部署到IIS上作为测试环境
- 微软ASP.NET站点部署指南(5):部署到IIS上作为测试环境
- DirectDraw Application & Driver for WinCE
- Windows完成端口与Linux epoll技术简介 1
- 我的生活我做主
- C#3.5语言新特性(三)-匿名类型
- struts2.0学习
- 使用selenim作为项目测试框架,适用asp.net c# 网站测试
- 在应用中嵌入Python
- oracle优化- 索引
- 期货交易与现货交易远期交易的关系
- 使用C#的Timer控件来实现定时触发事件
- JavaScript:设为首页-加入收藏-联系我们的代码
- 如何贯彻执行oop的设计理念
- how to test a file 's existence
- C#3.5语言新特性(四)-扩展方法