When you go to buy a guitar, you may have some idea of the kind you want, but whether you do or not, you'll need to take a good look at all those that are in the store. You start off by choosing one you like the look of. Then if it feels comfortable to hold, you need to hear how it sounds.
Playing a guitar in a shop may make you feel a bit intimidated, but you really do need to actually play the thing before you decide to buy it. Not only do you need to listen to the tone, but also you need to know how it feels whilst playing to make sure it suits you physically. If you are buying an electric guitar, make sure it's plugged into the same kind of amp that you plan to use; otherwise the sound will be different.
When you are playing it, strum the open strings hard so you can hear the sustain, and listen for any problem like buzzing strings. Play each fret on the neck to make sure there are no fret buzzes. Don't be afraid to ask if you can play it in a quieter room if there is too much surrounding noise for you to hear properly. If the salespeople glare at your noise, take your business elsewhere because it is impossible to choose a guitar without listening to it first. If you don't know anything about how to play a guitar, take along someone who does.
It's a good idea to write down all the details of each guitar you try, or you are likely to get them mixed up. If you write down the make, model, price and what it looks like, you'll remember when you get home. To make a good decision, spend as much time as you need in the store and thinking about each guitar afterwards. Never allow the salesperson - or anyone else - to rush you into a decision on what guitar to buy.
Once you've narrowed down your choice to two or three, start an online search for those makes and models. While the brand name websites will be pushing their own brands, you'll be able to find out more details than the shop assistant would know. Then you can go to a site that allows you to post in a forum and ask questions of other players about the model you are interested in. This way you can get vital feedback from other experienced players.