简体   繁体   English

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

[英]java attempting to assign weaker access privilege error

[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

I am getting above error for a fairly simple code: 对于一个相当简单的代码,我遇到了错误:

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 is how I use Wait class. 是我如何使用Wait类。 Please help me to understand this error. 请帮我理解这个错误。

The lines with the problem are the two below 有问题的线是下面两个

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

You try to override the until method which has public access in the com.thoughtworks.selenium.Wait class by a until method which is only package visible. 您尝试通过until方法覆盖com.thoughtworks.selenium.Wait类中具有public访问权限的until方法,该方法仅包可见。

You cannot override a method and reduce visibility. 您无法覆盖方法并降低可见性。 You can only increase the visibility (eg overriding a protected method and making it public ) 您只能提高可见性(例如,覆盖protected方法并将其public

So the fix would be to add the public keyword to these methods 因此,修复方法是将public关键字添加到这些方法中

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java:“试图分配较弱的访问特权错误”(使用1.8编译JDK 1.6 Source) - Java: “attempting to assign weaker access privilege error” (Compiling JDK 1.6 Source with 1.8) Android AsyncTask错误,尝试分配较弱的访问权限。 - Android AsyncTask error, attempting to assign weaker access privileges. 试图分配较弱的访问权限; 是isCancelled的公开错误 - attempting to assign weaker access privileges; was public error for isCancelled Android Studio:房间数据库实施时出现“尝试分配较弱的访问权限”错误 - Android Studio: "attempting to assign weaker access privileges" error on Room Database implementation 泛型问题:clone()尝试分配较弱的访问权限 - Generics issue: clone() attempting to assign weaker access privileges 无法覆盖 Fragment 中的 onResume() 尝试分配较弱的访问权限; 是公开的 - Cannot override onResume() in Fragment attempting to assign weaker access privileges; was public 为什么我们不能在子类中分配较弱的权限 - why can't we assign weaker privilege in subclass Java在访问能力较弱的接口方法上出错 - Java getting an error for implementing interface method with weaker access 分配对从超类覆盖的方法的较弱访问 - Assign weaker access to method overriding from superclass 为什么java不允许为子类中的静态方法分配较弱的访问权限? - Why doesn't java allow to assign weaker access privileges to static methods in a child class?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM