String alreadyuploaded="Mentioned upload file has already been uploaded";

String msg= DriverUtility.waitForAlertMsg(driver);
if(msg!= null && msg.contains("Wrong")|| msg.contains("Duplicate")|| msg.contains(alreadyuploaded))
    System.out.println("Invalid Receipt Upload or already uploaded");
    //      FinnoneOpration.ReceiptFlag=false;
    Alert alert1 = driver.switchTo().alert();
    System.out.println("alert1 text using  file upload is::"+alert1);
    Runtime.getRuntime().exec("taskkill /IM iedriverserver.exe /F");
  • 2
    I am not seeing any .getText() method in the query. – Alok Feb 1 '18 at 16:51
  • Can you provide the error message as well? – Swagin9 Feb 1 '18 at 18:53

If the alert is not displayed or accessable, driver.switchTo().alert() will return null and alert1.accept(); will raise a NullPointException.

If that's the case, waitForAlertMsg may have some problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.