I feel like the code in this post doesn't show an example of when you would need to use this technique, however it shows how to use it.
I can imagine a scenario where none of the Selenium selector strategies would apply (perhaps it moves about in the source of the page and shares attributes and classes with other items on the page) but you still need to pin down your element and get an ID for it. This would work in that case.
I'm pretty sure that using Selenium's native selection methods are what you would choose unless you simply can't get your element using them.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.