I've used PhantomJS in an C# application and it's not executing JavaScript even though the property PhantomJSDriver.Capabilities.IsJavaScriptEnabled is true. The simple page below still executes the content of the noscript tag. How can I make PhantomJS execute JavaScript?
I've added Selenium and PhantomJS to my VS2012 solution via NuGet:
PM> Install-Package Selenium.WebDriver PM> Install-Package PhantomJS I've created a simple HTML page to demonstrate that JavaScript is not enabled:
<html> <body> <a href="javascript:GoToAnotherPage()">Go to another page</a> <noscript> No JavaScript! </noscript> </body> </html> I've used the PhantomJSDriver. src displays "No Javascript!"
public class Program { public static void Main(string[] args) { var phantomDriver = new PhantomJSDriver(); phantomDriver.Url = @"C:\page.html"; var src = phantomDriver.PageSource; } }