我刚刚发现了 Sikuli 并设法让它在 eclipse 上运行。现在我试图弄清楚是否可以将 BDD 与它一起使用,但我似乎无法让它们一起工作。
我正在使用 JBehave 来运行测试。这是我到目前为止所拥有的:
故事档案
Scenario: Opening the orders list
Given i am in the main menu
When i click the orders button
Then the orders list should be opened
步骤文件
package com.test;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.jbehave.core.steps.Steps;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Screen;
public class AbrirListagemPedidosSteps extends Steps {
Screen s;
public AbrirListagemPedidosSteps() {
s = new Screen();
}
@Given("i'm in the main menu")
public void theSystemIsOpened() throws FindFailed {
s.click("/com/test/images/editSenha.jpg");
s.type("1");
s.click("/com/test/images/btnEntrar.jpg");
}
@When("i click the orders button")
public void iClickTheOrdersButton() throws FindFailed {
s.click("/com/test/images/btnPedido.jpg");
}
@Then("the orders list should be opened")
public void ordersListShouldBeOpened() throws FindFailed {
s.find("/com/test/images/listagemPedidos");
}
}
配置文件
package com.test;
import java.util.Arrays;
import java.util.List;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.io.LoadFromClasspath;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Sikulix;
public class AbrirListagemPedidos extends Sikulix {
public static void main(String[] args) throws FindFailed {
AbrirListagemPedidos test = new AbrirListagemPedidos();
test.configuration();
test.stepsFactory();
test.storyPaths();
}
public Configuration configuration() {
return new MostUsefulConfiguration()
.useStoryLoader(new LoadFromClasspath(this.getClass()))
.useStoryReporterBuilder(
new StoryReporterBuilder().withDefaultFormats().withFormats(Format.CONSOLE));
}
public InjectableStepsFactory stepsFactory() {
return new InstanceStepsFactory(configuration(), new AbrirListagemPedidosSteps());
}
protected List<String> storyPaths() {
return Arrays.asList("/com/test/AbrirListagemPedidos.story");
}
}
据我所知,Sikuli 需要一个 main[] 方法来执行,所以我尝试了这种方法。
我进行了很多搜索,但找不到有关如何使此设置正常工作的教程或其他内容。运行这个不会出错,它只是不做任何事情。