Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.openqa.selenium.WebDriverException: No command or response codec has been defined. Unable to proceed

I am using appium to automate mobile application but this above exception occurs after application launch on emulator or mobile device when I try to perform some operation on the application i.e clicking the login button... Does any one know what is wrong with it?>Error Screenshot

Complete code is as follows

import static org.junit.Assert.*;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;

public class selendriodCase {

    @Test
    public void test() throws MalformedURLException, InterruptedException {
         File appDir = new File("src");

            File app = new File(appDir, "EZMD1.apk");



        DesiredCapabilities cap=new DesiredCapabilities();
        cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
        cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
        // specify the application package that we copied from appium                
        cap.setCapability("appPackage", "com.mentor.mobile.csp.ezmobiledocs");
        // specify the application activity that we copied from appium                   
        cap.setCapability("appActivity", "com.mentor.mobile.csp.ezmobiledocs.SplashActivity");


        cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "100");
        System.out.println("ahmad");
        cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
        AndroidDriver ds = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
        //AndroidDriver driver=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap );
        System.out.println("ahmad");

        Thread.sleep(10000);
        ds.findElementById("com.mentor.mobile.csp.ezmobiledocs:id/facebook").click();

    }

}

When click operation is perform it shows the following exception

org.openqa.selenium.WebDriverException: No command or response codec has been defined. Unable to proceed
Build info: version: 'unknown', revision: '3169782', time: '2016-09-29 10:24:50 -0700'
System info: host: 'PKL-AIQBAL-W7', ip: '137.202.157.127', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_91'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:153)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:602)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:369)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:418)
    at DesiredCap.test(DesiredCap.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)

    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)enter code here

    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
like image 461
Ahmad Iqbal Avatar asked Jan 10 '17 09:01

Ahmad Iqbal


2 Answers

Try with the latest jar files below
http://central.maven.org/maven2/io/appium/java-client/4.0.0/java-client-4.0.0.jar

ds = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); Try this it will work.

like image 104
Pradap Pandian Avatar answered Oct 31 '22 15:10

Pradap Pandian


Please update your java-client version (jar file) to latest. I updated mine from 4.0 to 4.1.2 and it worked for me. Here

like image 38
Star Avatar answered Oct 31 '22 16:10

Star