C# (.net Framework 4) で Web 自動化ツールを開発しています。Selenium webDriver と PhantomJS を使用しています。それは本当に素晴らしいことです!しかし、「ネイティブな」PhantomJS js コマンドを使用したい場合がありuploadFile
ますinjectJs
。
今phantomjsを使用する方法:まず、--webdriver=
paramを使用してphantomjs実行可能ファイルを開始します。次は:
// connection
private bool ConnectToWebDriver()
{
try
{
_driver = new RemoteWebDriver(new Uri(localHost+':'+numericPortSelector.Value+"/wd/hub"),
DesiredCapabilities.PhantomJS());
_scriptExecutor = _driver as IJavaScriptExecutor;
_driver.Manage().Timeouts().SetPageLoadTimeout(new TimeSpan(0, 0, (int) numericTimeOut.Value));
return true;
}
catch (Exception)
{
return false;
}
}
ありがとう!