Experimenting with Selenium.
For example, if you create an object
ChromeDriver chrom = new ChromeDriver(); everything works, but the same version with PhantomJS does not pass (below) - throws an exception on phantomjs.FindElement (). What is there to do?
using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Support.UI; using OpenQA.Selenium.PhantomJS; using System.Drawing; using System.Drawing.Imaging; using System.Threading; namespace UnitTestProject1 { /// <summary> /// Summary description for UnitTest2 /// </summary> [TestClass] public class UnitTest3 { PhantomJSDriver phantomjs; [TestMethod] public void TestMethod3() { phantomjs = new PhantomJSDriver(); phantomjs.Navigate().GoToUrl("http://www.google.com/"); phantomjs.FindElement(By.Id("lst-ib")).SendKeys("AutoQA.org"); phantomjs.FindElement(By.Id("lst-ib")).SendKeys(Keys.Enter); Screenshot screenshot = ((ITakesScreenshot)this.phantomjs).GetScreenshot(); screenshot.SaveAsFile(@"C:\Users\User\Desktop\Новая папка\image_" + (DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss")).ToString() + ".jpg", ImageFormat.Jpeg); } // разрушение объекта драйвера после окончание теста. [TestCleanup] public void TearDown() { phantomjs.Quit(); } } }