authentication Scenario 8 — Check Logout Button for Auth State
Written by RTILA X Engineering Team
Advanced ~10 min
Prerequisites: authentication/4 authentication/5 authentication/6
What You'll Learn
Determine authentication state by checking UI elements
Real-World Use Case
Building robust session management logic
LIVE DEMO
Auth State Detection
The page shows a logout button only when authenticated. An element visibility check separates the two paths.
EXPECTED OUTPUT
Profile Data From Auth State Check
| label | value |
|---|---|
| user@test.com | |
| Role | Admin |
| Member Since | 2024-03-15 |
RTILA X PROJECT JSON
RTILA X Automation Project
check-logout-button-auth-state.json
{
"name": "Check_Logout_Button_For_Auth_State",
"settings": {
"urls": [
"https://learn.rtila.com/scenarios/authentication/8"
]
},
"datasets": {
"profile_data": {
"item_selector": "css=.dashboard-content table tr",
"properties": [
{
"name": "label",
"type": "text",
"selector": "css=td:first-child"
},
{
"name": "value",
"type": "text",
"selector": "css=td:last-child"
}
]
}
},
"commands": [
{
"command": "goto",
"params": {
"url": "https://learn.rtila.com/scenarios/authentication/8"
}
},
{
"command": "if",
"params": {
"condition": {
"type": "element_visible",
"selector": "css=.logout-btn"
},
"then": [
{
"command": "extract_data",
"params": {
"dataset": "profile_data"
}
}
],
"else": [
{
"command": "fill",
"params": {
"selector": "css=#cond-username",
"value": "user@test.com"
}
},
{
"command": "fill",
"params": {
"selector": "css=#cond-password",
"value": "secret"
}
},
{
"command": "click",
"params": {
"selector": "css=#cond-login-btn"
}
},
{
"command": "wait_for_selector",
"params": {
"selector": "css=.dashboard-content"
}
},
{
"command": "extract_data",
"params": {
"dataset": "profile_data"
}
}
]
}
}
]
}
RTILA X Concepts
Checking for .logout-btn is a reliable pattern for detecting auth state
without reading cookies. The same if/else structure can either extract immediately
or perform a full login fallback.
Did you complete this scenario?
Ready to run this automation?
Copy the project JSON above, open RTILA X, create a new project, and paste it.
This scenario covers 2 RTILA X commands and is referenced in 2 learning articles.
Continue Learning
Was this helpful?
Thank you for your feedback!