Can you pre book a train ticket before you arrive to go from Urumqi to Almaty(Kazakhstan).
Is it better to travel by bus?

If you can find a travel agency in Urumqi then perhaps they can assist you in obtaining tickets for this train. Tickets should be available 4-6 weeks before departure. Most people on this forum seem to have indicated that it is difficult to impossible to purchase such tickets anywhere but in the city of departure.
I know several people who have taken the train but no one who has taken the bus.
I am pretty sure that the through train only operates once or at most twice a week but I believe that there are also daily trains to the possible and that it is probably possible to cross the border and then catch a train from the other side. This website might help: Kazakh train schedule
Ruth