Public transport takes about 45 mins if you travel by bus from Cottesloe beach, via Claremont, Stirling Highway to the City. If you're travelling on the train directly from Cottesloe station, then it's about 10 minutes quicker, depending upon whether it's an express service or not. If you're travelling by car during business/school peak hour, it could take as long as by bus/train, and you will need to find parking in the City.
Depending on where you need to be in the city, it could take between 15 and 20 mins on a good day, at a good time. Might take you 5 mins to get to Stirling Why from wherever in Cottesloe you are though.