[ruby-core:94262] [Ruby master Misc#16096] each in each (multiple uses 'each')
From:
merch-redmine@...
Date:
2019-08-10 23:32:44 UTC
List:
ruby-core #94262
Issue #16096 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Feedback to Rejected
D1mon (Dim F) wrote:
> **selenium**
> ``` ruby
> for el in driver.find_elements(xpath: <some_xpath>)
> for e1 in el.find_elements(xpath: ...)
> ...
> end
> for e2 in el.find_elements(xpath: ...)
> ...
> end
> end
> ```
>
> I need to do two searches in one pass
You probably want something like:
```ruby
driver.find_elements(xpath: "...").each do |el|
(el.find_elements(xpath: "...").to_a + el.find_elements(xpath: "...").to_a).each do |e1|
# ...
end
end
```
Alternatively, you need an xpath expression that matches both elements you want to select (not sure if that is possible).
As this is not a bug report, I'm going to close this.
----------------------------------------
Misc #16096: each in each (multiple uses 'each')
https://bugs.ruby-lang.org/issues/16096#change-80577
* Author: D1mon (Dim F)
* Status: Rejected
* Priority: Normal
* Assignee:
----------------------------------------
``` ruby
obj.each {|a|
a.some_method1.each {|b|
... # comes here (enter)
}
a.some_method2.each {|c|
... # does not enter here
}
}
# tried and that way. also does not go
for a in obj
for b in a.some_method1
... # comes here
end
for c in a.some_method2
... # does not enter here
end
end
```
help solve the problem. I’ve been suffering for 2 days.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>