Sexually transmitted diseases (STDs) testing is Used to diagnose HPV, chlamydia, gonorrhea, and herpes. During the test, a provider will use a special swab to take a sample from the site of the infection. In women, samples may be taken from the vagina or cervix. In men, samples may be taken from the penis or urethra, the tube that carries urine out of the body.