gpt4 book ai didi

java 试图分配较弱的访问权限错误

转载 作者:太空狗 更新时间:2023-10-29 22:52:45 26 4
gpt4 key购买 nike

[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();
}


}

here这就是我使用 Wait 类的方式。请帮助我理解这个错误。

最佳答案

有问题的是下面两行

new Wait("") {boolean until() {return false;}};session().open("/");
new Wait("") {boolean until() {return false;}};session().click("id=btnLogin-button");

您尝试通过 覆盖 com.thoughtworks.selenium.Wait 类中具有 public 访问权限的 until 方法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");

关于java 试图分配较弱的访问权限错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11639741/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com