是否可以从多个类调用函数

时间:2014-10-16 11:27:40

标签: java class inheritance

这是一个场景:

点击某个地区 - >从列表中选择一个国家/地区>单击列出的进程之一 - >浏览输入文件的位置 - >上传并执行该过程。

这是一个地区以及其他9个地区的其他国家的基本流程。

我做的是: 为Regions创建了一个类(没有main函数), 在本规范中,亚太地区和加拿大都是地区。

public class Regions {


// For Clicking APAC
public static void APAC(WebDriver Driver)
{
WebElement APAC = Driver.findElement(By.xpath("//*[@id='APC']"));
APAC.click();
}
// For Clicking Canada

public static void Canada(WebDriver Driver)
{
WebElement Canada = Driver.findElement(By.xpath("//*[@id='CAN']"));
Canada.click();
}

为Processes创建一个类(没有main函数), 在这里,Paycost,Payroll是流程

public class Processes {


public void Paycost(WebDriver Driver)
{
    WebElement Paycost = Driver.findElement(By.id("PaycostProcess"));
    Paycost.click();
}
public void Miscellaneous_process(WebDriver Driver)
{
    WebElement Miscellaneous = Driver.findElement(By.id("MiscellaneousProcess-V1"));
    Miscellaneous.click(); 
}

为浏览上传执行的剩余操作创建了一个类(没有main函数),

 public class Others{
 public static void Upload(WebDriver Driver)
{

    WebElement Upload = Driver.findElement(By.id("UploadButton"));
    Upload.click();
}

// Clicking on the Execute button(13)

public static void Execute(WebDriver Driver)
{
    //WebDriver Driver = InternetExplorerDriver();
    WebElement Execute = Driver.findElement(By.id("Executing"));
    Execute.click();
}

现在在具有Main功能的Class中,我试图从3个不同的类中调用方法...

public class APAC_BU extends Others{
public static void main(String[] args) throws InterruptedException {

    IE_Call();      // Calling from others class 
    WebDriver Driver =  new InternetExplorerDriver();
    Driver.get(""); 
    Thread.sleep(5000);
    APAC(Driver, "a4106"); // Calling from Regions Class
    Thread.sleep(5000);
    Country_Selection(Driver);
        Paycost(Driver); // Calling from processes class
}

但我不能说它在Java中不可能实现多重继承。任何人都可以帮我找到解决这个问题的方法。

我可以在单个类本身中调出所有方法,但是在调用函数时我发现它有点混乱。

我在自动化和Java方面做得太多了。如果我错了,请纠正我。

我想为每个类创建一个接口,如接口1为Class Processes接口2接口,为其他类创建接口3.将这个接口组合在一起,然后从主类中调用它。 在调用它时,它将进入分组接口并调用所需的方法。

这只是我的想法,我还不清楚界面概念:( 请帮忙吧

先谢谢!!!!!

0 个答案:

没有答案