java-client icon indicating copy to clipboard operation
java-client copied to clipboard

Getting Exception while trying to connect ios simulator with ios appium driver

Open Sourabh25 opened this issue 5 years ago • 6 comments

The problem

Getting the below exception

java.lang.NoSuchMethodError: org.openqa.selenium.remote.http.HttpClient$Factory.createDefault()Lorg/openqa/selenium/remote/http/HttpClient$Factory;
	at io.appium.java_client.remote.AppiumCommandExecutor.<init>(AppiumCommandExecutor.java:93)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:95)
	at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:92)
	at com.comcast.xfinity.scenarios.TestIOSDriver.TestSafariOnIOS(TestIOSDriver.java:53)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
	at org.testng.TestRunner.privateRun(TestRunner.java:774)
	at org.testng.TestRunner.run(TestRunner.java:624)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
	at org.testng.SuiteRunner.run(SuiteRunner.java:261)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1191)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
	at org.testng.TestNG.run(TestNG.java:1024)
	at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Environment

  • Appium version (or git revision) that exhibits the issue: appium java client -7.1.0
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: macOS mojave v 10.14.5
  • Node.js version (unless using Appium.app|exe): 12.6.0
  • Npm or Yarn package manager: Npm
  • Mobile platform/version under test: IOS 12.4
  • Real device or emulator/simulator: Emulator
  • Appium CLI or Appium.app|exe: terminal

Code To Reproduce Issue [ Good To Have ]

package com.comcast.xfinity.scenarios;

import java.io.IOException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

import io.appium.java_client.ios.IOSDriver;

public class TestIOSDriver {
	
	@Test
	public void TestSafariOnIOS() throws IOException, InterruptedException {
	
		
		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability("platformVersion", "12.4");
		capabilities.setCapability("browserName", "Safari");
		capabilities.setCapability("deviceName", "iPhone 8");
		capabilities.setCapability("platformName", "IOS");
		capabilities.setCapability("udid", "FFFFB0BD-B7A2-4DDC-8456-C92201FF32B7");
		capabilities.setCapability("automationName", "XCUITest");
		capabilities.setCapability ("platformName", "iOS");
		capabilities.setCapability("xcodeOrgId", "85299US2MH");
        capabilities.setCapability("xcodeSigningId", "iPhone Developer");
        capabilities.setCapability("webkitResponseTimeout", "90000");
		URL url = new URL("http://0.0.0.0:4723/wd/hub");
		IOSDriver driver = new IOSDriver(url, capabilities);
		driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
		driver.get("http://google.com");
	}

}

Sourabh25 avatar Jul 30 '19 21:07 Sourabh25

Moving to the Java client, which may have more help.

imurchie avatar Jul 30 '19 22:07 imurchie

This issue is not appearing if change the version of Appium-java-client to 5.0.4

Sourabh25 avatar Jul 31 '19 02:07 Sourabh25

@Sourabh25 Please make sure you don't use any selenium dependency as java-client comes with selenium and then invalidate your cache and restart your IDE

saikrishna321 avatar Jul 31 '19 20:07 saikrishna321

Okay so it is working with Appium 7.1.0 java-client if I remove the selenium dependency. But now I have a project which wants to support both web and mobile. So I need selenium-server dependency to be added in my pom file. How can I handle that?

Sourabh25 avatar Aug 01 '19 17:08 Sourabh25

So I need selenium-server dependency to be added in my pom file

Why can't you use with the selenium-dependency that java-client already has ?

saikrishna321 avatar Aug 02 '19 20:08 saikrishna321

Had same issue and updated selenoum-server tp following and error disapeared -

`

        <groupId>org.seleniumhq.selenium</groupId>

        <artifactId>selenium-server</artifactId>

        <version>3.141.59</version>

`

tarun3kumar avatar Apr 05 '21 15:04 tarun3kumar