lib/selenium/client/idiomatic.rb in selenium-client-1.2.10 vs lib/selenium/client/idiomatic.rb in selenium-client-1.2.11

- old
+ new

@@ -14,14 +14,14 @@ # or the innerText (IE-like browsers) of the element, which is the # rendered text shown to the user. # # * 'locator' is an Selenium element locator # - # TODO - Should be renamed 'text' - def text_content(locator) + def text(locator) string_command "getText", [locator,] end + alias :text_content :text # Return the title of the current HTML page. def title string_command "getTitle" end @@ -56,42 +56,50 @@ remote_control_command "waitForPopUp", [window_id, actual_timeout * 1000 ,] end # Flexible wait semantics. ait is happening browser side. Useful for testing AJAX application. # - # * wait :wait_for => :page # will wait for a new page to load - # * wait :wait_for => :popup, :window => 'a window id' # will wait for a new popup window to appear. Also selects the popup window for you provide `:select => true` - # * wait :wait_for => :ajax # will wait for all ajax requests to be completed (Prototype only) - # * wait :wait_for => :effects # will wait for all Prototype effects to be rendered - # * wait :wait_for => :element, :element => 'new_element_id' # will wait for an element to be present/appear - # * wait :wait_for => :no_element, :element => 'new_element_id' # will wait for an element to be not be present/disappear - # * wait :wait_for => :text, :text => 'some text' # will wait for some text to be present/appear - # * wait :wait_for => :text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to be 'some text' - # * wait :wait_for => :no_text, :text => 'some text' # will wait for the text to be not be present/disappear - # * wait :wait_for => :no_text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to not be 'some text' - # * wait :wait_for => :condition, :javascript => 'some expression' # will wait for the javascript expression to be true + # * wait :wait_for => :page # will wait for a new page to load + # * wait :wait_for => :popup, :window => 'a window id' # will wait for a new popup window to appear. Also selects the popup window for you provide `:select => true` + # * wait :wait_for => :ajax # will wait for all ajax requests to be completed using semantics of default javascript framework + # * wait :wait_for => :ajax, :javascript_framework => :jquery # will wait for all ajax requests to be completed overriding default javascript framework + # * wait :wait_for => :effects # will wait for all javascript effects to be rendered using semantics of default javascript framework + # * wait :wait_for => :effects, :javascript_framework => :prototype # will wait for all javascript effects to be rendered overriding default javascript framework + # * wait :wait_for => :element, :element => 'new_element_id' # will wait for an element to be present/appear + # * wait :wait_for => :no_element, :element => 'new_element_id' # will wait for an element to be not be present/disappear + # * wait :wait_for => :text, :text => 'some text' # will wait for some text to be present/appear + # * wait :wait_for => :text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to be 'some text' + # * wait :wait_for => :no_text, :text => 'some text' # will wait for the text to be not be present/disappear + # * wait :wait_for => :no_text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to not be 'some text' + # * wait :wait_for => :value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to be 'some value' + # * wait :wait_for => :no_value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to not be 'some value' + # * wait :wait_for => :condition, :javascript => 'some expression' # will wait for the javascript expression to be true # # Using options you can also define an explicit timeout (:timeout_in_seconds key). Otherwise the default driver timeout # is used. def wait_for(options) if options[:wait_for] == :page wait_for_page options[:timeout_in_seconds] elsif options[:wait_for] == :ajax - wait_for_ajax options[:timeout_in_seconds] + wait_for_ajax options elsif options[:wait_for] == :element - wait_for_element options[:element], options[:timeout_in_seconds] + wait_for_element options[:element], options elsif options[:wait_for] == :no_element - wait_for_no_element options[:element], options[:timeout_in_seconds] + wait_for_no_element options[:element], options elsif options[:wait_for] == :text - wait_for_text options[:text], options[:element], options[:timeout_in_seconds] + wait_for_text options[:text], options elsif options[:wait_for] == :no_text - wait_for_no_text options[:text], options[:element], options[:timeout_in_seconds] + wait_for_no_text options[:text], options elsif options[:wait_for] == :effects - wait_for_effects options[:timeout_in_seconds] - elsif options[:wait_for] == :popup - wait_for_popup options[:window], options[:timeout_in_seconds] - select_window options[:window] if options[:select] + wait_for_effects options + elsif options[:wait_for] == :popup + wait_for_popup options[:window], options[:timeout_in_seconds] + select_window options[:window] if options[:select] + elsif options[:wait_for] == :value + wait_for_field_value options[:element], options[:value], options + elsif options[:wait_for] == :no_value + wait_for_no_field_value options[:element], options[:value], options elsif options[:wait_for] == :condition wait_for_condition options[:javascript], options[:timeout_in_seconds] end end @@ -105,21 +113,25 @@ # 'locator' is an element locator # # Using 'options' you can automatically wait for an event to happen after the # click. e.g. # - # * click :wait_for => :page # will wait for a new page to load - # * click :wait_for => :popup, :window => 'a window id' # will wait for a new popup window to appear. Also selects the popup window for you provide `:select => true` - # * click :wait_for => :ajax # will wait for all ajax requests to be completed (Prototype only) - # * click :wait_for => :effects # will wait for all Prototype effects to be rendered - # * click :wait_for => :element, :element => 'new_element_id' # will wait for an element to be present/appear - # * click :wait_for => :no_element, :element => 'new_element_id' # will wait for an element to be not be present/disappear - # * click :wait_for => :text, :text => 'some text' # will wait for some text to be present/appear - # * click :wait_for => :text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to be 'some text' - # * click :wait_for => :no_text, :text => 'some text' # will wait for the text to be not be present/disappear - # * click :wait_for => :no_text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to not be 'some text' - # * click :wait_for => :condition, :javascript => 'some expression' # will wait for the javascript expression to be true + # * click :wait_for => :page # will wait for a new page to load + # * click :wait_for => :popup, :window => 'a window id' # will wait for a new popup window to appear. Also selects the popup window for you provide `:select => true` + # * click :wait_for => :ajax # will wait for all ajax requests to be completed using semantics of default javascript framework + # * click :wait_for => :ajax, :javascript_framework => :jquery # will wait for all ajax requests to be completed overriding default javascript framework + # * click :wait_for => :effects # will wait for all javascript effects to be rendered using semantics of default javascript framework + # * click :wait_for => :effects, :javascript_framework => :prototype # will wait for all javascript effects to be rendered overriding default javascript framework + # * click :wait_for => :element, :element => 'new_element_id' # will wait for an element to be present/appear + # * click :wait_for => :no_element, :element => 'new_element_id' # will wait for an element to be not be present/disappear + # * click :wait_for => :text, :text => 'some text' # will wait for some text to be present/appear + # * click :wait_for => :text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to be 'some text' + # * click :wait_for => :no_text, :text => 'some text' # will wait for the text to be not be present/disappear + # * click :wait_for => :no_text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to not be 'some text' + # * click :wait_for => :value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to be 'some value' + # * click :wait_for => :no_value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to not be 'some value' + # * click :wait_for => :condition, :javascript => 'some expression' # will wait for the javascript expression to be true # # Using options you can also define an explicit timeout (:timeout_in_seconds key). Otherwise the default driver timeout # is used. def click(locator, options={}) remote_control_command "click", [locator,] @@ -138,10 +150,21 @@ # * 'locator' is an element locator def element?(locator) boolean_command "isElementPresent", [locator,] end + # Determines if the specified element is visible. An + # element can be rendered invisible by setting the CSS "visibility" + # property to "hidden", or the "display" property to "none", either for the + # element itself or one if its ancestors. This method will fail if + # the element is not present. + # + # 'locator' is an element locator + def visible?(locator) + boolean_command "isVisible", [locator,] + end + # Gets the (whitespace-trimmed) value of an input field # (or anything else with a value parameter). # For checkbox/radio elements, the value will be "on" or "off" # depending on whether the element is checked or not. # @@ -286,20 +309,24 @@ # Simulates the user clicking the "back" button on their browser. # Using 'options' you can automatically wait for an event to happen after the # click. e.g. # - # * go_back :wait_for => :page # will wait for a new page to load - # * go_back :wait_for => :popup, :window => 'a window id' # will wait for a new popup window to appear. Also selects the popup window for you provide `:select => true` - # * go_back :wait_for => :ajax # will wait for all ajax requests to be completed (Prototype only) - # * go_back :wait_for => :effects # will wait for all Prototype effects to be rendered - # * go_back :wait_for => :element, :element => 'new_element_id' # will wait for an element to be present/appear - # * go_back :wait_for => :no_element, :element => 'new_element_id' # will wait for an element to be not be present/disappear - # * go_back :wait_for => :text, :text => 'some text' # will wait for some text to be present/appear - # * go_back :wait_for => :text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to be 'some text' - # * go_back :wait_for => :no_text, :text => 'some text' # will wait for the text to be not be present/disappear - # * go_back :wait_for => :no_text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to not be 'some text' - # * go_back :wait_for => :condition, :javascript => 'some expression' # will wait for the javascript expression to be true + # * go_back :wait_for => :page # will wait for a new page to load + # * go_back :wait_for => :popup, :window => 'a window id' # will wait for a new popup window to appear. Also selects the popup window for you provide `:select => true` + # * go_back :wait_for => :ajax # will wait for all ajax requests to be completed using semantics of default javascript framework + # * go_back :wait_for => :ajax, :javascript_framework => :jquery # will wait for all ajax requests to be completed overriding default javascript framework + # * go_back :wait_for => :effects # will wait for all javascript effects to be rendered using semantics of default javascript framework + # * go_back :wait_for => :effects, :javascript_framework => :prototype # will wait for all javascript effects to be rendered overriding default javascript framework + # * go_back :wait_for => :element, :element => 'new_element_id' # will wait for an element to be present/appear + # * go_back :wait_for => :no_element, :element => 'new_element_id' # will wait for an element to be not be present/disappear + # * go_back :wait_for => :text, :text => 'some text' # will wait for some text to be present/appear + # * go_back :wait_for => :text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to be 'some text' + # * go_back :wait_for => :no_text, :text => 'some text' # will wait for the text to be not be present/disappear + # * go_back :wait_for => :no_text, :element => 'a_locator', :text => 'some text' # will wait for the content of 'a_locator' to not be 'some text' + # * go_back :wait_for => :condition, :javascript => 'some expression' # will wait for the javascript expression to be true + # * go_back :wait_for => :value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to be 'some value' + # * go_back :wait_for => :no_value, :element => 'a_locator', :value => 'some value' # will wait for the field value of 'a_locator' to not be 'some value' # # Using options you can also define an explicit timeout (:timeout_in_seconds key). Otherwise the default driver timeout # is used. def go_back(options={}) remote_control_command "goBack"