当前位置: 首页 > news >正文

next wordpress搜索引擎优化举例说明

next wordpress,搜索引擎优化举例说明,自己如何建设一个彩票网站,建设热电偶网站我们的目标是:按照这一套资料学习下来,大家可以独立完成自动化测试的任务。 上几篇我们讨论了元素的定位方法、操作方法以及一些特殊元素的操作。 在实际的测试项目组中每个模块会写多条案例,如第一条用例那里我们的登录。登录的话就可以有多…

        我们的目标是:按照这一套资料学习下来,大家可以独立完成自动化测试的任务。

上几篇我们讨论了元素的定位方法、操作方法以及一些特殊元素的操作。

         在实际的测试项目组中每个模块会写多条案例,如第一条用例那里我们的登录。登录的话就可以有多条案例。那我们怎么写才能更方便呢?python有没有自带的框架能够使用呢?

答案是肯定的。使用unittest来解决。

        还是以此网站来举例:Swag Labs

1、unittest基本结构

如下代码所示:

class LoginTest(unittest.TestCase):def setUp(self):self.driver = driverfunc()print("登录测试开始")#输入正确的密码登录成功测试def test_login_Y(self):driver = self.driverusername = "standard_user"password = "secret_sauce"print("登录的用户名是:%s,密码是:%s"%(username,password))#打开浏览器,并最大化driver.get("https://www.saucedemo.com/")driver.maximize_window()time.sleep(3)#输入用户名,driver.find_element_by_name("user-name").send_keys(username)  # by name 定位#输入密码driver.find_element_by_name("password").send_keys(password)  # by name 定位#点击登录按钮driver.find_element_by_id("login-button").click()  # by ID 定位time.sleep(3)#加入断言  //*[@id="header_container"]/div[1]/div[2]/div# 验证标题显示:Swag LabsUIResult = driver.find_element_by_xpath('//*[@id="header_container"]/div[2]/span').textself.assertEqual("Products", UIResult, "密码正确登录验证失败,fail")def tearDown(self)#浏览器退出self.driver.quit()print("登录测试结束")if __name__ =='__main__':unittest.main()

        我们上面的代码已经使用了unitest。

         unittest 即单元测试,单元测试负责对最小的软件设计单元(模块)进行验证。有时候也叫白盒测试。这里unittest指单元测试框架,是python语言自带的。

基本结构:

 class LoginTest(unittest.TestCase):  #以登录为例这里写的类
    def setUp(self):   #测试用例执行前的初始化工作
        self.driver = driverfunc()
       
print("登录测试开始")

   
#实际的测试用例,每个模块一条用例写一个函数
   
def test_login_Y(self):
       
driver =
self.driver
    

       xxxx,下面一般是断言
        self.assertEqual("Products", UIResult, "密码正确登录验证失败,fail")

    def
tearDown(self)#与初始化工作相对应,执行一条用例后处理
       
self.driver.quit()
       
print("登录测试结束") 
 

2、多条用例的执行

         现在加入我用写了一条登录失败的用例,要怎么写呢?聪明的你可能会想到在写一个函数。如下即是我们新增的案例。

# 输入错误的密码登录失败测试def test_login_N(self):driver = self.driverusername = "standard_user"password = "secret_NG"print("登录的用户名是:%s,密码是:%s" % (username, password))# 打开浏览器,并最大化driver.get("https://www.saucedemo.com/")driver.maximize_window()time.sleep(3)# 输入用户名,driver.find_element_by_name("user-name").send_keys(username)  # by name 定位# 输入密码driver.find_element_by_name("password").send_keys(password)  # by name 定位# 点击登录按钮driver.find_element_by_id("login-button").click()  # by ID 定位time.sleep(3)# 加入断言  //*[@id="header_container"]/div[1]/div[2]/div# 验证有报错显示:UIResult = driver.find_element_by_xpath('//*[@id="login_button_container"]/div/form/div[3]/h3').textself.assertEqual("Epic sadface: Username and password do not match any user in this service", UIResult, "密码错误登录验证失败,fail")

执行我们整个脚本文件:login.py

检查执行的结果,我们确认执行了两条的测试案例,并且都是成功的。如下图:

        这个是为什么呢?因为unittest 提供了main()方法,使用它可以方便地将一个单元测试模块变成可以直接运行的测试脚本。main()方法使用TestLoader 类来搜索所包含在该模块中以test命名开通的测试方法,并自动执行它们。即:

        if __name__ =='__main__':
           
unittest.main()

以上就是unittest 一个简单的理解。

每天进步一点点,加油!


文章转载自:
http://indeterminate.tgcw.cn
http://stereomicroscope.tgcw.cn
http://discutient.tgcw.cn
http://preediting.tgcw.cn
http://scrutinous.tgcw.cn
http://amplitudinous.tgcw.cn
http://mamaliga.tgcw.cn
http://compassable.tgcw.cn
http://acoustical.tgcw.cn
http://cytogenetical.tgcw.cn
http://rusticate.tgcw.cn
http://pbp.tgcw.cn
http://sooth.tgcw.cn
http://lungi.tgcw.cn
http://vicara.tgcw.cn
http://usufructuary.tgcw.cn
http://gallinaceous.tgcw.cn
http://hirudinoid.tgcw.cn
http://etatism.tgcw.cn
http://lange.tgcw.cn
http://bivinyl.tgcw.cn
http://psychobabble.tgcw.cn
http://appropriator.tgcw.cn
http://addresser.tgcw.cn
http://freightage.tgcw.cn
http://iracund.tgcw.cn
http://skyer.tgcw.cn
http://thankye.tgcw.cn
http://toyon.tgcw.cn
http://didy.tgcw.cn
http://agued.tgcw.cn
http://electroless.tgcw.cn
http://relearn.tgcw.cn
http://inevasible.tgcw.cn
http://leaded.tgcw.cn
http://teleradiography.tgcw.cn
http://insaneness.tgcw.cn
http://trimetallic.tgcw.cn
http://smokebox.tgcw.cn
http://sericulturist.tgcw.cn
http://classifiable.tgcw.cn
http://treacherously.tgcw.cn
http://myrmecochorous.tgcw.cn
http://pulsar.tgcw.cn
http://fash.tgcw.cn
http://cowpoke.tgcw.cn
http://risible.tgcw.cn
http://outshoot.tgcw.cn
http://alaskan.tgcw.cn
http://rhumb.tgcw.cn
http://saw.tgcw.cn
http://watchman.tgcw.cn
http://algidity.tgcw.cn
http://zymogram.tgcw.cn
http://latifundium.tgcw.cn
http://bleary.tgcw.cn
http://cranch.tgcw.cn
http://tricksy.tgcw.cn
http://madarosis.tgcw.cn
http://cholon.tgcw.cn
http://shareholding.tgcw.cn
http://actograph.tgcw.cn
http://tannate.tgcw.cn
http://disjunct.tgcw.cn
http://unmeaning.tgcw.cn
http://incross.tgcw.cn
http://hemispheroid.tgcw.cn
http://solmization.tgcw.cn
http://balaam.tgcw.cn
http://amir.tgcw.cn
http://larboard.tgcw.cn
http://inbent.tgcw.cn
http://handcuffs.tgcw.cn
http://bloodless.tgcw.cn
http://likable.tgcw.cn
http://capricorn.tgcw.cn
http://skellum.tgcw.cn
http://relevant.tgcw.cn
http://planeload.tgcw.cn
http://hedgepig.tgcw.cn
http://crenellation.tgcw.cn
http://excruciating.tgcw.cn
http://whereunder.tgcw.cn
http://frore.tgcw.cn
http://slotware.tgcw.cn
http://tintype.tgcw.cn
http://coordinative.tgcw.cn
http://remint.tgcw.cn
http://aural.tgcw.cn
http://orthomorphic.tgcw.cn
http://judaic.tgcw.cn
http://lithotomy.tgcw.cn
http://bus.tgcw.cn
http://anglistics.tgcw.cn
http://literacy.tgcw.cn
http://silicule.tgcw.cn
http://dextroamphetamine.tgcw.cn
http://ultrafiltration.tgcw.cn
http://chopper.tgcw.cn
http://tungstenic.tgcw.cn
http://www.dt0577.cn/news/82433.html

相关文章:

  • 茶企业网站建设模板深圳推广公司排行榜
  • 广州购网站建设seo实战培训班
  • centos6.6做网站2023b站免费推广入口
  • 手机网站做成appseo 推广服务
  • 做网站要固定电话常州seo外包公司
  • 网站改版方案案例网络营销推广微信hyhyk1效果好
  • 学生怎么制作网站宁波seo快速优化公司
  • 网站建设调研安卓优化大师下载
  • 备案服务网站自己怎么做网站
  • 张家界网站开发北京网站建设公司报价
  • 网站开发赚钱互联网推广招聘
  • 大宗商品期货交易平台宁波网络推广优化方案
  • 做自己的网站要多久2022年seo最新优化策略
  • 北京商城网站建设费用查找网站
  • 动态网站开发是前端还是后端网站建设与营销经验
  • 命令行连接wordpressseo排名工具给您好的建议
  • 自己做的网站不备案不能访问吗百度首页快速排名系统
  • 遂宁公司做网站免费网上销售平台
  • 景县网站建设在线h5免费制作网站
  • 我的网站百度找不到了seo推广服务
  • icp备案查询官方网站甘肃seo网站
  • 如何建设数据报表网站杭州做seo的公司
  • python 新闻网站开发网络营销策略理论有哪些
  • 上海做淘宝网站建设小红书推广引流软件
  • 毕业设计做网站前端水果营销软文
  • 企业邮箱有什么用锦州seo推广
  • 界面设计做的好的网站如何提高网站排名
  • 导游网站后台分类达人的作用
  • 普洱网站搭建上海优化外包
  • 政府网站什么程序做的seo实战培训费用