I am trying to understand the concepts provided by jonahss at below location:
ContextTest
I copied the code into Eclipse and wanted to test how it execute in Android Emulator. I am working on Windows 7 machine.
I copies the webapp application specified into my “D:\UD\jars\” path executed the below code:
public class ContextTest
{
private AndroidDriver driver;
@Before
public void setup() throws Exception
{
File appDir = new File("D:\\UD\\jars\\");
File app = new File(appDir, "WebViewApp.app.zip");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
// capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Testing");
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@After
public void tearDown() throws Exception
{
driver.quit();
}
@Test
public void testGetContext()
{
assertEquals("NATIVE_APP", driver.getContext());
}
@Test
public void testGetContextHandles()
{
assertEquals(driver.getContextHandles().size(), 2);
}
@Test
public void testSwitchContext()
{
driver.getContextHandles();
driver.context("WEBVIEW_1");
assertEquals(driver.getContext(), "WEBVIEW_1");
}
@Test(expected = NoSuchContextException.class)
public void testContextError()
{
driver.context("Planet of the Ape-ium");
}
}
After executing the test, i am getting below error. Is the code only works on iOS else is compatabile with Android also? Where actually i am going wrong and how can i solve this problem?
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"D:\\UD\\jars\\WebViewApp.app.zip","browserName":"","platformName":"Android","deviceName":"Testing"}}
> info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
> info: [debug] No appActivity desired capability or server param. Parsing from apk.
> info: [debug] No appPackage desired capability or server param. Parsing from apk.
> info: [debug] Using local .zip from desired caps: D:\UD\jars\WebViewApp.app.zip
> info: [debug] Copying local zip to tmp dir
> info: [debug] D:\UD\jars\WebViewApp.app.zip copied to C:\Users\user\AppData\Local\Temp\11529-1948-mqlqs1\appium-app.zip
> info: [debug] Got configuration error, not starting session
> error: Failed to start an Appium session, err was: Error: Bad app: D:\UD\jars\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,
> operable program or batch file.
>
> info: [debug] Cleaning up appium session
> info: [debug] Error: Bad app: D:\UD\jars\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,
> operable program or batch file.
>
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\android\android-common.js:56:13)
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\device.js:88:26)
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\device.js:167:7)
> at D:\softies\Programs\Appium\node_modules\appium\lib\helpers.js:143:7
> at ChildProcess.exithandler (child_process.js:641:7)
> at ChildProcess.EventEmitter.emit (events.js:98:17)
> at maybeClose (child_process.js:743:16)
> at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Bad app: D:\\UD\\jars\\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n)","origValue":"Bad app: D:\\UD\\jars\\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 118.002 ms - 726
> info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"D:\\UD\\jars\\WebViewApp.app.zip","browserName":"","platformName":"Android","deviceName":"Testing"}}
> info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
> info: [debug] No appActivity desired capability or server param. Parsing from apk.
> info: [debug] No appPackage desired capability or server param. Parsing from apk.
> info: [debug] Using local .zip from desired caps: D:\UD\jars\WebViewApp.app.zip
> info: [debug] Copying local zip to tmp dir
> info: [debug] D:\UD\jars\WebViewApp.app.zip copied to C:\Users\user\AppData\Local\Temp\11529-1948-1jqoa47\appium-app.zip
> info: [debug] Got configuration error, not starting session
> error: Failed to start an Appium session, err was: Error: Bad app: D:\UD\jars\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,
> operable program or batch file.
>
> info: [debug] Cleaning up appium session
> info: [debug] Error: Bad app: D:\UD\jars\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,
> operable program or batch file.
>
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\android\android-common.js:56:13)
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\device.js:88:26)
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\device.js:167:7)
> at D:\softies\Programs\Appium\node_modules\appium\lib\helpers.js:143:7
> at ChildProcess.exithandler (child_process.js:641:7)
> at ChildProcess.EventEmitter.emit (events.js:98:17)
> at maybeClose (child_process.js:743:16)
> at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Bad app: D:\\UD\\jars\\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n)","origValue":"Bad app: D:\\UD\\jars\\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 52.072 ms - 726
> info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"D:\\UD\\jars\\WebViewApp.app.zip","browserName":"","platformName":"Android","deviceName":"Testing"}}
> info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
> info: [debug] No appActivity desired capability or server param. Parsing from apk.
> info: [debug] No appPackage desired capability or server param. Parsing from apk.
> info: [debug] Using local .zip from desired caps: D:\UD\jars\WebViewApp.app.zip
> info: [debug] Copying local zip to tmp dir
> info: [debug] D:\UD\jars\WebViewApp.app.zip copied to C:\Users\user\AppData\Local\Temp\11529-1948-jh1h8p\appium-app.zip
> error: Failed to start an Appium session, err was: Error: Bad app: D:\UD\jars\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,
> operable program or batch file.
>
> info: [debug] Cleaning up appium session
> info: [debug] Error: Bad app: D:\UD\jars\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,
> operable program or batch file.
>
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\android\android-common.js:56:13)
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\device.js:88:26)
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\device.js:167:7)
> at D:\softies\Programs\Appium\node_modules\appium\lib\helpers.js:143:7
> at ChildProcess.exithandler (child_process.js:641:7)
> at ChildProcess.EventEmitter.emit (events.js:98:17)
> at maybeClose (child_process.js:743:16)
> at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Bad app: D:\\UD\\jars\\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n)","origValue":"Bad app: D:\\UD\\jars\\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 68.095 ms - 726
> info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"D:\\UD\\jars\\WebViewApp.app.zip","browserName":"","platformName":"Android","deviceName":"Testing"}}
> info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
> info: [debug] No appActivity desired capability or server param. Parsing from apk.
> info: [debug] No appPackage desired capability or server param. Parsing from apk.
> info: [debug] Using local .zip from desired caps: D:\UD\jars\WebViewApp.app.zip
> info: [debug] Copying local zip to tmp dir
> info: [debug] D:\UD\jars\WebViewApp.app.zip copied to C:\Users\user\AppData\Local\Temp\11529-1948-t9f4v8\appium-app.zip
> info: [debug] Got configuration error, not starting session
> error: Failed to start an Appium session, err was: Error: Bad app: D:\UD\jars\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,
> operable program or batch file.
>
> info: [debug] Cleaning up appium session
> info: [debug] Error: Bad app: D:\UD\jars\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,
> operable program or batch file.
>
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\android\android-common.js:56:13)
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\device.js:88:26)
> at null.<anonymous> (D:\softies\Programs\Appium\node_modules\appium\lib\devices\device.js:167:7)
> at D:\softies\Programs\Appium\node_modules\appium\lib\helpers.js:143:7
> at ChildProcess.exithandler (child_process.js:641:7)
> at ChildProcess.EventEmitter.emit (events.js:98:17)
> at maybeClose (child_process.js:743:16)
> at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Bad app: D:\\UD\\jars\\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n)","origValue":"Bad app: D:\\UD\\jars\\WebViewApp.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Command failed: 'xargs' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 49.802 ms - 726