This is a relatively new example of how to use JMeter with WebSphere MQ. This approach is a clever way of inserting messages into MQ using a JMS sampler (point to point) with a JNDI binding within MQ.
I had not heard of this approach before and am sure it will be useful in future, provided you have sufficient access to create the bindings in the first place.
Read More
A. Use a ci_reporter gem …
To install the ci_reporter gem on windows:
If you’re using Test::Unit, ensure the ci/reporter/rake/test_unit_loader.rb file is loaded before the test is run. If you’re using RSpec, you‘ll need to pass the following arguments to the spec command:
--require GEM_PATH/lib/ci/reporter/rake/rspec_loader
--format CI::Reporter::RSpec
You may also want to set the output directory as demonstrated by setting the CI_REPORTS environment variable.
require 'test/unit'
require 'ci/reporter/rake/test_unit_loader.rb'
require 'watir'
ENV["CI_REPORTS"] = 'C:/temp/'
Read More
A. Use the — argument to stop processing Test::Unit specific arguments …
Module Test::Unit has its own command line arguments as specified by the following:
~/just_add_watir $>ruby test_suite.rb --help
Test::Unit automatic runner.
Usage: test/unit/graph_test.rb [options] [-- untouched arguments]
-r, --runner=RUNNER Use the given RUNNER.
(c[onsole], f[ox], g[tk], g[tk]2, t[k])
-n, --name=NAME Runs tests matching NAME.
(patterns may be used).
-t, --testcase=TESTCASE Runs tests in TestCases matching TESTCASE.
(patterns may be used).
-v, --verbose=[LEVEL] Set the output level (default is verbose).
(s[ilent], p[rogress], n[ormal], v[erbose])
-- Stop processing options so that the
remaining options will be passed to the
test.
-h, --help Display this help.
Deprecated options:
--console Console runner (use --runner).
--gtk GTK runner (use --runner).
--fox Fox runner (use --runner).
Example watir:
def test_0021
# need to call test unit with -- argument
puts "argument 1 is: ",ARGV[0]
end
Read More
A. Use the .goto method to call the javascript …
Example html:
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<body scroll="no">
<script type="text/javascript" charset="utf-8">
function openWin(i){
alert(i);
}
</script>
<div id="menuLayer1">
<div id="menuLite1">
<div id="menuFg1">
<div id="menuItem1" mmaction="location='javascript:openWin(2);'" zIndex="1">
<div id="menuItemText1">
<div id="menuItemShim1">
<div align="left">
just_add_watir
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Example watir:
@b.goto('http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0020.html')
@b.div(:id, "menuItem1").flash
@b.goto("javascript:openWin(2)")
Read More
Sometimes you might wish to implement a QTP-like ‘object repository’. I’ve had most success implementing this via Ruby modules.
To ‘learn’ all the objects on a page using firewatir you can use a simple script like this:
require 'rubygems'
require 'firewatir'
class NilClass
def length
0
end
end
class DiscoverObjects
include FireWatir
def initialize(url)
if url
# attach to specific url
@b = Firefox.start(url)
else
# attach to existing window
@b = Firefox.new
end
end
def all
@objects = {}
[:links, :text_fields, :buttons, :select_lists].each do |type|
@b.send(type).each do |element|
@objects[element] = {}
@objects[element][:type] = type.to_s[0..-2]
# omitted :href, :url, :class
[:id, :name, :value, :text, :index, :xpath, :title, :action, :src, :for].each do |attrib|
value = element.send(attrib)
@objects[element][attrib] = value unless value.empty?
end
end
end
end
def print_objects
puts "module #{@b.title.to_s.gsub(/[^\d\w]/,'').capitalize}"
puts "# Objects learned from: #{@b.url}\n# #{Time.now}"
@objects.each do |key,val|
val.each do |k,v|
unless k.to_s =~ /type/
method_name = "#{val[:type]}_#{k}_#{v.to_s.gsub(/[^\d\w]/,'_').downcase}"
puts "\tdef #{method_name.gsub('__','_').gsub(/_$/,'')}"
puts "\t\treturn @b.#{val[:type]}(:#{k}, \"#{v}\")\n\tend\n\n"
end
end
end
puts "end"
end
end
url = ARGV[0]
discover = DiscoverObjects.new(url)
discover.all
discover.print_objects
Which will produce results like this:
module Firefoxwebbrowserfastermoresecurecustomizable
# Objects learned from: http://www.mozilla.com/en-US/firefox/
# Sat Sep 27 07:40:08 +1000 2008
def link_text_qmo
return @b.link(:text, "QMO")
end
def link_text_press_center
return @b.link(:text, "Press Center")
end
def link_text_other_systems_and_languages
return @b.link(:text, "Other Systems and Languages")
end
end
Feel free to modify to suit (for watir or the like). I develop on a Mac, so firewatir is easiest for me. The manual way is to just use the IE Developer Toolbar or Firebug depending on your platform.
Read More