Reputation: 163
I'm trying to build a testing framework for an android application using selenium webdriver on eclipse and Appium. I'm not using Maven. The initial script to launch the app is as follows:
package executionEngine;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import io.appium.java_client.android.AndroidDriver;
public class DriverScript {
public static AndroidDriver driver = null;
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
File app = new File(System.getProperty("user.dir")+"\\BP_QASTG.apk");
// Created object of DesiredCapabilities class.
DesiredCapabilities capabilities = new DesiredCapabilities();
//capabilities.setCapability(CapabilityType.BROWSER_NAME,"");
// Set android deviceName desired capability. Set your device name.
capabilities.setCapability("deviceName", "Galaxy Tab A");
// Set android VERSION desired capability. Set your mobile device's OS version.
capabilities.setCapability(CapabilityType.VERSION, "6.0.2");
// Set android platformName desired capability. It's Android in our case here.
capabilities.setCapability("platformName", "Android");
// Set android appPackage desired capability. It is
capabilities.setCapability("appPackage", "com.rivigo.zoombp.rivigozoombpapp");
// Set android appActivity desired capability. It is
capabilities.setCapability("appActivity", "com.rivigo.zoombp.rivigozoombpapp.activity.Activity.RivigoHomeActivity");
capabilities.setCapability("app", app.getAbsolutePath());
// Set appium server address and port number in URL string.
//AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
//driver = (AndroidDriver)((new URL("http://127.0.0.1:4723/wd/hub"), capabilities));
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
}
In the above code, the line where I declare the URL is marked in RED and hovering over it shows me this message: "The type org.openqa.selenium.remote.http.HttpClient$Factory cannot be resolved. It is indirectly referenced from required .class files"
I have seen many answers asking to add required jar files; but I'm sure I have added all the jar files required. It would be great if anyone can point out the particular jar file I might have missed,if indeed that is the issue, so that I can download and add it separately.
I have seen other answers asking to remove and re-add the JRE system library or close and repair the project, etc. which did not work for me.
I have tried with eclipse-neon and eclipse-mars versions also. Please ask for any details you need,
I'm blocked here for quite sometime, help on this would be appreciated,
Thanks, Rahul
Upvotes: 1
Views: 18779
Reputation: 1
If you see this error text "Unknown HttpClient factory netty" when you run your tests, using appium 2.0 and selenium 4+. You can check your dependecy selelnium-java maven. I updated to the latest version and it works
Upvotes: 0
Reputation: 168
appium , selenium, okhttp alltogether happily, please check my answer : Appium throws an error because of the driver
Upvotes: -1
Reputation: 21
I encountered similar exception while working on automation framework which was built to serve as a base framework for UI (Mobile and Web) and AIP automation. Technologies which I was using included selenium web driver and appium for UI and Mobile automation. This was maven project and I ended up having bunch of dependencies. When I spent a hell lot time investigating my exceptions, root cause I found was dependency conflict because there were lot of dependencies which included different version of same artifact. In this case dependency in conflict was "com.squareup.okhttp3" which i had defined explicitly in my POM and same dependency is part of selenium-java as well. Please try following solution and hopefully that should work:
Exception:
Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/ConnectionPool
at org.openqa.selenium.remote.internal.OkHttpClient$Factory.<init>(OkHttpClient.java:116)
at org.openqa.selenium.remote.http.HttpClient$Factory.createDefault(HttpClient.java:66)
at org.openqa.selenium.remote.HttpCommandExecutor.<clinit>(HttpCommandExecutor.java:47)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:95)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:94)
at nz.co.flexicards.automation.framework.common.Common.BaseMobile.main(BaseMobile.java:62)
Caused by: java.lang.ClassNotFoundException: okhttp3.ConnectionPool
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 6 more
Process finished with exit code 1
Solution:
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.2.0</version>
</dependency>
Upvotes: 2
Reputation: 21
I removed all the externals libraries that I had, and then I add java-client/7.0.0. It has anything that you need, then my project worked.
https://jar-download.com/artifacts/io.appium/java-client/7.0.0/source-code
Upvotes: 0
Reputation: 2633
It might have problem with java-client jar.
After changing java-client-7.0.0 version to java-client-3.2.0 my problem is solved.
Upvotes: 0
Reputation: 91
try the below code before creating the driver object.
System.setProperty("webdriver.http.factory", "apache");
Upvotes: 1
Reputation: 11
Add the below maven dependency to your pom.xml to resolve the issue.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.4.0</version>
</dependency>
Upvotes: 0
Reputation: 1
This problem occured today.
I just switched the version of java-client from 5.0.0 to 1.2.1, and found the problem solved.
Hope this would be helpful.
Upvotes: 0
Reputation: 163
The problem got solved when I followed below steps,
Previously I added different version of java client jar; I did not add any gson jar before. Maybe these changes solved my problem. (I'm not sure though)
Regards, Rahul
Upvotes: 0
Reputation: 1331
This requires
which has set of methods to do common http and other user requests and validations.
And kindly update your selenium jar as 2.5x or more have come now
Upvotes: 0