To make Watir work together with FunFX you do the same setup as usually with FunFX, but you also require watir, and attaches Watir to the browser FunFX started. With the example below I use the the title of the page to make Watir understand what browser to choose.
@ie = Funfx.instance@ie.start(true)
@ie.speed = 1
@ie.goto("http://localhost/flexapplication.html", "flexapplication")
$browser = Watir::IE.attach(:title, "PageTitle")
@ie.speed = 1
@ie.goto("http://localhost/flexapplication.html", "flexapplication")
$browser = Watir::IE.attach(:title, "PageTitle")
When you have done this, both the FunFX instance and the Watir instance is able to control the browser. But one thing you should watch out for is that when FunFX enter the Flex application, it must set the flex object again, so either if you use FunFX to navigate to the Flex application, you can define the flex object in the goto statement. Or you can use the setFlexObject method.
@ie.goto("www.google.com", nil)
$browser.text_field(:name, "q").set "pickaxe"
$browser.button(:name, "btnG").click
@ie.goto("http://localhost/flexapplication.html", "flexapplication")
@ie.button("buttonName").click
$browser.text_field(:name, "q").set "pickaxe"
$browser.button(:name, "btnG").click
@ie.goto("http://localhost/flexapplication.html", "flexapplication")
@ie.button("buttonName").click
@ie.set_flex_object("flexapplication")
8 comments:
I just started using FunFx with some existing Watir code. Because the Flex widgets are not the main thing I'm testing it was easier for me to attach to them on the fly.
@watir = Watir::IE.new
@flex = Funfx.instance
@flex.attach(@watir.ie, true)
@flex.set_flex_object("flexapplication")
...etc...
These are the extensions to the Flex Framework:
class Funfx < Flex::Base
def attach(hwnd, visible=false, browser_type = nil)
@browser = Browsers.get_browser(browser_type).new(visible, hwnd)
end
end
class InternetExplorer
def initialize(visible, hwnd)
sleep($sleep_between_tests)
if hwnd
@ie = hwnd
else
@ie = WIN32OLE.new('InternetExplorer.Application')
end
@ie.visible = visible
end
end
class InternetExplorer
def initialize(visible, hwnd=nil)
Mistake in my last comment. Forgot to default the hwnd to nil...
Hi, in application I'm testing, main window is written in javascript, and most of flex objects are new windows with buttons "Save", so when my test click "Save", I have an error:
Error:
test_control(Test_Administration_analitics_report):
WIN32OLERuntimeError: unknown property or method `item'
HRESULT error code:0x80010108
Вызванный объект был отключен от клиентов.
C:/ruby/lib/ruby/gems/1.8/gems/FunFX-0.0.4/lib/ie.rb:40:in `method_missing'
C:/ruby/lib/ruby/gems/1.8/gems/FunFX-0.0.4/lib/ie.rb:40:in `flex_object'
C:/ruby/lib/ruby/gems/1.8/gems/FunFX-0.0.4/lib/funfx.rb:52:in `get_flex_object'
C:/ruby/lib/ruby/gems/1.8/gems/FunFX-0.0.4/lib/flex.rb:87:in `flex_object'
C:/ruby/lib/ruby/gems/1.8/gems/FunFX-0.0.4/lib/flex.rb:106:in `is_sync'
C:/ruby/lib/ruby/gems/1.8/gems/FunFX-0.0.4/lib/xml_parser.rb:157:in `click'
C:\Documents and Settings\RubyWorkSpace\Necessary_Minimal_Test/NMT_Administration_analitics_report.rb:73:in `test_control'
C:/ruby/lib/ruby/1.8/test/unit/testcase.rb:78:in `__send__'
C:/ruby/lib/ruby/1.8/test/unit/testcase.rb:78:in `run'
C:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
C:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
C:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
C:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
C:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
C:/ruby/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
C:/ruby/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite'
C:/ruby/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in `start_mediator'
(eval):6:in `start'
(eval):3:in `__send__'
(eval):3:in `start'
C:/ruby/lib/ruby/site_ruby/1.8/test/unit/ui/reporter.rb:67:in `run'
C:/Documents and Settings/RubyWorkSpace/Necessary_Minimal_Test/NMT_Runner.rb:83
And one more problem. I'm testing an application, which have flex and javascript parts in one window. So, in this case, I use watir to get to the flex part. But don't know how to do this. In examples, it's describes, how to test pure flex window, without javascript or html parts
hi Peter,
Could you please tell me the process to access the widgets in a module container. I have one module container in that i am having two widgets CustSearch,ItemSearch. so could you please help me.....
Is there any way in which we can use both IE watir browser and FunFx browser. i'm testing an application in which in start it's normal html web page and after login, it open Flex application.
So at the time logging in, i have to use Watir browser and after logging in, i have to use FunFX browser.
Please let me know if it is poosible
Hi Peter,
I have a Flex Application that needs to be tested . However, QTP requires that you write some custom code if you wish to automate some home-made components... Unfortunately, we have some 3rd-party components which we do not have the source code so we can't really the custom code without having the 3rd-party component's source code.
Is there any existing framework and/or tools that would allow me to automate testing without having to write custom code that could be used by a non-programmer (i.e. A QA guy which has no idea what a pointer is)
or is there any solution in FunEx for above question.
Post a Comment