The morality of that is quite vigorously contested. And even in places that have elective abortion, it’s often only available in the first trimester, while many of these tests are performed after that.
But even if we accept the notion of elective abortions, it doesn’t follow that any reason is morally acceptable. What if the parents don’t want girls, like often is the case in India and China. It’s okay to abort them? What if we had an in vitro test for sexual orientation? Would it be okay to abort fetuses in that basis?