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

后端 未结 5 1731
渐次进展
渐次进展 2021-01-13 11:22

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

5条回答
  •  青春惊慌失措
    2021-01-13 11:51

    If one of the class is unique you can use className

    driver.FindElement(By.ClassName("google-componentbutton"));
    // or
    driver.FindElement(By.ClassName("glmdl-button"));
    // etc
    

    If none of them unique you can use combination of all of them or some of them

    driver.FindElement(By.CssSelector(".google-componentbutton.glmdl-button.glmdl-js-button.glmdl-js-ripple-effect.google-image.gl-transaction-image"));
    // or
    driver.FindElement(By.CssSelector(".google-componentbutton.glmdl-button"));
    

提交回复
热议问题