I was wondering if watirgrid / gridinit could be used in conjunction with Sikuli. http://www.sikuli.org
I've had some success integrating Sikuli with watir-webdriver and cucumber following the examples in
http://www.software-testing.com.au/blog/2010/08/16/automating-flash-ajax-popups-and-more-using-ruby-watir-and-sikuli
It's all being done from Jruby.
The next step for me was to see if I could use watirgrid to send sikuli commands, but I haven't had success thus far.
I followed the example in http://altentee.com/blogs/2010/watirgrid-support-for-watir-webdriver/
what I entered:
irb
require 'watirgrid'
require 'watir-webdriver'
require 'java'
java_import "org.sikuli.script.SikuliScript"
java_import "org.sikuli.script.Region"
java_import "org.sikuli.script.Screen"
# setup a controller on port 12351 for your new grid
controller = Controller.new(
:ring_server_port => 12351,
:loglevel => Logger::ERROR)
controller.start
# add a provider to your grid
# :browser_type => 'webdriver' if using webdriver or
# :browser_type => 'ie' if using watir...
provider = Provider.new(
:ring_server_port => 12351,
:loglevel => Logger::ERROR, :browser_type => 'webdriver')
provider.start
# connect to the grid and take all providers from it (this time only one)
grid = Watir::Grid.new(:ring_server_port => 12351, :ring_server_host => '192.168.0.107')
screen=Screen.new
grid.start(:take_all => true)
+++++++++++++ all is fine up to this point. ++++++++++++++
+++++++++++++ this is where the wheels come off ++++++++++++++
+++++++++++++ how to get the screen method available to watirgrid ? ++++++++++++++
irb(main):029:0* grid.screen.click("StartUpAdobe\/f.png",0)
NoMethodError: undefined method `screen' for #<Watir::Grid:0x1a0283e>
from (irb):29:in `evaluate'
from org/jruby/RubyKernel.java:1088:in `eval'
from C:/jruby-1.6.2/lib/ruby/1.8/irb.rb:158:in `eval_input'
from C:/jruby-1.6.2/lib/ruby/1.8/irb.rb:271:in `signal_status'
from C:/jruby-1.6.2/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1419:in `loop'
from org/jruby/RubyKernel.java:1191:in `catch'
from C:/jruby-1.6.2/lib/ruby/1.8/irb.rb:1开发者_如何学C54:in `eval_input'
from C:/jruby-1.6.2/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1191:in `catch'
from C:/jruby-1.6.2/lib/ruby/1.8/irb.rb:70:in `start'
from C:\jruby-1.6.2\bin\irb:13:in `(root)'
We're interested in using watigrid and sikuli for performance testing a vnc-based application.
So in your code, calling .screen does not exist on the 'grid' object, it is actually a method that belongs to the Screen class, which is part of the sikuli packages I'm guessing.
It looks like from the examples, the Screen class object is instantiated locally. What you want is for this object to be instantiated remotely.
Watirgrid just exposes remote watir[-webdriver] objects via DRb. It has no knowledge of Sikuli. It looks like in the examples, you're just using watir-webdriver to start an instance of the browser and navigate to the front page. From then on I'm guessing Sikuli does most of the work.
What you really need is a Sikuligrid =) Since you're the only person that's asked I'm not about to go monkey patch Watirgrid, as there might be a better way to achieve what you're trying to do.
Using DRb you may even be able to do something very simple like this:
remote.rb
require 'drb'
require 'java'
java_import "org.sikuli.script.SikuliScript"
java_import "org.sikuli.script.Region"
java_import "org.sikuli.script.Screen"
DRb.start_service("druby://127.0.0.1:61676", Screen.new)
DRb.thread.join
local.rb
require 'drb'
screen = DRbObject.new_with_uri("druby://127.0.0.1:61676")
screen.click("StartUpAdobe\/f.png",0)
At this point my focus with watirgrid is to enable testing of watir[-webdriver] on a distributed grid network. I do however acknowledge the usefulness of things like webdriver in driving something 'other' than a web app. This is where tools like Sikuli and even nativedriver http://code.google.com/p/nativedriver/ are looking very attractive. Right now though my focus is on making watirgrid bulletproof and probably next on the list is headless browser automation with phantomjs...
As Tim posted, until someone builds a "Sikuli Grid", your best option is to create your own such Grid following Tim's suggestions.
Another simpler but yet still has development work to do alternative is presented in my blog post. It's a theoretical approach that has yet to be implemented and proven though.
http://autumnator.wordpress.com/2011/12/22/autoit-sikuli-and-other-tools-with-selenium-grid/
精彩评论