How did a pope become a pope in the Medieval times?

he was voted on by the bishops he was the highest bishop