Element present in driver.getPageSource() but getting NoSuchElement Exception in Selenium with java



  • HTMLHi I am working on automation -selenium with java. I need to click on a button which is inside a modal popup and the whole is inside an iframe. I tried the following code:

    driver.switchTo().frame(2);
    log.info(driver.getPageSource()); 
    driver.findElement(By.className("modal-content")).isDisplayed(); 
    

    I get the element with class "modal-content" in the pagesource but NoSuchElement Exception when i run the automation script. Is there any possible way to find the element? Thanks.



  • Try this:-

    driver.switchTo().frame("frame-preview-c182db");
    driver.findElement(By.xpath(".//span[contains(text(),'Frozen')]")).isDisplayed();  
    

    Here i'm switching the frame using ID.


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2