Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 404
Banjaxx Avatar asked Apr 05 '16 11:04

Banjaxx


People also ask

Does Selenium support C language?

Conclusion: > Selenium WebDriver supports various programming languages like Java, Python, C#, Ruby, Perl, PHP, JavaScript, R, Objective-C and Haskell.

What is WebDriver in Selenium C#?

What is Selenium Webdriver? WebDriver is an automating web application testing tool. This provides APIs that easily integrate with any programming language such as C#, Java, Python. For details please go through the url. The use of Selenium Webdriver is to basically test any web application.

What is WebDriver and Selenium?

What is Selenium WebDriver? Selenium WebDriver is a web framework that permits you to execute cross-browser tests. This tool is used for automating web-based application testing to verify that it performs expectedly. Selenium WebDriver allows you to choose a programming language to create test scripts.

Which is better Selenium with Java or C#?

By searching with the keywords like 'Selenium with Java' and 'Selenium with C#' in any job portal you can verify then things. For Java, there is large support available online, as most of the professionals are using Selenium with Java. Rank wise Java is among the top 3 most popular languages, C# is not.


1 Answers

use xpath for based on the attribute "gl-command"

driver.FindElement(By.XPath(“//*[@gl-command='transaction']”)).Click();
like image 95
eduliant Avatar answered Oct 11 '22 13:10

eduliant