If so, how many times? Also, is it true that with the invention of firearms, the wall became useless?
Most of the current version of the Great Wall was built after firearms were invented and in common use on the Chinese battlefield (i.e., most of the current wall is Ming). Firearms were an important part of the defences on the wall, while the wall itself was very cannon-resistant (and was never breached by cannon). In the late Ming Dynasty, one of the greatest weaknesses of the defences, as far as the Ming were concerned, was not having enough firearms defending the wall.
Earlier versions were not a continuous wall - terrain considered difficult enough to cross was not covered by the wall. In response to Mongol raids through such gaps, the Ming extended the wall even across such terrain, at least in areas near Beijing.
While the wall was gappy enough for the Mongols to use the gaps for raiding, the Manchus/Qing, facing a more complete wall (and the strongest eastern section) didn't have that opportunity. Three major Manchu/Qing raids crossed the wall (1629, 1634, 1636).
The Great Wall defences held against the main Qing armies until the fall of the Ming. In 1644, Beijing was captured by a rebel army, led by Li Zicheng (who had, earlier in the year, declared the Shun Dynasty, with himself as its first emperor, as the legitimate rulers of China). Li Zicheng tried to get the Ming general Wu Sangui who was defending the Great Wall against the Qing to support him. Wu Sangui refused, and Li Zicheng attacked him. Wu Sangui joined with the Qing (submitted to the Qing, even), invited the Qing armies through the wall, and spearheaded the recapture of Beijing by this combined Ming-Qing army. After this, with the Qing controlling both sides of the Great Wall, it ceased to be the major defensive barrier it had been during the Ming.
Thus, it can be said that the Great Wall, even in its final Ming form, didn't completely stop raids. It did make it harder to raid, since the defences along a section of the wall would need to be overcome, and the wall would need to be crossed again to return (at least one Mongol force was caught on the Chinese side of the wall, and heavily defeated). The late Ming wall successfully stopped all major invasions (i.e., the Qing). So, far from useless.