0

After handling Alert and waits(popup at runtime,)The page is not loading which is why cannot locate elements. (in Selenium)getting no such element: Unable to locate element:

''''public class ApplicantLoginPageTest extends TestBase{

  @Test
    public void init() throws Exception { 
      
     
    ApplicantLoginPage applicantLoginPage = PageFactory.initElements(driver, ApplicantLoginPage.class);
    
      applicantLoginPage.getApp(prop.getProperty("urlapp"));
      Thread.sleep(3000);
      
      applicantLoginPage.login(prop.getProperty("un"));
      Thread.sleep(3000);
            
      applicantLoginPage.instruct1();
      Thread.sleep(3000);
      
      applicantLoginPage.TestClick();
      try {
            WebDriverWait wait = new WebDriverWait(driver, 2);
            wait.until(ExpectedConditions.alertIsPresent());
            Alert alert = driver.switchTo().alert();
            alert.accept();
            driver.switchTo().defaultContent();
        } catch (Exception e) {
        }
         applicantLoginPage.TestCamera();
        Thread.sleep(15000);
        applicantLoginPage.PreviewRecord();
        Thread.sleep(15000);
        applicantLoginPage.instruct2();
        Thread.sleep(3000);
    }
}''''
kallursh
  • 1
  • 1

1 Answers1

0

remove the following statement, and try again:

driver.switchTo().defaultContent();
Peter Quan
  • 788
  • 4
  • 9