title: Selenium C# - scrolling to a web element
body: <p>Selenium C# - scrolling to a web element</p>
  
  <p>I tried both the below options:</p>
  
  <p>1.</p>
  
  <pre><code>IWebElement button = this.WebDriver.FindElement(By.ClassName("btn-default")); 
  // locate the button, can be done with any other selector
  Actions action = new Actions(this.WebDriver);
  action.MoveToElement(button).Perform(); // move to the button
  button.Click();
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>IJavaScriptExecutor js = (IJavaScriptExecutor)this.WebDriver;
  js.ExecuteScript("arguments[0].scrollIntoView(true);", button);
  </code></pre>
  
  <p>Here is the HTML for the button:</p>
  
  <pre><code>button class="btn btn-default" data-bind="click: $root.addParameter, enable: $root.selectedParameter() == null" type="button"Add parameter/button  
  </code></pre>
  
  <p>Any suggestions?</p>