Transaction Scripting Tips and Tricks
Choosing Better Element Selectors
Avoid Dynamically Generated IDs
await driver.findElement(By.css('#tabZoneId278'));Avoid Overly Specific Selectors
await driver.findElement(By.Css('#nm-streaming-container > div.streamingNewsContainer.nsw-subscription-type-realTime.defaultTemplates.news-hideInsight.news-hideSentiment.header-auto-resize.news-hideHeader.news-results-item-insight2-shrinked.news-results-item-sentiment-shrinked.nsw-four-columns > div.news-results.news-list-table.newsSection.streamingTopSection > div');Working With Single Page Apps
await click(By.css('#app-bar-20c3440d-c67e-4420-9f80-0e50c39693df .icons-filled'));Criteria for Choosing the Right Element Selector
Unique Human-Readable ID
Unique Class Names
Unique Attribute Values
Unique Combination of Type, Class, Value
XPath Search
Unique Sibling-Ancestor Combination
Keep Reading
Use Pause During Playback
Waiting for Element State
Wait for a Single Element
Wait for a Group of Elements
PreviousOptimizing and Troubleshooting Transaction ScriptsNextTransactions – Executing Custom JavaScript Code
Last updated