<div class="mdl-align"> == $0
: :before
<button class="fp-upload-btn btn-primary btn">Upload this file</button> == $0
: :after
</div>
The above codes are from a website, however I am unable to click this button despite trying multiple attempts. Im using selenium with C# to do an automation testing. What this button does, is to simply submit a form.
idattribute on all components you want to manipulate using Selenium or any other UI Automation framework. Like @jainish kapadia said you can use XPath or CssSelectors like in jQuery but these rely on the layout, styling or even the language of the page. By setting the ID you don't have to worry about these variations provided the ids stay the same (the UI could be completely changed and it should still work.) Of course if you're crawling a page you don't own then XPath and CssSelectors are the best way I'm aware of.