I can not run this mobile automation script and it give me this error

90 Views Asked by At

CODE:

package assessmentForSale;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;
public class Calculator {

    public static AndroidDriver driver;
    public static void main(String[] args) {
        try {
            OpenCalculator();
        } catch (Exception exp) {
            System.out.println(exp.getCause());
            System.out.println(exp.getMessage());
            exp.printStackTrace();
        }
    }
    public static void OpenCalculator() throws Exception {

        DesiredCapabilities cap = new DesiredCapabilities();
        //device capabilities
        cap.setCapability("deviceName","Redmi");
        cap.setCapability("udid","8727c8a1");
        cap.setCapability("platformName","Android");
        cap.setCapability("platformVersion","9.0.0");
        //App capabilities
        cap.setCapability("AppPackage","com.miui.calculator");
        cap.setCapability("AppActivity","com.miui.calculator.cal.CalculatorActivity");

        URL url = new URL("http://0.0.0.0:4723/wd/hub");
        driver = new AndroidDriver(url,cap);

        System.out.println("Application has started...");
    }
}


Error: Could not find or load main class assessmentForSale.Calculator Caused by: java.lang.ClassNotFoundException: assessmentForSale.Calculator

i've looked into many resources and they assumed that this happens because the white spaces so i 've removed all white spaces from the code and the naming of the class might be wrong but i think mine is fine.

1

There are 1 best solutions below

0
On

Looks like you copied this example and package assessmentForSale doesn't exist
Please look at this topic