title: NoSuchElementException: no such element: Unable to locate element error clicking on the Sign up button using Selenium and Java
body: <p>So I'm trying to test out the first name section of this link (<a href="https://softwaretestinggn8fe.herokuapp.com/" rel="nofollow noreferrer">https://softwaretestinggn8fe.herokuapp.com/</a>) using selenium in java to show that the error message &quot;First Name can only contain characters.&quot; will be shown when I type &quot;545&quot; into the first name section of the website. However my test fails and this is the error I get:</p>
  <pre><code>org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {&quot;method&quot;:&quot;css selector&quot;,&quot;selector&quot;:&quot;*[name='submit']&quot;}
    (Session info: chrome=86.0.4240.198)
  </code></pre>
  <p>Does anyone know how to solve this issue?</p>
  <pre><code>    import org.testng.AssertJUnit;
      import org.openqa.selenium.By;
      import org.openqa.selenium.WebDriver;
      import org.openqa.selenium.WebElement;
      import org.openqa.selenium.chrome.ChromeDriver;
      import org.testng.Assert;
      import org.testng.annotations.Test;
      
      
      public class WebTesting {
          
          @Test
          public void test1() {
              
              System.setProperty(&quot;webdriver.chrome.driver&quot;, &quot;C:/Users/mtecl/Desktop/Drivers/chromedriver.exe&quot;);    // configure path to the driver
              
              WebDriver driver = new ChromeDriver();
              
              driver.get(&quot;https://softwaretestinggn8fe.herokuapp.com/&quot;);
              
              //Username
              WebElement testUsername = driver.findElement(By.id(&quot;firstname&quot;)); //id: first name
          
              testUsername.sendKeys(&quot;545&quot;);
              
              //Button
              driver.findElement(By.name(&quot;submit&quot;)).click();
              
              String expected = &quot;First Name can only contain characters.&quot;;
              String actual = driver.findElement(By.xpath(&quot;html/body/div/main/div[2]/form/div[1]/span&quot;)).getText();
              
              Assert.assertEquals(expected, actual);
          
          }
      }
  </code></pre>