You might want to try this ...
First let's assume that the sensor is 24VDC (a very common type) and that it has 3 wires (most of them do) and that one wire is brown, and another wire is blue (a very common situation). Start by hooking the brown wire to +24VDC and the blue wire to 0VDC. This powers up the sensor. Next use a "SMALL" wattage 24VDC incandescent lamp to test with. (A small relay with a 24VDC coil will also work but don't use an LED). Hook the sensor's third wire (usually black) to one side of the lamp. Now hook the other side of the lamp to +24VDC. Now actuate the sensor several times.
If the lamp works OK, then you've got yourself an NPN sensor. The sensor is switching on and off the negative side of the power to the lamp. An old-timer electrician would say, "The lamp ALREADY HAS positive (remember you just hard-wired one side of it to +24VDC). It's WAITING FOR negative." The sensor works correctly by switching the negative side of the power off and on.
If the lamp does NOT work OK as connected above, swing that last wire over so that one side of the lamp is hard-wired to the 0VDC line. Now actuate the sensor again. If the lamp works ok this time, then you've got a PNP type sensor. The sensor is switching on and off the positive side of the power to the lamp. An old-timer electrician would say, "The lamp ALREADY HAS negative (remember you just hard-wired one side of it to 0VDC). It's WAITING FOR positive. The sensor works correctly by switching the positive side of the power off and on.
If the lamp doesn't work correctly with either hookup, you've probably got a bad sensor.
To sum up so far: If the sensor switches (N)egative, it's an (N)PN type sensor. If the sensor switches (P)ositive, it's a (P)NP type sensor. In other words, the first letter of the sensor type will tell you which side of the power supply the sensor is designed to switch.
Further, since MOST of us mentally associate the POSITIVE side of the power supply as the "SOURCE" of the power, we can use that association to help remember that a (P)NP type sensor is a SOURCING type device. Conversely, since most of us mentally associate the NEGATIVE side of the power supply as the low or "SINKING" side of the power, we can use that association to help remember that an (N)PN type sensor is a SINKING type device.
Now, if you've got a SOURCING sensor, you must connect it to a SINKING input module. If you've got a SINKING sensor, you must connect it to a SOURCING input module. In the field, the input module's circuit takes the place of the lamp in our test setup. The main difference is that the input module is polarity sensitive; the lamp is not. (Incidentally, we're using a lamp rather than an LED in our original tests so that we don't have to worry about this polarity issue).
Finally, the resistors and digital meters that have been discussed in other postings are too sophisticated for a simpleton like myself. My main objection to the meter is that it is just too darn sensitive. Most of the sensors we're discussing have a tiny amount of "leakage current" which will be enough to show a full voltage reading on the meter EVEN WHEN THE SENSOR IS OFF. The off-state leakage current is too low to light my cheap little lamp, so I will not be fooled by the leakage current. Yes, if they're connected properly, the resistors can be used to "load" the system so that the meter reads correctly. But personally I find the lamp a lot easier to deal with. Besides being easier for me to use than the resistors and the meter, the lamp also provides me with a simple visual indication of the off/on status of the sensor. This helps me find not only the PNP/NPN type of the sensor but also its NO/NC switching action. Something that OFTEN confuses people working with a meter.
Best regards to all.