jarmo / RAutomation

RAutomation
MIT License
100 stars 33 forks source link

Feature Enhancement: select_list #select and #selected? #12

Closed myungs closed 12 years ago

myungs commented 13 years ago

Method call for selecting an element in a select_list is poor.

Currently the spec is: it "#selected? & #select" do
select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /COMBOBOX/i) select_list.options(:text => "Apple")[0].should_not be_selected select_list.options(:text => "Apple")[0].select.should be_true select_list.options(:text => "Apple")[0].should be_selected end

Would prefer it work like the following it "#selected? & #select" do
select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /COMBOBOX/i) select_list.selected?("Apple").should_not be_true select_list.select("Apple").should be_true select_list.selected?("Apple").should be_true

    #set alias for select, like in Watir
    select_list.set("Coconut").should be_true
    select_list.set?("Coconut").should be_true

    #raise exception if you try to call an option not in the list, used same exception name from watir
    expect { select_list.select("Mango") }.
        to raise_exception(RAutomation::NoValueFoundException )
end

set alias would also help for being able to, per request #11, loop over all sub-controls and call a generic #set

jarmo commented 13 years ago

It would be even better if there would be an Option element like in Watir, so: select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /COMBOBOX/i) select_list.option(:value => "Apple").selected? select_list.option(:value => "Apple").set

That API would make more sense to me than the current one. Although i'm not sure if it's possible to do something like that in the context of Windows controls.

snscaimito commented 13 years ago

We now have that option element Jarmo proposed

jarmo commented 12 years ago

This seems to be implemented. Closing.