We are currently working on a selenium project. Can you guys help me to find the xpath locator for the logout button in the application?
Below is a screenshot of the code for the element for which I'm trying to find the xpath.
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.Sign up to join this community
As @Nathan_Cooper already commented I would ask to add Ids to the objects.
If it's not possible, or if the HTML is dynamic, I would start a little higher than the other answer, in particular from
<div class="header_menu logout">
as I assume that a
div with a class
logout will always wrap the logout button.
If you want to do it manually, then you will have to trace the path from the root of the host up to where the element is being generated.
There is an easy way to get the xpath. In Mozilla FireFox install Firebug addon. Then install Firepath addon. Now visit your web page. Press F12 to open Firebug console. Click on the Firepath tab. Inspect the element you want to get the xpath of. Xpath of that element will be displayed in the Firepath console.