创建基于父母的elementsCollection在Selenide中的一个
我正在使用 Selenide ,并寻找机会创建儿童elementscollection 基于父母的。例如,我有一个Web表和一个由表行组成的父元素汇总。因此,在通过某种条件过滤此集合后,我得到了50行。然后需要将第一个单元格保存为新的ElementsCollection(儿童)中的硒纤维。 如果我使用列表,此情况没有任何问题,因为我可以使用stream()as:
List<SelenideElement> parents = $$("parent_css_selector");
List<SelenideElement> children = parents.stream().filter(s -> s.getText().equals("some_text")).map(s -> s.$("child_css_locator")).collect(Collectors.toList());
//or even in List<String> if I need to...
List<String> childrenTexts = parents.stream().filter(s -> s.getText().equals("some_text")).map(s -> s.$("child_css_locator")).getText().collect(Collectors.toList());
但是,由于selenide 6.2.0中的stream()devect of stream()我找不到机会这样做。
I'm using Selenide and looking for an opportunity to create children ElementsCollection based on a parent's one. For example, I have a web table and a parent ElementsCollection consisting of table rows. So, after filtering this collection by some condition, I get, for example, 50 result rows. Then need to save the first cell in each row as a SelenideElement in a new ElementsCollection (children).
This case doesn't have any issues, if I use List, because I can do this using stream() as:
List<SelenideElement> parents = $("parent_css_selector");
List<SelenideElement> children = parents.stream().filter(s -> s.getText().equals("some_text")).map(s -> s.$("child_css_locator")).collect(Collectors.toList());
//or even in List<String> if I need to...
List<String> childrenTexts = parents.stream().filter(s -> s.getText().equals("some_text")).map(s -> s.$("child_css_locator")).getText().collect(Collectors.toList());
But since stream() was deprecated in Selenide 6.2.0 I cant find an opportunity to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在Gitter和Github中的专门硒化主题中提出了这个问题。我想指出,我在一个小时内收到了回应,这是项目开发和支持的非常宝贵的方法。 ))这是Selenide创始人Andrei Solntsev的答案。
据我所知,他将在ElementsCollection中返回未剥夺的流()。
I've raised this question in specialized Selenide topics in Gitter and GitHub. And I would like to note that I received a response within an hour and it is very valuable approach in project development and support. )) Here is the answer of Andrei Solntsev, Selenide founder.
As far as I understood, he will return non-deprecated stream() in ElementsCollection.
您的IDE应该为您解决这个问题。由于
stream()
已弃用,您可以用for循环替换它,例如此Intellij自动生成此,如果不是您想要的,则不再依赖于
stream()
。Your IDE should sort this out for you. Since
stream()
is deprecated you can replace it with a for loop, such as thisIntelliJ generated this automatically, apologies if it's not exactly what you wanted but it no longer relies on
stream()
.