wd中使用jquery(转载)
2012-05-15 01:17
190 查看
转载于http://blog.csdn.net/nbkhic/article/details/6897089
<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_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
<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_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
相关文章推荐
- 转载 jQueryEasyUI Messager基本使用
- 跟ASP.NET MVC一起使用jQuery(转载)
- jquery插件之jqModal使用笔记(转载)
- jQueryUI Autocomplete插件使用入门教程(最新版)---------转载
- 使用jQuery实现页面表格中相同内容的行或列合并[转载]
- 【转载】使用jquery做类似搜索引擎效果
- 转载:jQuery flexigrid使用说明 (一、静态格式化表格)
- [转载]jQuery 图表插件 jqChart 使用
- jQuery的deferred对象使用详解【转载】
- 【转载】jQuery UI dialog 的使用
- 使用jQuery自动缩图片 (转载)
- [jQuery]使用jQuery.Validate进行客户端验证——不使用微软验证控件的理由-目录及简介[转载]
- 艾伟_转载:使用Ajax和jQuery实现GridView的展开、合并
- <转载> Jquery的使用技巧-实用!
- [乐意黎转载]从零开始学习jQuery (四) 使用jQuery操作元素的属性与样式
- 转载 - 使用HTML5、CSS3和jQuery增强网站用户体验
- jquery中attr()方法的使用(转载)
- 使用jQuery简化Ajax开发——Ajax开发入门(转载)
- 26 个 jQuery使用技巧(转载)
- JQuery上传插件Uploadify使用详解 转载