I am writing script for mobile number verification by One time password (OTP). While OTP popup is open, I am unable to put value in the text field, system is showing error:
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"class name","selector":"opt_success"} Command duration or timeout: 30.04 seconds"
Below is the code that I have drafted.
driver.findElement(By.id("phone")).sendKeys(Constants.MOBILE_NUMBER);
driver.findElement(By.id("btn_verify")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebElement otp_value = driver.findElement(By.id("otp"));
otp_value.sendKeys("1212121212");
driver.findElement(By.xpath("html/body/div[4]/div/form/div/div[4]/span[1]/input")).click();
Webpage url is : http://talentrack.in/register
You need to correct your Xpath for "OTP text field" as below.
driver.findElement(By.xpath("//*[@id='verifyOTP_register']//*[@id='otp']")).sendKeys("1212121212");
Also, you can use 'relative' xpath for Submit button instead of using 'absolute' xpath.
driver.findElement(By.xpath("//*[@id='verifyOTP_register']//*[@type='submit']")).click();
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments