A web element that has a unique id/name can be identified using xpath as well. Then what is the advantage in using By.id/By.name over By.xpath. Consider the following example. Below is a web element.
<input id="abc" name="abc" xpath="abc">
This web element can be identified as:
By.id("abc");
By.name("abc");
By.xpath(".//*[@id='abc']); or By.xpath(".//*[@name='abc']);
I want to know what is the advantage of using 1. or 2. over 3.?