Selectors Guide

You don’t need to be an expert to use selectors. If you can inspect an element, you can create a tour.

πŸš€ Quick Start (Do This First)

  1. Right-click any element on your page
  2. Click **Inspect**
  3. Find the element in the HTML
  4. Use one of these:

Example:

{
  selector: "#login-btn"
}

🧠 Simple Rules (Follow These)

div > div > span:nth-child(2)

πŸ‘‰ These break easily

βœ… Best Practices

1. Use Unique Selectors

Good:

#submit-btn

Bad:

.button

If your UI doesn’t have good selectors, add this:

<button data-tour="start-btn">Start</button>

Then use:

{
  selector: '[data-tour="start-btn"]'
}

πŸ‘‰ This is the most reliable method

3. Keep It Stable

Avoid:

πŸ” Common Selector Types

ID Selector

#header

Class Selector

.navbar

Attribute Selector (Best for production)

[data-tour="menu"]

Tag Selector

button

⚑ Extended Selector Features (NavigateMe)

These are power features that make your tours smarter and easier to target.

πŸ”€ `:contains(text)`

Select elements containing specific text.

button:contains(Start)

πŸ‘‰ Matches any button that includes "Start"

🎯 `:exact`

Use with :contains() for exact text match.

button:contains(Start):exact

πŸ‘‰ Matches only elements with exact text "Start"

πŸ”’ `:nth(index)`

Select element at a specific position (0-based index).

.card:nth(2)

πŸ‘‰ Selects the 3rd .card

πŸ”š `:last`

Select the last matching element.

.card:last

πŸ‘‰ Selects the last .card

πŸ§ͺ Combining Features

You can combine selectors with features:

button:contains(Next):nth(1)

πŸ‘‰ Second button containing "Next"

.menu-item:contains(Settings):exact

πŸ‘‰ Exact match for "Settings"

⚠️ Guidelines for Extended Selectors

πŸ§ͺ Debugging Tips

Element not found?

Wrong element selected?

πŸ’‘ Pro Tip

Start simple β†’ refine later

Don’t over-engineer selectors. Get the tour working first, then improve.

🎯 Example Tour Step

{
  selector: 'button:contains(Login):exact',
  content: "Click here to login"
}

πŸš€ Summary

That’s it. You’re ready to build powerful, flexible tours.