2

This is my selenium code. After I ran this code, I am getting a java.lang.AbstractMethodError.

package amazon;
import io.appium.java_client.android.AndroidDriver; 
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

public class StartApplication {

private static AndroidDriver driver;

public static void main(String[] args) throws MalformedURLException, InterruptedException {

        File app = new File("C:\\Users\\Dexter\\Desktop\\Appium\\AmazonTest\\com.amazon.mShop.android.shopping.apk");

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("deviceName", "Samsung Galaxy J7");
        capabilities.setCapability("platformVersion", "8.1.0");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("app", app.getAbsolutePath());
        capabilities.setCapability("appPackage", "in.amazon.mShop.android.shopping");
        capabilities.setCapability("appActivity", "com.amazon.mShop.home.web.MShopWebGatewayActivity");

        driver = new AndroidDriver(new URL("https://xxx.xxx.xxx.xxx:xxxx/wd/hub"), capabilities);
        driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
        Thread.sleep(3000);
         driver.quit();

  }

}

Following is the error, I am getting -

Exception in thread "main" java.lang.AbstractMethodError: org.openqa.selenium.remote.internal.ApacheHttpClient.execute(Lorg/openqa/selenium/remote/http/HttpRequest;)Lorg/openqa/selenium/remote/http/HttpResponse;
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:105)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:69)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:36)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:114)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:132)
    at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:92)
    at amazon.StartApplication.main(StartApplication.java:32)

If anybody has any solution, kindly let me know.

  • I think this is caused by version inconsistency between your AndroidDriver version and your Appium server. – Alexey R. Jan 25 at 10:02
  • can you suggest any specific version I can use to fix this issue? @AlexeyR. – Rishikesh Jan 25 at 10:09
1

You are getting errors from your Appium backend that are causing the http requests that your Selenium drivers are trying to make.

I would check the Appium backend is running and allows connections from your client.

Possible reasons for it not running :

  • driver versions don't match - the Android Driver might need updating
  • device is not connected/visible - the actual device might not be visible.
  • Appium isn't running - restart Appium and check the logs

You can test your backend is working by running Appium studio and using its GUI.

You can also do a lot of those things within exception handlers which could attempt retries or at least give you more information.

I will never understand why people think its sensible to write Selenium tests in Java; compiled languages make this so much harder and can add 10s of thousands to project costs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.