0

I used Selenium(version 4.1.0) in a C# project.I looked up a lot of information. This is My code

ChromeDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("xxxx");
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
wait.Until(ExpectedConditions.ElementExists(By.Id("xxx")));
context.Response.Write(driver.pageSource);

This is very effective for get full page html until I test https://jp.mercari.com. It can not get full page.

Is there any other way to get the complated page source?

Alex.Zou
  • 1
  • 1

1 Answers1

0

You aren't getting the get full page html as a lot of the elements are distributed within multiple #shadow-root (open) elements.

mercari


Conclusion

Even after the webpage compltes rendering the HTML DOM, the entire pageSource may not be available. To access the entire DOM Tree you have to use Document.querySelector().

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I used document.querySelector get the IWebelement ,i can get the text ,but can't get html code by GetAttribute("innerHTML") ,why? – Alex.Zou Mar 30 '22 at 10:34