How to use Name locator in selenium.


The following html snippet has been taken from the following  link (you can inspect it there in the page) https://en.wikipedia.org/wiki/Main_Page

<input class="vector-search-box-input" type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [alt-shift-f]" accesskey="f" id="searchInput" autocomplete="off">

It indicates one search box, where we can write something for the same purpose.
Here  you can see the locator is Name and its given as this-  name=”search”

The syntax to identify the Name locator using selenium is given below.

driver.findElemnt(By.name(“search”)).sendKeys(“write something here to search”);

To know how does this driver object come, you have to check the post on –Different web drivers invoking using selenium java