• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 一個菜鳥測試工程師的簡易自動化測試框架(2)

    發表于:2012-08-23來源:test China作者:AskaNeverEnd點擊數: 標簽:自動化測試框架
    self.sel.select(element, selection) def Check(self, element): if self.isElementPresent(element): self.sel.check(element) def Type(self, element, text): if self.isElementPresent(element): self.sel.type

      self.sel.select(element, selection)

      def Check(self, element):

      if self.isElementPresent(element):

      self.sel.check(element)

      def Type(self, element, text):

      if self.isElementPresent(element):

      self.sel.type(element, text)

      測試數據分離, 這個做的非常簡單,就是把期望值和控件位置作為測試數據放入 xml 中。

      GWEB

      link

      //span[text()="Web"]

      Web

      GIMAGES

      link

      //span[text()="Images"]

      Images

      name 表示控件名字,type 為控件的類型,locator 表示控制位置,expect_value 表示期望值。

      讀取 xml 的內容。這段代碼屬于我現學現賣,直接看了一下 python 對 xml 的支持,然后自己搗鼓了一下就寫出來了,可以獲取自己需要的 xml 里面的數據。

      from xml.dom import minidom

      class PageData():

      def __init__(self, page_name, file):

      self.name = page_name

      self.data = minidom.parse(file)

      self.xpth_dict = self.XML_Dict()

      def XML_Dict(self):

      xpath_dict = {}

      for i in self.data.getElementsByTagName(self.name):

      xpath_dict[str(i.childNodes[1].firstChild.nodeValue)] = \

      [str(i.childNodes[5].firstChild.nodeValue),\

      str(i.childNodes[7].firstChild.nodeValue)]

      return xpath_dict

      def GetLocator(self, object_name):

      return self.xpth_dict[object_name][0]

      def GetValue(self, object_name):

      return self.xpth_dict[object_name][1]

      最后,主程序里面,我們就能用下面的方式,執行我們本來已經設計好的案例。

      def testAutoCompleteFunctionMouseMove(self):

      '''test the function of auto complete. case 2: when user move mouse to the suggestion, there will be a link '''

      self.initTest("testAutoCompleteFunctionMouseMove")

      self.open('http://www.google.com/ncr')

      GoogleHomePage = data_parser.PageData("GoogleHomePage", self.data_file)

      self.Type(GoogleHomePage.GetLocator('SEARCHTEXT'), 's')

      GoogleAutoComplete = data_parser.PageData("AutoCompleteCase", self.data_file)

      self.isElementPresent(GoogleAutoComplete.GetLocator("SUGGESTIONFIELD"))

      time.sleep(10)

      self.MouseMove(GoogleAutoComplete.GetLocator("SUGGESTIONONEFORS"))

      expect_text = "I'm Feeling Lucky »"

      self.assertLogTrue(self.isTextPresent(expect_text), "The text %s has been displayed" %expect_text)

      self.MouseMove(GoogleAutoComplete.GetLocator("SUGGESTIONTWOFORS"))

      time.sleep(10)

      self.assertLogTrue(self.isTextPresent(expect_text), "The text %s has been displayed" %expect_text)

      self.endTest()

      這樣,一個相當簡易的自動化測試框架基本完工??梢酝晟频牡胤綄嵲谔嗔?,希望有志之士去完善吧,加入些新功能,譬如錯誤出現的時候截圖,然后統計測試用例總數以及通過的數量。

      后記

      作為一個菜鳥測試工程師,沒有任何的開發經驗,搞出這個東西還是有點小激動的,也激發了本人對許多事情的興趣。 以后希望能有更好的 test frame 去學習去創造。

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>