我正在通過一次性密碼(OTP)編寫用於手機號碼驗證的腳本。雖然OTP彈出是開放的,我不能把值在文本字段中,系統顯示錯誤:無法找到元素:org.openqa.selenium.NoSuchElementException
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"class name","selector":"opt_success"} Command duration or timeout: 30.04 seconds"
下面是我起草的代碼。
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();
網頁的網址是:http://talentrack.in/register
錯誤不是來自您的代碼有問題。你能告訴我們調用'findElement(by.className(「opt_success」))''的行嗎? – Buaban
Buaban是對的。您顯示的代碼不會導致您顯示的錯誤。有更多的代碼,顯示它。謝謝。 – alecxe