在我们的应用程序中,几乎在每个屏幕中我们都有一个带有文本"New"的按钮,这是其中一个按钮的html源:
<button id="defaultOverviewTable:j_id54" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-state-hover" type="submit" name="defaultOverviewTable:j_id54" role="button" aria-disabled="false">
<span class="ui-button-text ui-c">New</span>
</button>
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下语句单击按钮:
driver.findElement(By.xpath("//button[[@type, 'submit'] and [text()='New']]")).click();
Run Code Online (Sandbox Code Playgroud)
但这不起作用
org.openqa.selenium.InvalidSelectorException: The given selector //button[[@type= 'submit'] and [text()='New']] is either invalid or does not result in a WebElement.
Run Code Online (Sandbox Code Playgroud)
目前我使用以下代码点击按钮:
List<WebElement> allButt = driver.findElements(By.tagName("button"));
for (WebElement w : allButt)
{
if (w.getText().matches("New"))
{
w.click();
break;
}
}
Run Code Online (Sandbox Code Playgroud)
因为我在页面中有近150个按钮.还有其他方法吗?
我是GraphQL的新手.我知道这是非常基本的问题.但是尝试花费大量时间而我无法做到.
我的要求是我需要使用java类中的graphql-java api方法发送GraphQL查询.
这是查询:
{
contentItem(itemId: 74152479) {
slug
updatedAt
contributors {
id
isFreeForm
name
}
}
}
Run Code Online (Sandbox Code Playgroud) 我的任务是测试整个应用程序,两个输入字段之间的间距应为6px。
因此,当我尝试使用getCssvalue方法读取css值时,它给出了一个空白值。
注意:getCssvalue方法对于其他属性工作正常(例如:font-family)
这是输入字段之一的css值的屏幕快照,其中包含输入字段之间的间隔。

我正在尝试将soapui-5.2.1.jar 依赖项添加到pom.xml 中。以下是我在 POM 中添加的依赖项:
<dependency>
<groupId>soapui</groupId>
<artifactId>SoapUI</artifactId>
<version>5.2.1</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但显示以下错误信息:
Missing artifact soapui:SoapUI:jar:5.2.1
Run Code Online (Sandbox Code Playgroud)
我尝试添加父级和存储库,如下所示:
<repositories>
<repository>
<id>smartbear</id>
<name>smartbear repository</name>
<url>http://smartbearsoftware.com/repository/maven2</url>
</repository>
</repositories>
<parent>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-project</artifactId>
<version>5.2.1</version>
</parent>
Run Code Online (Sandbox Code Playgroud)
仍然显示相同的错误消息。
我在这里错过了什么吗?像任何存储库和父标签一样?
注意:当我尝试将 jar 文件安装为本地 Maven 依赖项时,它工作正常。但我不想使用本地依赖项。