小编Rus*_*ord的帖子

Java 8 Streams - Get distinct integers from object list as an array

I'm struggling to work out how to get the distinct integers from an object list as an array using Streams.

Consider I have the below class:

public class Person{

    private int age;
    private double height;

    public Person(int age, double height) {
        this.age= age;
        this.height = height;
    }

    public int getAge() {
        return age;
    }

    public double getHeight() {
        return height;
    }
}

Run Code Online (Sandbox Code Playgroud)

Then consider that have a populated list of these objects e.g. List<Person> people.

My question is, how …

arrays java-8 java-stream

5
推荐指数
1
解决办法
1万
查看次数

CSS 选择器:href 的锚文本包含

我目前正在使用 Selenium,现在已经进入了有趣但非常困难的 CSS 选择器世界。

我目前正在考虑选择 Google 工具栏的不同选项。例如,当您搜索某些内容时,在结果页面上,您可以选择在图片、新闻、视频等下搜索相同的词

我对选择“图像”链接特别感兴趣。

我已经研究了很长一段时间,我得到的最接近的是以下选择器:

div a.q.qs[href]
Run Code Online (Sandbox Code Playgroud)

这将深入到正确的子类,但有 16 个。尽管进行了数小时的漫无目的搜索,但我无法使用围绕锚文本的 contains 方法完成查询,这在目标子类中是独一无二的。

我知道 Selenium 中有一个 By LinkText 选项,但我不确定锚文本在整个页面中是否唯一。另外,我真的很想了解一般的 CSS 选择器,所以即使是这样,我也想解决这个特定问题,以便我可以将其应用于未来的问题。

我正在寻找类似于以下伪 CSS 选择器的内容:

div a.q.qs[href].Anchorcontains("Images")
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮忙吗?

css java selenium

3
推荐指数
1
解决办法
1万
查看次数

Maven / Junit并行执行-Cucumber-JVM v4.0.0

我正在努力获得与JUnit / Maven一起使用的Cucumber-JVM v4.0.0的新并行执行功能。

作为指定在这里,如果配置<parallel><threadCount>在你的POM因此,和使用依赖注入到共享状态(我使用的Pico Continer),那么你的黄瓜功能应该并行执行。

但是,当我运行Maven时,它仍然一次仅执行一项功能。

我在下面包括了完整的POM-有人可以帮忙吗?

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.softwareautomation</groupId>
<artifactId>selenium</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>selenium</name>
<url>http://maven.apache.org</url>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.4</version>
            <configuration>
                <parallel>both</parallel>
                <threadCount>4</threadCount>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>

    <!-- AssertJ -->
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.11.1</version>
        <scope>test</scope>
    </dependency>

    <!-- Cucumber -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>4.0.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>4.0.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>4.0.0</version>
        <scope>test</scope>
    </dependency>

    <!-- …
Run Code Online (Sandbox Code Playgroud)

junit selenium maven cucumber-jvm cucumber-junit

2
推荐指数
1
解决办法
1394
查看次数