Best way is to replace the part, refill the coolant - but don't replace the expansion tank cap - then start the engine and let it idle. Any air will start to appear in the tank as the coolant circulates the system. To speed up the process you can rev and hold the throttle for short periods as well as squeeze the main hoses to push the coolant around the system. As the pipes start to get warm, just replace the cap and then go for a drive to take the system up to temperature. Come back, park up and let the system cool (overnight is perfect) before checking and topping up any loss caused by air working its way out of the system into the expansion tank.
Try not to over-think it and I hope this helps.