我敢肯定,有经验的 Java 开发人员可以很快回答这个问题。但是由于我对 Java 不太熟悉,所以我不知道如何在 Java 中找到 Selenium 的 @Config 部分。如果我可以有一个配置文件或类,我可以将数据(浏览器、网站等)放在其中,另一方面是测试文件,那将是最佳的。
下面是一个测试文件的例子:
package com.example_test.selenium;
import io.ddavison.conductor.Browser;
import io.ddavison.conductor.Config;
import io.ddavison.conductor.Locomotive;
import org.junit.Test;
@Config(
browser = Browser.CHROME,
url = "http://example.com"
)
public class test_a_Home extends Locomotive {
@Test
public void testifExists() {
validatePresent(site_a_Home.EL_NEWCUSTOMERBANNER);
}
}
现在我想要一个名为tests.java 的单独文件,我可以在其中调用“test_a_Home”函数。如果我尝试一下
package com.example_test.selenium;
public class tests {
test_a_Home test = new test_a_Home();
test.testifExists();
}
我收到错误消息,“testifExists()”无法解决。
我尝试更改public void testifExists()
topublic int testifExists()
并尝试使用int res = test.testifExists();
in调用它,class tests
但这也不起作用,因为我收到 error java.lang.Exception: Method testNewCustomersBannerExists() should be void
。
如果有人可以帮助我,我会很高兴。如果您需要更多信息,请随时提及。谢谢你。