Search code examples
javagithubappium

After cloning Git repository in eclipse, throwing an error "Error: Could not find or load main class tests.Baseclass"


I'm working on java and appium. I pushed my project(code) to Github( which includes .classpath, .gitignore, .project, pom.xml). I clone the same project(code) in another machine and then i tried executing it using eclipse.

But i observed after clonig the Git repository (.classpath, .gitignore, ,project) are not cloned at all.

I was getting an error:

Error: Could not find or load main class tests.Baseclass

Eclipse project:

screenshot

I gone through some answers and couldn't find solution. Appreciate your help. Thanks in advance.

I tried changing some run configurations. But still issue is not resolved.

public class Baseclass {

    public static void main(String[] args) {
        //Set the Desired Capabilities
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("deviceName", "My Phone");
        caps.setCapability("udid", "XXXXXX"); 
        caps.setCapability("platformName", "Android");
        caps.setCapability("platformVersion", "9.0");
        caps.setCapability("appPackage", "com.xxx.xxx");
        caps.setCapability("appActivity", "com.xxxxxx.xxx.MainActivity");
        caps.setCapability("noReset", "true");
        caps.setCapability("unicodeKeyboard", true);
        caps.setCapability("resetKeyboard", true);
        try {
                AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps);
                driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
                //driver.findElementByClassName("android.widget.TextView").click();
                driver.findElement(By.xpath("//*[@text ='SIGN IN']")).click();
                driver.findElement(By.xpath("//*[@text ='Email address']")).sendKeys("mobasasas@gmail.com");
                driver.findElement(By.xpath("//*[@text ='Password']")).sendKeys("qqqwqdasdwq55");
                driver.findElement(By.xpath("//*[@text ='CONTINUE']")).click();
                System.out.println("Signed In Successfuly");



        } catch (MalformedURLException e) {
            System.out.println(e.getMessage());
        }


    }

}

Solution

  • The project is not built yet in the Eclipse as per the screenshot(The red exclamation mark near the project name).

    1. Right Click on the project and click on Properties
    2. Choose Build Path > Configure Build Path

    Check whether there are any errors or warnings.

    You can also view Problems with the project in Windows-> Show View -> Problems

    Until these issues are resolved, the project will not be built and the class won't be identified.