开发者

Cannot access static method when running thru main method from command line

I have a a method that is being called from Main but when the time comes to call the static method within it will not proceed and test stops.

I have inserted log comments in order to tell where the problem is and no exceptions are caught so there is no compiling nor runtime errors so far.

The static method that is not being called is GC2CommonMethods.loadApplication();. The weird thing is that when running Main from Eclipse IDE it runs perfectly but it does not when executing from jar file through the same Main method.

See below both codes from the method that is being executed and the detail of the static method that is within a static class respectively.

I would appreciate your help with this. Thanks.

//This method is intented to be called from Main method 

package com.mycompany.test.loginRoleEntitlements; 
public void verifyLoginPageElements() {
   logger.info("\t1.0/1.0.2 - Verif**strong text**ying Login page elements...");
     try {
         logger.info("entering Try");

         GC2CommonMethods.loadApplication(sl);    //Static method from Static class. 
         assertTrue("Region identifier is not present.", sl.isElementPresent(PageAttributes.LoginPage.DB_LABEL));
         assertTrue("Forgot Password link is not present", sl.isElementPresent(PageAttributes.LoginPage.FORGOT_PASSWORD));

     } catch (SeleniumException se) {
           logger.info("caught SeleniumException");
           logger.error(se.getMessage());
       throw se;
     } catch (AssertionFailedError ae) {
       logger.info("caught AssertionException");
       开发者_JAVA技巧logger.error(ae.getMessage());
       throw ae;
     } catch (Exception e) {
       logger.info("caught Exception");
       logger.info("Encountered exception");
        e.printStackTrace();
    }

  //This is the static method that is within GC2CommonMethods static class
  package com.mycompay.common;

  public static void loadApplication(SeleniumHandle sl) {   

    sl.open(props.getProperty("APPLICATION_URL"));
    sl.waitForPageToLoad("30000");
    assertEquals("The page is not the correct one.
   |Expected: "+PageAttributes.LoginPage.LOGINPAGE_TITLE + ".
   Found:"+sl.getTitle(),PageAttributes.LoginPage.LOGINPAGE_TITLE,sl.getTitle());
  }


I found the solution. The problem was on the main method when trying to read a properties file. There was an uncaught exception which was not being logged so I was not able tell where the problem was. Thanks for your replies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜