If Republicans think they'll win in November by using racist rhetoric to attack Democrats, three recent elections suggest quite the opposite.

The GOP’s tax scam bill was supposed to buoy their midterm election cycle. But that hasn’t happened. And panicked Republicans are shifting their emphasis toward racist, inflammatory rhetoric about immigrants to try to motivate their base.

But that strategy isn’t working, either.

It didn’t work in the governor’s race in Virginia last November. It didn’t work in the March special election in Pennsylvania’s 18th Congressional District. And it didn’t work in a New York State Assembly race on Tuesday on Long Island.

In all three cases, Republicans lost winnable races after touting ugly claims about immigrants and gang violence.

The New York defeat was especially stunning because that seat had been in Republican hands for 40 years. But on Tuesday, Democrat Steve Stern won, and he won easily.

What did Stern have to overcome during the closing weeks of the campaign? Ugly attacks from the local Republican Party, which sent out mailers saying that, because of his policies, “illegal immigration and MS-13 gangs exploded.”

“Our schools have become unsafe. Our communities are in danger,” the mailer read.

That seemed to follow Trump’s lead. He’s previously, and erroneously, claimed that Long Island had become some sort of MS-13 breeding ground. And he insisted that his administration had helped free the community from violence.

“We’ve gone into towns in Long Island where we’ve taken MS-13 and we’ve actually liberated towns,” Trump claimed earlier this month.

In truth, crime on Long Island has been falling for years, which might have explained the voter disconnect on Tuesday.

Again and again, Republicans are failing with this immigrant-bashing strategy.

“In Virginia and more recently in Pennsylvania, state-level GOP officials and the National Republican Congressional Committee stopped running on tax cuts — an issue Republicans believed they could bet on to deliver them wins in the midterm elections later this year — and started back on hammering on cultural issues,” Vox recently noted.

During last November’s gubernatorial race in Virginia, Republican Ed Gillespie’s campaign was rife with appeals to bigotry and anti-immigrant sentiment.

His campaign was not “just a dog whistle to the intolerant, racially resentful parts of the Republican base” but “a mating call,” noted the Washington Post. Gillespie flooded the airwaves with fear-mongering ads “embracing President Trump’s inflammatory political tone and tenor with an advertising campaign that equated illegal immigrants with gang violence.”

Like Stern on Long Island, Gillespie lost badly in a race that was supposed to be extremely close. And so did Republican Rick Saccone in the Pennsylvania special election, where the GOP was forced to ditch its tax scam pitch and where Trump’s endorsement hurt rather than helped the ticket. In that race, Republicans also attacked Democrat Conor Lamb as being soft on crime, but that scheme felt flat, too.

If the tax bill doesn’t work, and immigrant bashing does work, what’s the GOP’s Plan C for November? Not even Senate Majority Leader Mitch McConnell knows the answer to that one.