You have the hiring process backward.
Have you ever heard of a situation where a company wanted to hire an H1B but ended up
You will never see a job posting that says:
Position: SOFTWARE ENGINEER
5 years of D++
2 years using WGF and Visual Baloney
Experience with Libux a bonus
Must be an H1B
So if companies are exclusively looking for H1B applications, they will not make it apparent that they are doing so.
Have any of you ever been hired instead of an H1B because you are local?
How would the applicant know? They don't get any insight into the other potential hires.
In general, there are 2 kinds of companies hiring H1Bs. The one type is contracting companies looking for massive cheap labor, so they just take the cheapest people. The other type is just looking for skilled contractors, and they don't care if they are H1B or citizens or what. Those companies pick the best applicant regardless of H1B status. It would only matter if it was a tie, because the H1B would be more of a pain to deal with. But in reality, ties don't happen. I've interviewed hundreds of software engineers, and never the team of interviewers not had reason to sway one direction or the other. Also, the interview team is generally not told if the person is an H1B applicant, and we don't care. I've also never had a manager say "Well, you chose candidate X, but I will actually hire candidate Y." If so, I might suspect a preference for the visa, or some salary negotiation thing went on. But so far I guess I've worked for honest people at honest companies.