Selenium WebDriver not able to find elements which are not present in the Page Source but present in HTML when seen through Developer Tools Selenium WebDriver not able to find elements which are not present in the Page Source but present in HTML when seen through Developer Tools selenium selenium

Selenium WebDriver not able to find elements which are not present in the Page Source but present in HTML when seen through Developer Tools


The fact that the element you are looking for is not in the page source should not be a problem. The WebDriver API was introduced to explicitly add support for dynamic pages, e.g. where elements are added via JavaScript.

However it is not sufficient that an element is in the DOM, but the element also needs to be visible. WebDriver means to only allow interactions which also a user could do, so if an element is not visible, you should e.g. not be able to click on it via WebDriver.


As per your Scenario description There can be one reason dynamically loading of content.
in this scenario selenium code runs faster while html(java script / framework) code at browser end take time to load dynamic data from server .so use waitdriver to make selenium driver wait until dynamic data loads and append to DOM

WebDriver driver = new FirefoxDriver();WebDriverWait wait = new WebDriverWait(driver, 10);Wait.Until(ExpectedConditions.visibilityOfElementLocated(By.XPath(xpathOfElement));````