Appium version 1.4.13
xcode version 7.2
When i starting my code, i taking error in log. ideviceinstaller is instaled. Help me with this problem.
Error log: error: Failed to start an Appium session, err was: Error:
Command failed: /bin/sh -c ideviceinstaller -u
9B2E5BE1-C31B-4484-B14C-73E2554F7887 -i
/Users/Ark/Library/Developer/Xcode/DerivedData/Ark-bwydkfpusazddvfbasvrcjailpjv/Build/Products/QA-iphoneos/Ark.app
java code:
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.junit.Before;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
/**
* Created by betbull on 1/29/16.
*/
public class Runing {
public static IOSDriver driver;
public static AppiumDriver wd;
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "IOS");
capabilities.setCapability("platformVersion", "9.2");
capabilities.setCapability("deviceName", "iPhone6");
capabilities.setCapability("app", "/Users/Ark/Library/Developer/Xcode/DerivedData/Ark-bwydkfpusazddvfbasvrcjailpjv/Build/Products/QA-iphoneos/Ark.app");
driver= new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
}
I believe you need to install the ideviceinstaller prior to using Appium to perform automation tests on iOS. Quoting from here the following should help. Try running on your terminal :
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
// Wait for the command to finish.
Run: brew install ideviceinstaller
Related
I'm new to eclipse. I'm trying to start Appium test on Android devices. My preferenses:
Appium 1.8.2
jre1.8.0_191
jdk1.8.0_191
eclipse 4.9.0
TestNG
AndroidStudio 3.2.1
AndroidDeveloperTools
So after installing, configuration Appiumserver, Android SDK, Android Device Manager - next step is to start testing in Eclipse IDE I've got problem with defining URL and don't know what to do.
jar files:
java-client-6.1.0.jar
gson-2.8.5.jar
client-combined-3.9.0-sources.jar
client-combined-3.9.0.jar
seleium-3.9.0-nodeps-sources.jar
seleium-3.9.0-nodeps.jar
seleium-html-runner-3.9.0.jar
seleium-server-standalone-3.9.0.jar
TestNG
JRE System Library
that's all
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class FirstScript {
private URL serverUrl;
public static AndroidDriver driver;
public String APPIUM_PORT = "4723";
#BeforeClass
public void setUp() throws MalformedURLException{
//Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Samsung S7");
caps.setCapability("udid", "******************"); //Give Device ID of your mobile phone
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "8.0");
caps.setCapability("appPackage", "com.***.***");
caps.setCapability("appActivity", "com.***.***.MainActivity");
caps.setCapability("noReset", "true");
try {
serverUrl = new URL("http://127.0.0.1:4723/wd/hub");
} catch (MalformedURLException e) {
e.printStackTrace();
}
driver = new AndroidDriver (serverUrl,caps);
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
}
#Test
public void testExample() {***}
#AfterClass
public void tearDown() {driver.closeApp();}
}
Running debug for this code with error
Server is working
The solution to your issue is that you use latest stable version of Selenium i.e. 3.141.5
If you're having Java project then, before adding new latest version of jar's make sure to first remove all selenium related old jar's and then add newly downloaded version of the jar's to build path.
In case of Maven project, update the selenium dependency version to latest and run following on terminal,
$ mvn clean install
I suggest you to use maven project and the dependencies: java-client, selenium-java and testng.
If you don't want to use maven project, you need to import above libraries in eclipse. For that From your Eclipse workspace, right click your project on the left pane -> Properties -> Java Build Path -> Add Jars -> add your jars there.
Change your code as follow:
public class FirstScript {
public static AppiumDriver<MobileElement> driver;
#BeforeClass
public void setUp() throws MalformedURLException{
//Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Samsung S7");
caps.setCapability("udid", "******************"); //Give Device ID of your mobile phone
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "8.0");
caps.setCapability("appPackage", "com.***.***");
caps.setCapability("appActivity", "com.***.***.MainActivity");
caps.setCapability("noReset", "true");
driver = new AndroidDriver (new URL("http://127.0.0.1:4723/wd/hub"),caps);
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
}
}
Unable to build Selenium Script in Jenkins.
Generating error related to Browser driver.
Working Code in Eclipse with Maven
package test;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import java.net.MalformedURLException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
public class NewTest {
private WebDriver driver;
#Test
public void testEasy() throws InterruptedException {
System.out.println("Testing");
driver.get("http://www.google.com/");
Thread.sleep(5000);
String title = driver.getTitle();
}
#SuppressWarnings("deprecation")
#BeforeTest
public void beforeTest() throws MalformedURLException {
System.out.println("#BeforeTest");
//System.setProperty("webdriver.gecko.driver", "F:\\Selenium\\Selenium Library\\drivers\\geckodriver.exe");
//Now you can Initialize marionette driver to launch firefox
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
/*FirefoxOptions options = new FirefoxOptions()
.addPreference("browser.startup.page", 1)
.addPreference("browser.startup.homepage", "http://demo.guru99.com/test/guru99home/");
driver = new FirefoxDriver(options);
*/
driver = new FirefoxDriver();
}
#AfterTest
public void afterTest() {
System.out.println("##AfterTest");
driver.quit();
}
}
After trying to run POM.xml build in Jenkins. It's result failed because of Unable to execute gecko driver.
enter image description here
Failed
test.NewTest.beforeTest (from TestSuite)
Failing for the past 26 builds (Since Unstable#11 )
Took 1.2 sec.
add description
Error Message
The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
Stacktrace
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
at test.NewTest.beforeTest(NewTest.java:39)
Standard Output
#BeforeTest
Standard Error
Apr 20, 2018 2:12:36 PM org.openqa.selenium.remote.DesiredCapabilities firefox
INFO: Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
Any one have idea about how to resolved this issue please provide me solution for that
i have written simple script, which launches an chrome app on Android N(7.0),but not able to run, getting error
Details Environment
Appium version (or git revision) that exhibits the issue: 1.4.16.1
Last Appium version that did not exhibit the issue (if applicable): N/A
Desktop OS/version used to run Appium: window 7/32 bit
Node.js version (unless using Appium.app|exe): node-v8.9.4-x86
Mobile platform/version under test: chrome browser /64.0.3282.123
Real device or emulator/simulator:Android 7.0.0:MotoG(4)/Build/NPJS25.93-14-10
Appium CLI or Appium.app|exe: Appium Desktop exe
Error logs
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c "D:\android-sdk\platform-tools\adb.exe -s ZY2239HZB2 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk""\nadb: failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.unlock without first uninstalling.]\r\n)","killed":false,"code":1,"signal":null,"cmd":"C:\Windows\system32\cmd.exe /s /c "D:\android-sdk\platform-tools\adb.exe -s ZY2239HZB2 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk""","origValue":"Command failed: C:\Windows\system32\cmd.exe /s /c "D:\android-sdk\platform-tools\adb.exe -s ZY2239HZB2 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk""\nadb: failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.unlock without first uninstalling.]\r\n"},"sessionId":null}
code:
import java.net.MalformedURLException;
import java.net.URL;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
//import org.testng.annotations.Test;
public class StartChrome
{
public static void main(String[] args) throws MalformedURLException{
DesiredCapabilities cd=DesiredCapabilities.android();
cd.setCapability(MobileCapabilityType.BROWSER_NAME,BrowserType.CHROME);
cd.setCapability(MobileCapabilityType.PLATFORM,Platform.ANDROID);
// we need to define platform name
cd.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
// Set the device name as well (you can give any name)
cd.setCapability(MobileCapabilityType.DEVICE_NAME,"my phone");
// set the android version as well
cd.setCapability(MobileCapabilityType.VERSION,"7.0");
// Create object of URL class and specify the appium server address
URL url= new URL("http://127.0.0.1:4723/wd/hub");
// Create object of AndroidDriver class and pass the url and capability that we created
WebDriver driver = new AndroidDriver(url, cd);
// Open url
driver.get("http://www.facebook.com");
// print the title
System.out.println("Title "+driver.getTitle());
// enter username
driver.findElement(By.name("email")).sendKeys("sni****#gmail.com");
// enter password
driver.findElement(By.name("pass")).sendKeys("*****8");
// click on submit button
driver.findElement(By.id("u_0_5")).click();
// close the browser
driver.quit();
Please update your Appium version as it's very old and you're seeing a known issue with Android 7.0 that was resolved in 1.6.0 (released October 2016).
If that's not possible, run the following commands before running your script:
adb -s device_serial uninstall io.appium.settings
adb -s device_serial uninstall io.appium.unlock
Genymotion with VirtualBox download from genymotion site and install properly
Add Genymotion pluging on eclipse and set Genymotion directory
Add virtual device Nexus9 os version 5.1.0 API 22
Add Selenium and Appium java client jar files under project
Use Genymotion Android Tool and Custom Android SDK tool as Genymotion ADB tool connection setting
Configure Appium Setting and run Appium
Run below source code on eclipse
import java.io.IOException;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.URL;
import io.appium.java_client.android.AndroidDriver;
public class Firstappium {
static String deviceName = "Nexus9-5.1.0API22";
static WebDriver driver;
static String url ="http://127.0.0.1:4720/wd/hub";
public static void main(String[] args) {
DefaultExecuteResultHandler resultHandler;
DesiredCapabilities capabilities = new DesiredCapabilities();
DefaultExecutor executor = new DefaultExecutor();
resultHandler = new DefaultExecuteResultHandler();
capabilities.setCapability("deviceName","Nexus9-5.1.0API22");
capabilities.setCapability("platformVersion", "5.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app","G:/appium/apk/cz.hipercalc.apk");
driver = new AndroidDriver(new URL(url),capabilities);
System.out.println("Appium Driver is launched successfully");
}
}
Every time Appium can't find to the Genymotion emulator within session time. Please check attached screen shot
Friends,
Trying to run appium script on ios actual device,gets below error
Eclipse error:
[TestNG] Running:
/private/var/folders/05/79kfthm94qjd3bngd2l5pv7r0mx69v/T/testng-eclipse--1690789728/testng-customsuite.xml
FAILED CONFIGURATION: #BeforeClass setUpBeforeClass
org.openqa.selenium.SessionNotCreatedException: A new session could
not be created. (Original error: Command failed: /bin/sh -c xcrun
--sdk iphonesimulator --show-sdk-version) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15.00 seconds
Build info: version: '2.51.0', revision: '1af067d', time:
'2016-02-05 19:15:17'
System info: host: 'NCA047065', ip: '10.65.210.61', os.name: 'Mac
OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version:
'1.7.0_79'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
And .java code:
import org.junit.BeforeClass;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
import java.io.File;
import java.net.URL;
import java.util.concurrent.TimeUnit;
public class iOSApptest {
public static RemoteWebDriver driver;
#BeforeClass
public static void setUpBeforeClass() throws Exception
{
File appDir = new File ("//Users//gangaiahl//Appium//jars");
File app = new File (appDir, "Car.ipa");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "firefox");
capabilities.setCapability("device", "iPhone 6");
capabilities.setCapability("u_did", "840384833537f40d011032eaaf20a53705a451ce");
capabilities.setCapability("bundle_id", "au.dev.com.onewaytraffic.carsguide");
capabilities.setCapability("deviceName", "Cars_iPhone_6");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "9.2");
capabilities.setCapability("app",app.getAbsolutePath());
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
#Test
public void test()
{
System.out.println("Test started");
//System.out.println(" Start to identify a test");
//System.out.println("Test Completed");
}
}
It seems wrong capability
capabilities.setCapability("u_did",
"840384833537f40d011032eaaf20a53705a451ce");
Try use "udid" key instead of "u_did"
See documentation
You can try since that could have to do with the libxml library according to a quick google search.
$ brew uninstall libxml2
$ brew prune
$ brew install libxml2
You should also try and update your Xcode command line tools. Since its failing when trying to use the xcrun command.
Xcode 11
Try installing command-line tools from https://developer.apple.com/download/more/
This solved my error