Examples of selectors for ScraperSensei
article:has-text("ScraperSensei")
Matches any <article>
tag that contains the text “ScraperSensei”, even nested inside child elements.
button:text-is("Log")
Matches elements with exact text content. Case-sensitive and trims whitespace.
button:text-matches("Log\\s*in", "i")
Matches text using regex patterns. The example matches “Login”, “Log in”, “log IN”, etc.
input:right-of(:text("Username"))
Matches input fields that are to the right of text “Username”
button:near(.promo-card)
Matches buttons within 50 pixels of elements with class “promo-card”
button:near(:text("Username"), 120)
Matches buttons within 120 pixels of text “Username”
button:visible
Matches only visible button elements
article:has-text("ScraperSensei")
Matches article elements containing “ScraperSensei” text anywhere inside
#nav-bar :text("Home")
Matches elements with text “Home” inside #nav-bar element
button:has-text("Log in"), button:has-text("Sign in")
Matches buttons containing either “Log in” or “Sign in” text
xpath=//button
Matches any button element anywhere in the document
xpath=//div[@id='main']//button
Matches button elements inside div with id=“main”
label:has-text("Password")
Matches label element containing “Password” text and can be used to target its associated input
_react=BookItem
Matches React components named BookItem
_react=BookItem[author = "Steven King"]
Matches BookItem components with specific author prop
_vue=book-item
Matches Vue components named book-item
_vue=book-item[author = "Steven King"]
Matches book-item components with specific author prop
data-testid=submit
Matches elements with data-testid=“submit”
id=login-form
Matches elements with id=“login-form”
css=button
Matches any button element using standard CSS selector
css=#nav-bar :text("Home")
Matches smallest element containing “Home” text inside #nav-bar
article:has(div.promo)
Matches article elements that contain div with class “promo”
:nth-match(:text("Buy"), 3)
Matches the third element containing text “Buy”
article >> .bar > .baz >> span[attr=value]
Chains multiple selectors, each queried relative to the previous match
*css=article >> text=Hello
The *
prefix captures the article element instead of the text element
[type=radio]:left-of(:text("Label 3")):near(.form-group)
Complex selector combining position and proximity
[role="button"][aria-label="Submit"]
Matches elements with specific ARIA roles and labels
xpath=//span[contains(@class, 'spinner__loading')]|//div[@id='confirmation']
Matches elements that satisfy either condition
button:visible
Only matches visible buttons, useful to distinguish between similar elements
article:has-text("ScraperSensei")
Matches elements containing specified text somewhere inside
button:has-text("Log in"), button:has-text("Sign in")
Matches elements that satisfy any of the text conditions
article:has(div.promo)
Returns elements that have matching children
:nth-match(:text("Buy"), 3)
Matches the nth occurrence of an element (1-based index)
button:above(.footer)
Matches buttons that are above the footer element
input:below(.header)
Matches inputs that are below the header element
button:right-of(.sidebar)
Matches buttons positioned to the right of the sidebar
button:near(.card, 100)
Matches buttons within 100 pixels of a card element
_react=BookItem[author *= "king" i][year = 1990]
Matches React components with multiple property conditions
_react=[some.nested.value = 12]
Matches components with specific nested property values
_react=BookItem[author = /Steven(\\s+King)?/i]
Matches components where properties match a regex pattern