亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測(cè)試 > 開(kāi)源軟件測(cè)試 > 開(kāi)源功能測(cè)試工具 > Selenium
Selenium教程之使用jquery輔助進(jìn)行測(cè)試
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2016/12/23 15:46:29 ] 推薦標(biāo)簽:Selenium 功能測(cè)試

  Jquery是當(dāng)下比較流行的1個(gè)js框架,通過(guò)使用webdriver的execute_script方法,我們可以將jquery庫(kù)結(jié)合到自動(dòng)化測(cè)試中去。
  結(jié)合jquery進(jìn)行自動(dòng)化測(cè)試的思想是這樣的:首先將jquery的源碼讀到1個(gè)string中去,然后使用execute_script執(zhí)行該string。執(zhí)行完畢后我們可以通過(guò)execute_script方法來(lái)調(diào)用jquery庫(kù)了。
  下面的html代碼中有一個(gè)隱藏的div,當(dāng)鼠標(biāo)移動(dòng)到(mouseover)頁(yè)面上名為Mouse Over Here的鏈接時(shí),隱藏的div將會(huì)顯示出來(lái)。
  <html>
  <head>
  <title>FireEvent</title>
  <style>
  .mo {color: blue;}
  .tips {display:none;border: 1px solid #ccc; background-color:#EFEFEF;width: 100px;height:100px}
  </style>
  <script>
  function show_tips(){
  document.getElementById("t").style.display = "block";
  }
  function hide_tips(){
  document.getElementById("t").style.display = "none";
  }
  </script>
  </head>
  <body>
  <a class = "mo" href = "#" onmouseover = "show_tips()" onmouseout = "hide_tips()">Mouse Over Here</a>
  <div id = "t" class = "tips">This is the tips of link</div>
  </body>
  </html>
  下面的代碼使用jquery的庫(kù)函數(shù)實(shí)現(xiàn)了不去觸發(fā)Mouse Over Here鏈接而直接顯示隱藏div的效果(僅在ruby1.9.2下測(cè)試過(guò),ruby1.8x應(yīng)該都不支持)
  jquery_helper.rb
  #encoding: utf-8
  module JqueryHelper
  def load_jquery dr,jquery_path
  jq = read_jquery(jquery_path)
  jq.force_encoding('utf-8')
  dr.execute_script jq
  end
  def read_jquery(jquery_path)
  js = ''
  File.open(File.expand_path(jquery_path), 'r') do |f|
  js = f.read
  end
  js
  end
  end
  fire_event.rb
  require 'rubygems'
  require 'selenium-webdriver'
  require './jquery_helper'
  include JqueryHelper
  dr = Selenium::WebDriver.for :firefox
  select_file = 'file:///'.concat File.expand_path(File.join(File.dirname(__FILE__), 'fire_event.html'))
  dr.navigate.to select_file
  jquery_path = './jquery-1.6.4.min.js'
  load_jquery dr, jquery_path
  jq = <<JQ
  $("#t").show();
  JQ
  dr.execute_script jq
  使用jquery來(lái)輔助測(cè)試實(shí)用性應(yīng)該不是很強(qiáng),不過(guò)有些時(shí)候可以使用jquery方法來(lái)獲得dom節(jié)點(diǎn)的css屬性,從而達(dá)到簡(jiǎn)化腳本的目的。

軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 国产成人精品福利站 | 免费三级黄色片 | 欧美日韩国产在线观看 | 国产精品欧美亚洲韩国日本久久 | 国产丝袜视频在线 | 看a网址| 久久综合综合久久狠狠狠97色 | 欧美中文字幕视频 | 成人免费视频网 | 毛片福利视频 | 国产高清精品自在久久 | 狠狠躁夜夜躁人人爽天天 | 香港日本三级在线播放 | 中国一级特黄剌激爽毛片 | 欧美日韩一区二区三区在线观看 | 国产精品久久久久久久人热 | 在线三区| 欧美三级日韩三级 | 免费视频性 | 亚洲激情久久 | 免费一级在线观看 | 国产精品二区三区免费播放心 | 一级毛片特级毛片免费的 | 一级黄色α片 | 日韩高清在线日韩大片观看网址 | 高清不卡毛片 | 一区二区三区亚洲 | 最新欧美精品一区二区三区 | 欧美在线一区二区三区欧美 | 欧美00xx| 狠狠色狠狠色综合曰曰 | 欧美日韩在线高清 | 国产欧美日韩另类va在线 | 天天操天天插天天射 | 99综合网 | 成年做羞羞免费观看视频网站 | 国产成人精品亚洲一区 | 夜间福利视频 | 你懂的免费在线视频 | 国产天堂亚洲精品 | 精品91麻豆免费免费国产在线 |