大佬教程收集整理的这篇文章主要介绍了asp.net – 如何使我的硒测试不那么脆弱?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我发现测试非常脆弱,不仅仅是通过实际更改页面的代码更改,而且还通过无害重构(如重命名控件)(因为我需要将控件的clientID传递给SELEnium的Click方法等)或替换具有中继器的gridview。因此,我发现自己在我的测试用例中“浪费”时间更新字符串值,以修复断开的测试。
有没有办法编写更可维护的硒测试?还是更好的网络UI测试工具?
编辑添加:@H_675_7@通常,第一稿是通过在IDE中记录测试来创建的。 (这个第一步可以由QA的工作人员执行。)然后我重构生成的C#代码(提取常量,重复代码的提取方法,可能会重复不同数据的测试用例等)。但是,每个测试用例的代码的一般流程仍然与原始生成的代码相当接近。
http://code.google.com/p/webdriver/wiki/PageObjects
更多信息:@H_675_7@ – What’s the Point of Selenium?@H_675_7@ – Selenium Critique
我用同样的场景你有硒c#
这是我的代码如何:
测试方法看起来像这样的东西
[TestMethod] public void RegisterSpecialist(UserInfo usrInfo,CompanyInfo companyInfo) { var RegistrationPage = new PublicRegistrationPage(SELEnium) .FillUserInfo(usrInfo) .ConTinueSecondStep(); RegistrationPage.FillCompanyInfo(companyInfo).ConTinueLastStep(); RegistrationPage.FillSecurityInformation(usrInfo).ConTinueFinishLastStep(); Assert.IsTrue(RegistrationPage.VerifySpecialistRegistrationmessagePayPal()); SELEnium.WaitForPageToLoad(resources.Globalresources.TimeOut); paypal.LoginSandboxPage(usrInfo.sandboxaccount,usrInfo.sandboxpwd); Assert.IsTrue(paypal.Verifyamount(usrInfo)); paypal.SubmitPayment(); RegistrationPage.GetSpecialisTinformation(usrInfo); var bphome = new BPHomePage(SELEnium,String.Format(resources.Globalresources.LoginBPHomePage,usrInfo.AccountName,usrInfo.password)); Assert.IsTrue(bphome.VerifyPageWasLoaded(usrInfo)); Assert.IsTrue(bphome.VerifySpecialistProfile()); bphome.Logout(); }
页面对象将是这样的
public class PublicRegistrationPage { public ISELEnium SELEnium { get; set; } #region Constructors public PublicRegistrationPage(ISELEnium sel) { SELEnium = sel; SELEnium.Open(resources.Globalresources.PublicRegisterURL); } #endregion #region Methods public PublicRegistrationPage FillUserInfo(UserInfo usr) { SELEnium.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserFirstName",usr.FirstName); SELEnium.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserLastName",usr.lastName); SELEnium.SELEct("ctl00_cphComponent_ctlContent_wizRegister_ddlUserCountry",String.Format("label={0}",usr.Country )); SELEnium.WaitForPageToLoad(resources.Globalresources.TimeOut); SELEnium.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserEmail",usr.Email ); SELEnium.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserDirectTel",usr.DirectTel); SELEnium.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserMobile",usr.MobilE); return this; }
}
希望这可以帮助。
以上是大佬教程为你收集整理的asp.net – 如何使我的硒测试不那么脆弱?全部内容,希望文章能够帮你解决asp.net – 如何使我的硒测试不那么脆弱?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。