We had this problem with our son. It was explained to us by the professionals in our parenting group that all babies test their parents at this age. Since babies are narcissistic, they aren't born with the value not to be cruel, so we have to teach it. Many babies will pull a cat's tail or pull on the dog's fur, or bite a nipple, they all do it. We found ourselves getting laughed at, too and it was really frustrating. We did this, as soon as the glasses were pulled off or our faces slapped, pinched, we would look at Miles sternly in the face and say, "OUCH. That is NOT okay." If he laughed, we would take his cheeks firmly between our fingers and thumb to let him know that we meant business, (but with our emotions under control)and say, "NOT OKAY", pulling hair NOT OKAY." His face would crumple and that was a good sign that he was getting it, but sometimes he would still smile and that is the tricky test. We never raised our voices or overreacted, we just kept giving him the same mirror that this behavior is unacceptable.
In order to teach a child it is never okay to harm another, you must get them to see that it will never be okay with you. They have to believe you, and when they finally do fold at your fierce expression of seriousness, you can say something like "I know, you are learning" or "I know dear, I know". And give her a little empathy after she has gotten the message. If you give her this response every time she tests that boundary, she will stop. If she repeats the behavior, maybe you could hold off on the empathy and make sure she gets it.
Welcome to the discipline stage! It has been the most challenging thing for me as a mom. It is much easier to bend, but my son doesn't do well with that. He likes to know where we stand on everything, and we feel that he gets his values and part of his identity (one aspect of which is kind, gentle toddler) when we guide him consistently about the important stuff.
Good luck to you, dear.