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

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

  • <strong id="5koa6"></strong>
  • Appium 自動化測試演示

    發表于:2013-11-20來源:TesterHome作者:guo點擊數: 標簽:Appium
    Appium 自動化測試演示.經驗就是: 每兩次操作之間,一定要間隔幾秒,不然可能會由于加載不完全,導致操作異常 初始隱藏的控件,要判斷狀態,等顯示后再操作

      經驗就是:

      每兩次操作之間,一定要間隔幾秒,不然可能會由于加載不完全,導致操作異常

      初始隱藏的控件,要判斷狀態,等顯示后再操作

      最后輸出:

      測試截圖的相似度百分比(之前某一次結果),用來做正確性驗證,基本上相似度小余90%的都有點問題

      http://v.youku.com/v_show/id_XNjM0ODIxNTUy.html

      密碼:testerhome.com

      PS:

      原來不支持嵌入視頻

      相似度計算是看的 http://blog.csdn.net/gzlaiyonghao/article/details/2325027

      現在搞不太清楚的就是怎么判斷當前的位置,是在什么窗口下面,和如何打印出當前位置的所有控件

      貼下代碼

      # coding:utf8

      import logging

      import histsimilar

      import traceback

      import time

      import os

      from selenium import webdriver

      from selenium.common.exceptions import NoSuchElementException, WebDriverException

      logging.basicConfig(filename='log.txt',level=logging.INFO)

      success = True

      desired_caps = dict()

      desired_caps['browserName'] = 'iOS'

      desired_caps['platform'] = 'Mac'

      desired_caps['version'] = '6.1'

      desired_caps['app'] = os.path.abspath('測試app的位置')

      #def is_alert_present(wd):

      # try:

      # wd.switch_to_alert().text

      # return True

      # except:

      # return False

      def click(element):

      element.click()

      time.sleep(3)

      logging.info(str(c) + ' time click ' + wd.page_source)

      screenshot()

      def send_keys(element, keys):

      element.send_keys(keys)

      time.sleep(3)

      logging.info(str(c) + ' time click ' + wd.page_source)

      screenshot()

      def execute_script(script, args):

      wd.execute_script(script, args)

      time.sleep(3)

      screenshot()

      def mk_new_dir():

      global path, base

      base = '截圖存放的位置'

      if not os.path.isdir(base):

      path = base + '0/'

      os.mkdir(path)

      return

      path = base + str(len(os.listdir(base))) + '/'

      c = 0

      def screenshot():

      global c, path

      if not os.path.isdir(path):

      os.mkdir(path)

      wd.get_screenshot_as_file(path + str(c) + '.png')

      c += 1

      def compare():

      dirs = list()

      for dirname in os.listdir(base):

      if os.path.isdir(base + dirname):

      dirs.append((os.path.getmtime(base + dirname), dirname))

      if len(dirs) < 3:

      return

      dirs.sort()

      new = dirs[len(dirs) - 1][1]

      previous = dirs[len(dirs) - 2][1]

      names = [(os.path.getmtime(base + new + '/' + filename), filename) for filename in

      os.listdir(base + new)]

      names.sort()

      for n in names:

      if n[1].startswith('.'):

      continue

      if os.path.exists(base + previous + '/' + n[1]):

      print n[1] + ' similarity : ' + str(

      int(histsimilar.calc_similar_by_path(base + new + '/' + n[1],

      base + previous + '/' + n[1]) * 100)) + '%'

      try:

      mk_new_dir()

      wd = webdriver.Remote('http://0.0.0.0:4723/wd/hub', desired_caps)

      wd.implicitly_wait(5)

      try:

      button = wd.find_element_by_name('點擊開啟')

      while not button.is_displayed():

      #screenshot()

      time.sleep(1)

      time.sleep(3)

      click(button)

      except WebDriverException, NoSuchElementException:

      logging.info('沒有開機動畫')

      click(wd.find_element_by_xpath("//window[1]/tableview[1]/cell[1]/button[1]"))

      click(wd.find_element_by_name(" 返回"))

      click(wd.find_element_by_xpath("//window[1]/tableview[1]/cell[1]/button[2]"))

      click(wd.find_element_by_name(" 返回"))

      click(wd.find_element_by_name("游記"))

      click(wd.find_element_by_name("qunar login"))

      send_keys(wd.find_element_by_xpath("//window[1]/image[2]/textfield[1]"), "lvtu@yopmail.com")

      send_keys(wd.find_element_by_xpath("//window[1]/image[3]/secure[1]"), "lvtu@yopmail.com")

      click(wd.find_element_by_name("登錄"))

      try:

      click(wd.find_element_by_xpath("//window[1]/button[3]"))

    原文轉自:http://testerhome.com/topics/201

    老湿亚洲永久精品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>