FindElement(By.AttributeValuePair(string attribute, string value))

30 views
Skip to first unread message

B shah

unread,
Jan 3, 2017, 1:46:37 PM1/3/17
to Selenium Developers
Hi Folks,

Apologies if this question/request comes across as silly or if it has been asked before, but I need to get it off my chest none-the-less :)

It would be awesome if the "By" class had a method to search for Custom attributes/value pairs. The method would look something like By.AttributeValuePair(string attribute, string value) OR even better By.AttributeValuePairs(params string[] attributeValuePairs). 

Usage would be something like FindElement(By.AttributeValuePair("id","loginButton")) or  if there's more than one search criteria FindElement(By.AttributeValuePairs("id","loginButton","text","Login"))

This could (sort of) eliminate the presence of long magic strings from page object classes (i.e. xpath & css selectors) as well as make the search criteria more readable to an extent.
Reply all
Reply to author
Forward
0 new messages