A dishwasher for treating dishes according to at least one cycle of operation and methods for operating a dishwasher. The dishwasher may have a tub at least partially defining a treating chamber, a rotatable sprayer, a drive system operably coupled to the rotatable sprayer to effect movement of the rotatable sprayer, and a liquid recirculation system for recirculating sprayed liquid. The dishwasher may have a sump including a sensor enclosure, a first sensor element located within the sensor enclosure and configured to sense at least a portion of the rotatable sprayer, and a controller configured to receive output from the first sensor element and control the drive system and the liquid recirculation system to rotate the rotatable sprayer while selectively supplying liquid to the rotatable sprayer.