title: Selenium C# how to get text in IWEbElement
body: <p>I am trying to fill in a text-field on a website for which the id changes every time the website is opened. To circumvent this, I look up the webelement by it's class name and this seems to work well as I am able to click on it through </p>
  
  <pre><code>currentWebElement.Click();
  </code></pre>
  
  <p>however, when I try to fill in the edit text box through</p>
  
  <pre><code>currentWebElement.SendKeys("51");
  </code></pre>
  
  <p>nothing happens (even more so, focus is lost)</p>
  
  <p>I have searched a lot to see what the problem is but have not been able to find a solution so I was wondering if someone here can point me in the right direction. What I have tried so far:</p>
  
  <p>1) I was working in chrome but since this seems to be a common problem with sendKeys I have swithed to ie, alas the problem persisted. I have tried migrating to firefox but did not succeed as I cannot seem to locate the binary path to firefox.exe but this should be addressed in a different question. So the problem occurs both in chrome and IE.</p>
  
  <p>2) Using javascript to send the command as I have found this suggestion in other questions that were answered on this website:</p>
  
  <pre><code>driver.ExecuteScript("arguments[0].value = '51'", currentWebElement);
  </code></pre>
  
  <p>directly but also implementing it as a function did not work:</p>
  
  <pre><code>private static object setValue(this IWebDriver driver, IWebElement element, String value) {
          return ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].value = arguments[1]", element, value);
      }
  
  // and then calling it in my code:
  
   setValue(driver, currentWebElement, "51");
  </code></pre>
  
  <p>all implementations did not give me errors nor warnings (I managed to get rid of those during the process), but none of them give the desired result i.e. the box keeps remaining empty which is really starting to bug me!</p>