A party to an action may be examined as a witness, at the instance of the adverse party, and for that purpose may be compelled in the same manner, and subject to the same rules of examination, as any other witness, to testify at the trial, or appear and have his or her deposition taken.