org.openqa.selenium.WebDriverException - 无法点击验证按钮

时间:2016-04-26 17:31:35

标签: selenium selenium-webdriver

我正在编写用于验证手机号码的脚本,当我点击验证移动按钮元素时,显示以下错误。

  

org.openqa.selenium.WebDriverException:元素无法点击   点(285.5,59.600006103515625)。其他元素会收到   单击:命令持续时间或   超时:78毫秒

我已编写此代码以验证具有不同条件的OTP。

// Verify OTP should not accept more than 6 characters value
        String otp = Constants.WRONG_OTP;       
        driver.findElement(By.id("phone")).sendKeys(Constants.MOBILE_NUMBER);
        driver.findElement(By.id("btn_verify")).click();
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        WebElement otp1_value = driver.findElement(By.xpath("//*[@id='verifyOTP_register']//*[@id='otp']"));
        otp1_value.sendKeys(Constants.WRONG_OTP);
        if(otp.length()>6){
            driver.findElement(By.xpath("//*[@id='verifyOTP_register']//*[@type='submit']")).click();
            System.out.println("Incorrect otp");
        }
        driver.findElement(By.xpath("//*[@id='verifyOTP_register']//*[@type='button']")).click();
        // verify message after entering correct OTP
        driver.findElement(By.id("phone")).clear();
        driver.findElement(By.id("phone")).sendKeys("1231231232");
        driver.findElement(By.xpath("//*[@id='form_register']//*[@type='button']")).click();
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        WebElement otp_value = driver.findElement(By.xpath("//*[@id='verifyOTP_register']//*[@id='otp']"));
        otp_value.sendKeys(Constants.MOBILE_OTP);
        driver.findElement(By.xpath("//*[@id='verifyOTP_register']//*[@type='submit']")).click();
        String otp_success_msg = driver.findElement(By.className("opt_success")).getText();
        System.out.println(otp_success_msg);
        WebElement otp_reset = driver.findElement(By.xpath("//*[@id='verifyOTP_register']//*[@id='otp']"));
        otp_reset.clear();

0 个答案:

没有答案