Just to give you a bit more info about the waitForSelector, you can do whatever you want while it's waiting for the selector to be present. If the time (10 seconds for us) runs out it'll fail though.