It is a best practice to make your automation script as Dynamic as possible. Here's a sample when dealing with search results or blog post or list of articles.
In this example, I use the google.com search results.
Scenario:
I'd like to automate the searching capability of google search and click the first search result (not the featured) no matter what title or text it has.
Figure 1.0 Search results in google.com |
Tip: You can get the properties of the object either using object spy or developer tools in your browsers.
Figure 2.0 Decription and .ChildObjects |
Figure 2.1 Looping the objects' existence |
Object indexes acts like arrays, it always starts with '0' index.
Note: You can always maximize your scripts to be suitable for similar layouts as long as the objects are still the same and uses the same hierarchy.