Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java attempting to assign weaker access privilege error

Tags:

[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. Please help me to understand this error.

like image 274
hrishikeshp19 Avatar asked Jul 24 '12 21:07

hrishikeshp19


1 Answers

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.

You cannot override a method and reduce visibility. You can only increase the visibility (e.g. overriding a protected method and making it public)

So the fix would be to add the public keyword to these methods

new Wait("") {public boolean until() {return false;}};session().open("/"); new Wait("") {public boolean until() {return false;}};session().click("id=btnLogin-button"); 
like image 147
Robin Avatar answered Dec 09 '22 04:12

Robin