Nobody did a correlational study between electability and judge or prosecutor competence either.
Would you agree knowledge of the law is a better, if still imperfect, indicator of ability as a judge or prosecutor than being merely appealing to voters?
In any case, I think a competitive exam is better than law school grades. It allows for applicants who didn't do so well in law school but got better later.
It's hard to craft an exam that isn't mostly testing how good the examinee is at writing exams. Things like the SAT, LSAT, GRE, etc... are good predictors of near-future academic success but not very useful beyond that.
So, I think an exam is a bad idea unless it's a pass/fail exam (ie no grades, you either understand the law or you do not) and there should be no meaningful time constraint when completing the exam. That's basically the system in most states today, except the training comes after someone without a law degree is elected.
There are state and federal oversight mechanisms with the power to remove bad judges.