My code is
String OTP = driver.findElement(By.xpath("//span[@id='otp']")).getAttribute("value");
System.out.println(OTP);
Assuming you are trying to get the text in the span. getAttribute("value")
only works for textbox, textarea. For span div and others use getText()
driver.findElement(By.xpath("//span[@id='otp']")).getText();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With