Either experience...been there, done that. Or, a little research with the wiring schematics. Usually, one wire will go to a power source or, a ground. The other wire will go to a control device, of some type.
Time mark 4:40, in this video, shows ScannerDanner Figuring this out for a circuit with both wires going to the computer, and now indication of which wire is which.
"Knowledge is a weapon. Arm yourself, well, before going to do battle."
"Understanding a question is half an answer." I have learned more by being wrong, than I have by being right.