How to write XPATH for Dropdown menu using Selenium IDE?

| | 2 min read

XPATH stands for XML Path. In web-based application, XPATH is a unique address for each web object. XPath is mainly used to find an element in the web page. XPath helps to get address of the web element such as check box, radio button, link etc. To write XPATH for Dropdown, first of all we need to install Firebug in Mozilla Firefox browser. Firebug allow user to view the code behind the web page.

Suppose you have Drupal website where user can buy product through online platform. Suppose the site have a Dropdown menu in the home page. The Record and playback tool can't find the dropdown menu during execution of the test case. Here we make use of XPATH to find Dropdown button. To get an XPATH of an element right-click the Dropdown menu and select 'Inspect element with Firebug'. Then corresponding code would be highlighted in the firebug, right-click on it and select copy XPath. By this method we can copy the XPATH and paste it into the Selenium IDE tool's Target section. Here we need to find XPath for both Dropdown menu as well as option from the dropdown menu. ClickAt command could be used in the command section of the Selenium IDE tool while writing xpath in the target section.

Format for writing XPath of Dropdown in Selenium IDE -

xpath= xpath of drop down menu
xpath= xpath of required option from the drop down


xpath = /html/body/form/select
xpath = /html/body/form/select/option[2] //xpath.jpg

Hope this article helps you to write XPATH for drop down menu.