What methods can be used in online exams to genuinely test the students' knowledge and capabilities? There has been a lot of talk about online teaching in relation to covid-19 and campus shutdowns.

This question isn't about that though: my question is about what ways online examinations should be treated in counterpoint to written examinations. 

I'm going to be transferring my course's written examination into an online environment. This examination involved 2 hours of students, with a pen and paper, answering questions both short and long in a typical examination environemnt.

An online exam however cannot be policed. Demanding it be anything other than open book is unrealistic. What methods can be deployed such that it is a genuine test of students' knowledge and capabilities?
First, a two hour time limit might be difficult to enforce or to guarantee, especially if it uses a real-time clock. At some level of scale you may start to find that some students didn't get the exam paper or were unable to return it by the deadline. So, I'd start by rethinking if a time limit of less than a day is really essential to your exam. 

Second, you can pre-vet any questions you ask by doing searching yourself online for possible answers and responses. Reject questions that have too much online presence, or be prepared for getting that back as answers. Presumably the test isn't about effective online searches. 

Third, give up the idea of asking students for facts. That is obvious, I'd think, as facts are cheap. But even facts requiring computation, such as in mathematics or statistics can be generated with tools such as MatLab or Mathematica. 

The best sort of questions, I think, are those that require either or both of interpretation and insight. Questions about the why of things rather than the what and how are much better. However, these are the hardest to create, the hardest to answer, and are likely to have the widest variation in quality from students. To grade them might require quite a lot of interpretation: does this student show any insight at all into the subject? Pass-fail grading can be considered. Repeat attempts can be considered. 

As an alternative to an exam, you can consider individual portfolio development by students. Students write or otherwise create some artifacts according to some criteria. Plagiarism concerns come in to play here, of course. 

I'll note that honor codes can help to a certain extent, though provide no guarantees. And honor codes created in the moment are probably less effective than those of long standing.