mosil / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.EditText #565

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  EditText editText = (EditText) 
solo.getCurrentActivity().findViewById(SRC_R.id.username);
    solo.enterText(editText, "Username");
2.  EditText editText = (EditText) solo.getView(SRC_R.id.pinValue);
    solo.enterText(editText, "Username");

What is the expected output? What do you see instead?
java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to 
android.widget.EditText
at com.mob.page.SignInPage.enterUsername(SignInPage.java:75)
at com.mob.test.SignInTest.test1_SignInWithmobAccount(SignInTest.java:35)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at 
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at 
android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTes
tCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:55
4)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)

What version of the product are you using? On what operating system?
robotium-solo-4.3.jar, Android 4.3.1

Please provide any additional information below.
I don't know why this misbehaviour , apart from this project above command 
working fine.

Please let know what could be the problem and how to resolve.

Original issue reported on code.google.com by mgmanika...@gmail.com on 14 Dec 2013 at 12:41

GoogleCodeExporter commented 9 years ago
You trying to cast a LinerLayout to an EditText. You need to use the correct 
resource ID. If you dont know the resource ID you can use enterText with index 
instead. Please see the javadoc.

Original comment by renasr...@gmail.com on 15 Dec 2013 at 8:35

GoogleCodeExporter commented 9 years ago
Thank you for reply.

Above mention  resource ID's are corresponding EditText ID only, I got these 
ID's via  hieararchyviewer.

So what could be the issue. Please help me.

Original comment by mgmanika...@gmail.com on 15 Dec 2013 at 1:10