A MissingWayOfFindingObjectException occurs when trying to locate an element
using the :css and :index locator.
For example, say you have the following html:
```html
<div class="test">text</div>
<div class="test">text2</div>
```
You can get a collection of elements using the :css locator and then get the
second element:
```ruby
p browser.elements(:css => '.test')[1].text
#=> 'text2'
```
However, you cannot directly get the second element:
```ruby
p browser.element(:css => '.test', :index => 1).text
#=>
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:238:in
`assert_valid_as_attribute': invalid attribute: :css
(Watir::Exception::MissingWayOfFindingObjectException)
#=> from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:219:in
`normalize_selector'
#=> from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:198:in
`block in normalized_selector'
#=> from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:195:in
`each'
#=> from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:195:in
`normalized_selector'
#=> from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:75:in
`find_first_by_multiple'
#=> from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:32:in
`locate'
#=> from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/elements/element.rb:509:in
`locate'
#=> from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/elements/element.rb:487:in
`assert_exists'
#=> from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/elements/element.rb:85:in
`text'
#=> from test.rb:28:in `<main>'
```
I would have expected the second approach to work since it is equivalent to the
first.
---
Reply to this email directly or view it on GitHub:
https://github.com/watir/watir-webdriver/issues/241
_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development