[javac] U:\dms-webui-testing\test-java\dmswebui\CR\TestLogin.java:16: until() in cannot override until() in com.thoughtworks.selenium.Wait; attempting to assign weaker access privileges; was public
对于一个相当简单的代码,我遇到了以上错误:
package dmswebui.CR;
import org.infineta.webui.selenium4j.MainTestCase;
public class TestLogin extends MainTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
startSeleniumSession("ChromeDriver", "somesite");
}
public void testMethod() throws Exception {
new Wait("") {boolean until() {return false;}};session().open("/");
new Wait("") {boolean until() {return false;}};session().click("id=btnLogin-button"); session().waitForPageToLoad("30000");
for (int second = 0;; second++) {
if (second >= 60) fail("timeout 'waitForTextPresent:Logoff' ");
try { if (session().isTextPresent("Logoff")) break; } catch (Exception e) {}
Thread.sleep(1000);
}
new Wait("") {boolean until() {return false;}};session().click("id=btnUserLogout-button");
new Wait("") {boolean until() {return false;}};session().click("id=yui-gen0-button"); session().waitForPageToLoad("30000");
}
public void tearDown() throws Exception {
super.tearDown();
closeSeleniumSession();
}
}
这是我使用Wait类的方法。请帮助我了解此错误。
有问题的线是下面的两行
new Wait("") {boolean until() {return false;}};session().open("/");
new Wait("") {boolean until() {return false;}};session().click("id=btnLogin-button");
您尝试通过仅包可见的until
方法来覆盖public
在com.thoughtworks.selenium.Wait
类中具有访问权限的until
方法。
您不能覆盖方法并降低可见性。您只能增加可见性(例如,重写protected
方法并使之成为可能public
)
因此解决方法是将public
关键字添加到这些方法中
new Wait("") {public boolean until() {return false;}};session().open("/");
new Wait("") {public boolean until() {return false;}};session().click("id=btnLogin-button");
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句