-1

I tried to input phone numbers in the field but it gives me an error

    Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element

Here is the code:

    driver.get("https://marswebtdc.tdc.vzwcorp.com/cdl/lte/fdr_llc/fdr.jsp?3gOr4g=4g");
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    driver.findElement(By.xpath("//*[@id='content column']/table[1]/tbody/tr/td/form/b/table/tbody/tr/td/table/tbody/tr[2]/td[4]/input")).click();
    driver.findElement(By.xpath("//*[@id='content column']/table[1]/tbody/tr/td/form/b/table/tbody/tr/td/table/tbody/tr[2]/td[4]/input")).clear();

    driver.findElement(By.xpath("//*[@id='content column']/table[1]/tbody/tr/td/form/b/table/tbody/tr/td/table/tbody/tr[2]/td[4]/input")).sendKeys("9083071303");

this is internal site you cant load the page.

I assume the sendkey() doesnt work for this field. is there any element i can use instead sendkey().

SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
tony lee
  • 25
  • 4

1 Answers1

-2

Exception org.openqa.selenium.NoSuchElementException tells the element not present on page when action is performed.

This may be because of either XPATH is not correct or element is not appeared on page before action is called.

Please run code in debug mode to find exact problem.

Here is quick example of google search box. I have put wrong id to make code fail. In this case I get the exception. If we correct the id "gbqfq" the code works fine.

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class GoogleSearchUsingSelenium {

    public static void main(String[] args) {

        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");

        try
        {
            WebElement searchBox = driver.findElement(By.id("gbqfq1")); //Incorrect ID here
            searchBox.sendKeys("Cheese");
        }
        catch(Exception e){
            System.out.println("Eelemnt Not Found : "+e.getMessage());
        }

        driver.close();

    }

}
Magnilex
  • 11,584
  • 9
  • 62
  • 84
h4k3r
  • 91
  • 5