title: Selenium getText
body: <p>I want to <code>getText()</code> using <code>By.id</code> or <code>By.cssSelector</code>.</p>
  <p>I managed to solve my problem by doing <code>getAttribute(&quot;value&quot;)</code>, but I don't understand why <code>getText()</code> doesn't work like I expect it, and I might need it so all help is appreciated.</p>
  <p>Here is the Java code:</p>
  <pre><code>WebDriverWait wait = new WebDriverWait(driver, 10);
  Boolean elementIsPresent = wait.until(ExpectedConditions.textToBePresentInElementValue(By.cssSelector(&quot;#general_service_name&quot;),&quot;[reg] general_service_name&quot;)); // true
  
  //WebElement general_service_name = driver.findElement(By.cssSelector(&quot;#general_service_name&quot;));
  WebElement general_service_name = driver.findElement(By.id(&quot;general_service_name&quot;));
  
  // Display check
  Boolean isDisplayed;
  if(general_service_name.isDisplayed())  isDisplayed = new Boolean(true); else isDisplayed = false; //true
  
  String text_empty = general_service_name.getText(); //&quot;&quot;
  String text_with_value = driver.findElement(By.id(&quot;general_service_name&quot;)).getAttribute(&quot;value&quot;); //&quot;[reg] general_service_name&quot;
  </code></pre>
  <p>And HTML:</p>
  <pre><code>&lt;input id=&quot;general_service_name&quot; type=&quot;text&quot; value=&quot;[reg] title&quot; name=&quot;general_service_name&quot; style=&quot;float:left;&quot;/&gt;
  </code></pre>