How does Selenium find element work?

How does Selenium find element work?

Selenium can find element work in many ways. First, Selenium can find elements by using the implicit tabindex attribute. If the user is on a page where the tab index is set to a number greater than zero and if the element is focusable, then it will receive focus when the user presses the tab key. For example:

//Quit program when the user presses ‘Q’

driver.findElement(By.xpath(“//*[@id=‘txtName’]”)).sendKeys(“Q”);

driver.findElement(By.xpath(“//*[@id=‘btnSubmit’]”)).click();

driver.quit();