Execute my First Appium Script


#1

Code:-

final String URL_STRING = “http://127.0.0.1:4723/wd/hub”;
URL url = new URL(URL_STRING);

	DesiredCapabilities dc=new DesiredCapabilities();
	
	dc.setCapability(CapabilityType.BROWSER_NAME, "");
	
	dc.setCapability("deviceName","My Android");
	
	dc.setCapability("platformVersion", "4.3");
	
	dc.setCapability("platformVersion", "Android");
	
	dc.setCapability("appPackage","io.selendroid.testapp");
	
	dc.setCapability("appActivity", ".HomeScreenActivity");
	
	//driver=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),dc);
	
	//driver=new AndroidDriver(new URI("http://127.0.0.1:4723/wd/hub"),dc);
	
	driver = new AndroidDriver<>(url, dc);
	
	driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	
	driver.findElement(By.xpath("//android.widget.EditText[@content-desc='my_text_fieldCD']")).sendKeys("Himmat Kadam");
	
	Thread.sleep(5000);

Output :-

Exception in thread “main” java.lang.NoClassDefFoundError: org/openqa/selenium/remote/ProtocolHandshake
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:93)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:95)
at Classes.SampleJava.main(SampleJava.java:45)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.ProtocolHandshake
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 3 more