【问题标题】:How to call a different method(written in second class) run from different class(first class)?如何调用从不同类(第一类)运行的不同方法(用第二类编写)?
【发布时间】:2015-01-21 02:30:30
【问题描述】:
  • 第一个项目 --- 在 Eclipse IDE 中 -- Selenium 项目

        public class StandLib () {
    
            public string URL = "http://www.google.com";
    
                    Standlib objAutomation = new Standardlib();
    
                    public static void main (String args[]) 
                    {
                        objAutomation. testlaunch(URL);
                    }
        }
    
  • 第二个项目——在 Eclipse IDE 中——Selenium 项目

        public class BusinesLib() extends  StandLib {
    
                public void testlaunch(String URL) {
    
                        driver.get (URL);
                    }
        }
    

【问题讨论】:

  • 正确格式化和缩进你的代码
  • 以上是不是项目分别是:第一个项目"和"第二个项目",实际上是不同包中的两个不同的类?
  • 是的。 'Subh'......这是正确的。你能帮忙吗

标签: java selenium selenium-webdriver


【解决方案1】:

如果要调用第二类的实例方法,则必须创建第二类的对象并通过它调用方法。 (“秒”是类名)

Second mySecond = new Second();
mySecond.myMethod();

如果要调用第二类的静态方法,可以通过以下方式提及第二类来调用它

Second.myMethod();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-08
    • 2013-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多