0

It's not in frame and throwing an error while enter credit card number. Please note it's an angular-based website.

driver.findElement(
    By.xpath("//input[@id='credit-card-number']")
).sendKeys("4111111111111111");

Error in console

FAILED: orderplace
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@id='credit-card-number']"}
  (Session info: chrome=84.0.4147.89)
Ackdari
  • 3,222
  • 1
  • 16
  • 33
  • 1
    Be sure page is loaded and element is realy present. Start with Thread.sleep(int miliseconds), consider implicit or explicit wait methods, see https://www.guru99.com/implicit-explicit-waits-selenium.html. If it not helps please add html source code. – pburgr Jul 28 '20 at 07:08

1 Answers1

0

Try to use this code code:

WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement myinput = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@id='credit-card-number']")));
myinput.sendKeys("4111111111111111");

I have added wait 'till the input box is visible. Once it is visible you can put text inside it.

Calaf
  • 1,133
  • 2
  • 9
  • 22
Swaroop Humane
  • 1,770
  • 1
  • 7
  • 17