In the backroom of a Walmart store in Salem, N.H., is a floor-to-ceiling robotic system that the country’s largest retailer hopes will help it sell more groceries online.

Workers stand on platforms in front of screens assembling online orders of milk, cereal and toilet paper from the hulking automated system. Wheeled robots carrying small baskets move along metal tracks to collect those items. They are bagged for pickup later by shoppers or delivery to homes.

...