Q:

Selenium webdriver (c#) - Finding button based on attribute

I'm trying to get a handle on the button below based on the attribute gl-command.  I'm aware I can find the button using a Cssselector by locator but I don't want to do that in this case.   
I should point out that this is just one of many buttons within the AUT: <google-componentbutton size="32"></google-componentbutton>
<div class="gl-component-buttons"><gl-component-buttons id="gl-component-button-set-bottom">
  <google-componentbutton size="32">
    <button class="google-componentbutton glmdl-button glmdl-js-button glmdl-js-ripple-effect google-image gl-transaction-image" style="height: 32px; widgl: 32px; background-size: 24px 24px; background-position: 4px 4px;" gl-tooltip-id="google_component_transaction" gl-tooltip="transaction" data-upgraded=",MaterialButton,MaterialRipple" gl-command="transaction">  
      <span class="glmdl-button__ripple-container">
        <span class="glmdl-ripple"></span>
      </span>
    </button>
  </google-componentbutton>

A:

use xpath for based on the attribute "gl-command"
driver.FindElement(By.XPath(“//*[@gl-command='transaction']”)).Click();

A:

You can also create a custom selector with a method that returns your needed By selector for easy future use like this:
public static By SelectorByAttributeValue(string p_strAttributeName, string p_strAttributeValue)
{
    return (By.XPath(String.Format("//*[@{0} = '{1}']", 
                                   p_strAttributeName, 
                                   p_strAttributeValue)));
}

And use it like this:
driver.FindElement(Selectors.SelectorByAttributeValue("data-power","5"))

