Locator in selenium IDE are used for locating an element on page. Selenium IDE support many types of locators like name, id, CSS and XPath, dom, ui etc.. and from all of them, mostly used locators are name, id, CSS and XPath. Selenium IDE has a facility to set your preferred locator to record it. Thatmeans during recording, which locator format you want to record in your script. If you set CSS then selenium will record CSS of an element in target column of command. Follow bellow given steps to set your proffered locator to record.
Steps set sort order of locator builders and recording selenium IDE script
- Open Selenium IDE
- Click on "Options" menu > Options
- Select Locator Builders tab as shown in bellow given image.
- Now drag and drop 'name' at first position as shown bellow and close selenium IDE option window by clicking on OK button.
- Now start recording your script to search something on Google. Selenium IDE will create script like bellow.
|type||name=q||while and endwhile in selenium ide|
In above script, targeted elements (Google search text box and search button) are located using 'name' locator as we set it in Locator Builders window.
- Now set CSS as your proffered locator as shown bellow and selenium IDE option window by clicking on OK button.
- Now record same (Google search) script. it will looks like bellow.
|type||css=#gbqfq||while and endwhile in selenium ide|
- Now see in above example, both elements are located using 'css' locator.
- Same way, if you set 'id' on 1st position then your script will looks like bellow.
|type||id=gbqfq||while and endwhile in selenium ide|
Compare all three above examples. "Command" and "Value" columns are same in all three but target fields is different. All three example will do same thing but only difference is elements are located using different methods.
Same way you can try remaining locator builders yourself for better understanding. Let you know me if any confusion bu posting your comment bellow.