title: How to write my own customize locator for Selenium webdriver in java?
body: <p>I want to write my own locator to access the elements. WebDriver’s API offers currently eight locators allowing to retrieve elements by id, name attribute, tag name, complete or partial link text, XPath, class name, and css selector. However those default locators not enough for me now because I have to access the elements through a new attribute. Let me give an xample so that you can understand what I really want here.</p>
  
  <p>Example: 
  <em>Choose your username:</em></p>
  
  <p>Now I want to write a code so that I can access the username button using the myLocator locator like:</p>
  
  <pre><code>*driver.findElement(By.myLocator("username")).*
  </code></pre>
  
  <p>It would be very helpful if anybody can give us some good idea how could I rewrite the BY class to add my own locator.</p>
  
  <p>Thank you in advance for your help.</p>