Selenium to click on a javascript button corresponding to a text

I have a lot of buttons in my web page and that too are javascript buttons. All those buttons have same TagName, but different id. But I cant use ID since I cant predict which button has to be clicked.

<img src="https://i.stack.imgur.com/jgmjh.jpg" alt="enter image description here">

Selenium will search for a content (Question here) and if could find the content, then it must click on the respective button. How can it be achieved?

Any comments would be really helpful and appreciated..


This will find a button based on the displayed text on the button and click it.

var loggout = driver.FindElement(By.LinkText("Logg ut")); loggout.Click();

Or you can change it to;

By.Id() By.CssSelector() By.Name() ...


  • Selenium Firefox WebDriver in WCF throwing “failed to start up socket within 45000 ms”
  • How do I retrieve the text in a table column using Selenium RC?
  • Update web.config file in asp.net
  • How to capture or listen to browser notifications?
  • Can you use multiple instances of Edge on a Selenium Grid Node?
  • Entity Framework ObjectContext: Concurrency
  • How do you keep a running instance for Google App Engine
  • change color of jstree node
  • my tic-tac-toe program in matlab does not work [closed]
  • jQuery - resize an elements height to match window without refreshing, on window resize
  • Subclassing QGraphicsItem prevents me from being able to use itemAt() on a QGraphicsScene/View
  • Detect when Facebook like button is clicked
  • Google Custom Search with transparent background
  • How to clear text inside text field when radio button is select
  • Android fill_parent issue
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Ajax Loaded meta Tags
  • Xamarin Forms - UWP Fonts
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Insert into database using onclick function
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • What is Eclipse's Declaration View used for?
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • Can I make an Android app that runs a web view in Chrome 39?
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • jquery mobile loadPage not working
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Arrays break string types in Julia
  • Is there a mandatory requirement to switch app.yaml?
  • Data Validation Drop Down Box Arrow Disappearing
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Free memory of cv::Mat loaded using FileStorage API
  • How do you join a server to an Active Directory (domain)?
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?
  • UserPrincipal.Current returns apppool on IIS