Of course they use the bathroom, they do. When one of the pilots needs to use the facilities, a flight attendant goes into the cockpit, the pilot who needs to answer the call of nature leaves the cockpit, and the door locked, insuring there are two members of the crew on the flight deck.