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
Not sure if you are asking to find a button IF it has the gl-command attribute or if the value of gl-command is some specific value so I'll answer both ways.
Find buttons with gl-command attribute
driver.FindElements(By.Tag("button")).Where(x => !string.IsNullOrEmpty(x.GetAttribute("gl-command")).FirstOrDefault();
Can remove the FirstOrDefault()
if you want all buttons with gl-command attribute.
Find buttons with specific gl-command value
driver.FindElements(By.Tag("button")).Where(x => !string.IsNullOrEmpty(x.GetAttribute("gl-command") && string.Compare(x.GetAttribute("gl-command"), "YOURGLCMD", StringComparison.OrdinalIgnoreCase) == 0));
My closing parens might be off because I typed all this out on my phone in bed, but that's the general gist and my gf is yelling at me to go to sleep.