Please Help

83 views
Skip to first unread message

rajiv shankar

unread,
Nov 25, 2013, 4:38:51 AM11/25/13
to appium-...@googlegroups.com
Hi,

I am getting error while executing the below code. Please help.

I am trying to run it on android simulator from windows system.

I have pasted code as well as error screenshot(attached) here :


package com.stc.one;

import java.net.MalformedURLException;
import java.net.URL;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.*;

public class CalculatorTest {

WebDriver driver;

@Before
public void setUp() throws MalformedURLException{

//Set up desired capabilities and pass the Android app-activity and app-package to Appium
DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
capabilities.setCapability(CapabilityType.VERSION, "4.4");
capabilities.setCapability(CapabilityType.PLATFORM, "Windows");
capabilities.setCapability("app-package", "com.android.calculator2"); // This is package name of your app (you can get it from apk info app)
capabilities.setCapability("app-activity", "com.android.calculator2.Calculator"); // This is Launcher activity of your app (you can get it from apk info app)
//Create RemoteWebDriver instance and connect to the Appium server.
//It will launch the Calculator App in Android Device using the configurations specified in Desired Capabilities
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

}
@Test
public void testCal(){
//locate the Text on the calculator by using By.name()
WebElement two=driver.findElement(By.name("2"));
two.click();
WebElement plus=driver.findElement(By.name("+"));
plus.click();
WebElement four=driver.findElement(By.name("4"));
four.click();
WebElement equalTo=driver.findElement(By.name("="));
equalTo.click();
//locate the edit box of the calculator by using By.tagName()
WebElement results=driver.findElement(By.tagName("EditText"));
//Check the calculated value on the edit box
assert results.getText().equals("6"):"Actual value is : "+results.getText()+" did not match with expected value: 6";
}

@After
public void teardown(){
//close the app
driver.quit();
}
}

Regards,
Rajiv
AppiumError.JPG
jUnitError.JPG

Tejesh G

unread,
Nov 25, 2013, 5:15:27 AM11/25/13
to appium-...@googlegroups.com
Re-start the Appium session and try. Appium session sometimes does not get terminated. Make sure you have driver.quit at the end of your script

rajiv shankar

unread,
Nov 25, 2013, 5:19:40 AM11/25/13
to appium-...@googlegroups.com
Hi Tejesh,

I tried it several times but still not working.

Yes, I have driver.quit at the end of my script.

Tejesh G

unread,
Nov 25, 2013, 7:45:05 AM11/25/13
to appium-...@googlegroups.com
I would advise to re-start the emulator and also the Appium and then try executing ,cos I have faced similar issue and restarting the emulator and the Appium worked for me.
Appium version Im using is 0.11.3 .If you are using the older version, just try it out using the Appium version 0.11.3. Guess this is the latest version.

rajiv shankar

unread,
Nov 25, 2013, 8:21:52 AM11/25/13
to Tejesh G, appium-...@googlegroups.com
Hi Tejesh,

I tried with re-start of the emulator but it did not worked even after that.

Finally, I re-started my system and gave one try again.

This time it worked for me :)

Not sure, what was the problem, but it is working now.

Thanks for the help.

Regards.
Rajiv

Best wishes,

Rajiv Shankar Pandey | Senior Software Test Engineer

 

Aditya Birla Minacs | accelerating businesses for 30 years

2nd Floor Millenium Towers, ITPL Road, Brookefields, Bengaluru - 560 037, India

Phone +91 80 43415000 | Extn 117391 | Mobile +91 9620662468 | www.minacs.adityabirla.com | Follow us on Twitter



--
http://appium.io
---
You received this message because you are subscribed to a topic in the Google Groups "Appium-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/appium-discuss/qadAN76GHYs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Tejesh G

unread,
Nov 26, 2013, 12:24:07 AM11/26/13
to appium-...@googlegroups.com, Tejesh G
cool :)

Purbasha Priyadarshini

unread,
Dec 30, 2013, 1:43:48 AM12/30/13
to appium-...@googlegroups.com, Tejesh G
Hi Rajiv,

I am new to Appium. While was trying to launch it on Android, I found the similar error, you faced. Tried restarting the system as well as restarting the emulator.

But still getting the same error.

Could you please help.

Attached are the snapshots of the error.

Thanks,
Purbasha
Appium.JPG
FailureTraceJunit.JPG
Reply all
Reply to author
Forward
0 new messages