For website testing in VisualStudio, I planned to use Selenium with Cromedrive. Unfortunately, I encountered difficulty in seeing items generated by Javascript on the page. It appears that chromedriver captures the pagesource before the JS has a chance to run. Despite dedicating 3 days to this issue, I have not been able to resolve it.
I came across various suggestions such as waiting for the entire page to load:
driver.Navigate().GoToUrl("http://...");
driver.WaitForPageToLoad();
System.Threading.Thread.Sleep(20000);
and different methods for waiting for element loading:
WebDriverWait waitForElement = new WebDriverWait(driver,TimeSpan.FromSeconds(5));
waitForElement.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("div.list-item[userid=2]")));
I also experimented with executing javascript and retrieving innerHTML:
uid.GetAttribute("innerHTML");
However, none of these attempts proved successful.
The only progress I made was when using the PhantomJS driver. While it performs well, my requirement is to test it with Chrome.
It seems like drivers render pages differently. For example, the ChromeDriver displays elements as:
<div class="list-item" on-click="{{selectUser}}" userid="{{u.id}}">
whereas the PhantomJSDriver renders them as:
<div class="list-item" on-click="{{ selectUser }}" userid="2">
Although the elements appear the same visually, the pagesources are different.
If you have any insights on how to obtain the same pagesource in ChromeDriver as in Chrome, your input would be greatly appreciated. Thank you.