If I'm standing at the counter in the local gun shop, and I want to look at semi-autos, for a new one, what do I need to look carefully at?
Honestly...the same broad scrutiny you would apply to purchasing a factory new car, bicycle, suit of clothing, or delivered furniture. In other words, just a visual once-over for obvious factory defects.
If you buy brand new, and something later comes to your attention...just bring it back for repair or replacement. You wouldn't accept a new car off of the dealer's lot if it had a crease in the body work, crookedly mounted trim, a tear in the upholstery, non-functional lights, or grinding brake pads.
Today, there are so many quality guns offered by so many manufacturers, that it's difficult to go wrong, but...you can still run into the occasional lemon. You'll probably not detect a performance issue until you actually go to the range, but you can alleviate problems by inspecting for major defects at the gun shop.
So look for obvious manufacturing errors:
Loose or off centered sights
Cosmetic blemishes, scratches, finish mistakes, exterior tooling marks, etc.
Controls that fail to properly function (safety, trigger, decocker, magazine release, slide stop, etc.)
A slide that doesn't ride smoothly along the rails or seems to "catch" midway along its length of travel (could be a burr in the rails, polymer sprue interfering with a metal rail insert, or small bits of metal grist or chips left over from manufacturing)
Magazines that won't seat properly (or release freely)
Chips or scratches on grips
Anything loose or wiggly that's supposed to be staked or screwed down tight
Obvious burrs in metal at muzzle crown, along rails, on sights, on feed ramps, etc.
Signs that the weapon has been dropped (dinged sights, butt, muzzle, grips, or trigger guards)
Things that are visually out of kilter...waves in what is supposed to be a flat mirror polish, bends in what are supposed to be straight lines on a slide, crookedly machined parts, unevenly polished finish or "smeared" rollmarks, huge gaps in fit (like one side of slide to rail fit being vastly different from the opposite side...when looking at the rear of the slide).
Make sure the caliber markings (on the slide or barrel) actually match what is advertised on the tag or box. It happens. Hmmnn...Why wont my .40 cartridges fit in this new weapon? Oops! Apparently this is actually a 9mm!
Inspect the weapon visually from all angles paying close attention to sights, muzzle, bottom of butt, trigger guard, top of slide, rear of slide/grip, and bottom of slide. Lock the slide to the rear and inspect everything you can see. I rarely ask to disassemble a new gun, but if you must, have the seller field strip it for you so that you can look at the interior components. Any scratches created or problems encountered are his...not yours. This isn't the time to prove you are an armorer.
From some companies, factory test firing will leave powder residue, so the fact that the weapon is slightly "dirty" does not indicate that it isn't new. On the other hand, it shouldn't be covered in firing residue and have a filthy bore. Just a smudge of black residue should be finger wipe-able from off the breech face, chamber, muzzle, and feed ramp area.
Inspect the weapon for signs of rust. Rare with a new pistol...but it happens.
Inspect all screws for signs of marring or rust, especially on grips and adjustable sights. Some idiot may have dinged them up while playing with it in the stock room.
Inspect the bore. Lock the slide back (after properly clearing) and look down the barrel. If you don't have a mini-flashlight or bore light, just use the overhead room lighting to take a glance. Stick your thumb or index finger into the open ejection port and use your finger nail to reflect ambient light back towards your eye (looking down the muzzle). An easy trick to do and you are merely looking for obvious bore defects: rust, major scratches inside the bore, burrs, damage to the muzzle crown, etc.). Anything that shouldn't be there. A slight hint of copper colored smear (from bullet jacketing) on the inside of the bore just indicates the weapon was test fired at the factory. 99% of the time, you are going to see a clean, bright, and shiny bore with crisp lands and grooves. Inspecting the bore should take you all of about 5 seconds.
Ask the seller if you can dry fire the piece. Clear it, then point the weapon safely at the floor or other safe direction, and try the trigger a time or two. Also test the safety (if it has one) by trying to fire with the safety applied.
Ensure that your dealer is including the correct complement of factory spare magazines. Some weapons come with one. Some with two. Some with three. Unscrupulous shops have been known to parse spare $40-$50 magazines from factory boxes...then sell them separately. This requires a little due diligence on your part...easily done by researching here on the forum or at the manufacturers website before you buy. If your proposed new purchase is supposed to come with two factory magazines, but the dealer is only showing you one...you might want to ask where the other magazine is.
If the pistol of your dreams feels like crap in your hands...find something else. You'll never shoot it well if it doesn't fit you comfortably. Doesn't matter who made it, how much it costs, or how much the gun magazines have raved about it. Find something else.
To me, the single most important thing you can do is to resist impulse buying with only a cursory inspection. Have an idea of what particular model you are considering before you come into the shop. Compare the field by trying several weapons to hand. After looking at a weapon, you might want to go home to do some more leisurely comparison on the internet.
Then decide if the weapon you were enamored with earlier in the day is actually the one you want.
Don't get buck fever while standing at the gun counter. Even if it's exactly what you always wanted, is in good shape, and at a decent price...walk away and look at something else for a few minutes. Give yourself time to think about it before you slap down cash or credit card. Then, go back and make a second (closer) mechanical inspection. Upon further reflection, if it fits your needs, fits your hand, fits your budget, and makes you happy to hold it...buy it.
It's just shopping.