trial and error
trial and error {n.}
A way of solving problems by trying different possible solutions until you find one that works.
John found the short circuit by trial and error.
The only way Tom could solve the algebra problem was by the method of trial and error.
Categories:
Source: A Dictionary of American Idioms