ruby - Unable to find buttons of system popup using rautomation -


i'm writing tests using selenium webdriver , rautomation handle system popup. tried on irb following:

require 'selenium-webdriver' require 'rautomation'  driver = selenium::webdriver.for :firefox driver.get "http://rubygems.org/gems/rautomation-0.9.2.gem"  window = rautomation::window.new :title => "opening rautomation-0.9.2.gem"  ok_button = window.button(:text => "&ok") ok_button.exists?  cancel_button = window.button(:text => "&cancel") cancel_button.exists? 

ok_button.exists? , cancel_button.exists? returning false. hence can't click on buttons.

i tried:

window.buttons.length 

to find number of buttons, it's returning 0.

could please me why buttons aren't detected using rautomation? please correct me if i'm doing wrong.

here popup:

window popup

the problem dialog not use native windows controls. when use spy++ or autoit window info tool not show controls in window either.

when using rautomation can check if has native controls on or not this:

win = rautomation::window.new :title => /opening rautomation/ p win.present? p win.controls.length p win.text win.close 

the output of script be:

true 0 "" 

in other words - window present, had 0 controls of kind , text empty string. also, closing window closed can verify visually - means interacting correct window , not accidentally other empty window (beware: might happen too).

this means cannot interact controls directly autoit, rautomation or many other automation tools. there might specific automation tools available handling these kind of dialogs - i'm not sure.

there workaround how work these kind of windows - send needed keystrokes window. in case, sending return/enter key trick since same clicking on "ok" button - can try manually.

here example code, works same clicking on "ok" button:

win = rautomation::window.new :title => /opening rautomation/ win.activate sleep 1 win.send_keys :enter 

i'm not sure why, reason have activate window manually calling window#activate , wait second before sending enter key.

after doing new dialog pop up, uses native windows controls - can handle have expected rautomation work in first place.

however, if use :ms_uia adapter instead of default :win32 don't need activate , sleep.

here working example :ms_uia adapter:

win = rautomation::window.new :title => /opening rautomation/, :adapter => :ms_uia win.send_keys :enter  file_dialog = rautomation::window.new :title => /enter name of file/ file_dialog.button(:value => "&save").click 

to click "cancel" on first dialog instead of "ok" can use window#close using test window above.

i recommend use :ms_uia adapter instead of :win_32 since getting more stable every day , new default 1 in far future.

to set :ms_uia adapter default 1 can use environment variable rautomation_adapter before loading rautomation this:

env["rautomation_adapter"] ||= :ms_uia require "rautomation" 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -