From Cannes to St Tropez: here is an alternative drive to avoid St Maxime area. (worst traffic is around the gulf between St Maxime and St Tropez))
Take the highway from Cannes (A8) but don't leave it at the exit "Le Muy", keep going until "le Luc" (about 15 km further). Then follow the road signs to St Tropez.
This small road will take you through "La Garde freinet" and about 35 minutes later you will end up in "Port-Grimaud" which is on the coast but already half-way through the gulf. (link to google map itinerary below)
From Port-Grimaud to St Tropez, expect traffic for about 45 minutes.
Total from Cannes: (worst case scenario) just over 2 hours:
Highway: 45 minutes
Le Luc to Port-Grimaud: 35 minutes
Port-Grimaud to St Tropez: 45 minutes
Expect the same on the way out.
So for a day trip, you will spend about 4 hours in the car. I still recommend to take your car so that you can enjoy both the town (St Tropez) and the beach of Pampelonne.
So what to do for a day trip?
Go first to St Tropez. Park your car in the "parking du port", then take a walk through the small town, around the harbor, Place des Lices (local market is indeed on Saturday and also on Tuesday), have a coffee at "Le Senequier" in front of the yachts, have a look at the boutiques...
Then take your car again and drive (10 minutes) to Pampelonne beach (follow "route des plages" just outside St Tropez) and select one of the numerous beach restaurants available.
There are the famous ones such as Nikki Beach, Voile Rouge, Club 55, Nioulargo... but also more many smaller ones which are great also. I personally like Tiki Beach, Plage des jumeaux, Tropezina, ....
They all have restaurants on the beach, with tables "toes in the sand" and sea view. After lunch enjoy the "chaises longues" (umbrellas available) by the water with a glass of rosé -Château des Marres- is my favorite, .... and the pristine blue waters of Pampelonne.
In Pampelonne, you can have a late lunch (usually served non stop all day) to enjoy the morning in town, and then go to the beach....until 6 or 7 pm (sunset in August is around 9 pm).
On the way back to Cannes, take the small road that takes you from Pampelonne to Gassin, then Port-Grimaud and then again follow the road to La Garde Freinet to join the A8 back to Cannes. In this way, you will avoid the gulf all together and save a good hour by avoiding traffic. (link to google map itinerary below)
Definitely a nice day from Cannes, despite the time spent in the car....
Here are the links on Google map for the drive:
Cannes to St Tropez
Pampelonne to Cannes
Enjoy!