Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

2 like 0 dislike
2.7k views
by The go-to Tester (262 points)
retagged by
String[] member = (String[]) map.get("memberid");

Getting class cast exception. Please help me
by The go-to Tester (181 points)
Can you post exact exception stacktrace from console by replying to this comment?
by The go-to Tester (262 points)
java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;
    at com.owler.rest.dataCard.DataCardAPITest.TestStatusCode(DataCardAPITest.java:58)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:702)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:768)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)

1 Answer

1 like 0 dislike
by The go-to Tester (181 points)

It says that you are getting response as a String. You can not cast it to array of String[]

 

To store it into String you should do something as given below.

 

String[] member = new String[] {map.get("memberid")};

 

Hope that helps!


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...