lib/selenium/webdriver/driver.rb in selenium-webdriver-0.0.27 vs lib/selenium/webdriver/driver.rb in selenium-webdriver-0.0.28

- old
+ new

@@ -227,20 +227,26 @@ # driver.script('function() { ... };') # alias_method :script, :execute_script - # Get the first element matching the given id. + # Get the first element matching the given selector. If given a + # String or Symbol, it will be used as the id of the element. # - # @param [String] id + # @param [String,Hash] id or selector # @return [WebDriver::Element] # - # driver['someElementId'] #=> #<WebDriver::Element:0x1011c3b88> + # driver['someElementId'] #=> #<WebDriver::Element:0x1011c3b88> + # driver[:tag_name => 'div'] #=> #<WebDriver::Element:0x1011c3b88> # - def [](id) - find_element :id, id + def [](sel) + if sel.kind_of?(String) || sel.kind_of?(Symbol) + sel = { :id => sel } + end + + find_element sel end # # for Find @@ -252,6 +258,6 @@ nil end end # Driver end # WebDriver -end # Selenium \ No newline at end of file +end # Selenium