Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to selenium webdriver coding and i am stuck with the basic issue .Below is the code.

public static void main(String[] args) {
        WebDriver driver;
        System.setProperty("webdriver.gecko.driver","c:/geckodriver.exe");
        driver =new FirefoxDriver();

        driver.get("http://newtours.demoaut.com");

        driver.findElement(By.linkText("REGISTER")).click();

        driver.findElement(By.name("firstName")).sendKeys("Vansh");
        driver.findElement(By.name("lastName")).sendKeys("kumar");
        driver.findElement(By.name("phone")).sendKeys("9887654321");
        ---}

In the above code after launching my application and clicking on Register link i am able to got to registration page but i am not able to enter values for firstname,lastname and phone. Please help what am i missing here.

Thanks

share|improve this question
    
have you tried to wait for a while between your actions? – Yu Zhang 8 hours ago
    
what do you mean by not able to enter values? explain what is happening? – Rao 7 hours ago
    
always mention the exception (error) that you are getting. it helps in understanding the question and giving the appropriate answer. – Alok 6 hours ago

When I run your code against the demo app, I get a NoSuchElementException: Unable to locate element: *[name='firstName']. Looks like the reason for that is that the web page is loading rather slowly, so you'll need to wait until the element is actually there before you can interact with it.

An elegant way to do this is to use the explicit wait API:

new WebDriverWait(driver, 5).until(ExpectedConditions.visibilityOfElementLocated(By.name("firstName"))).sendKeys("Vansh");
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.