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(); } } } 
  • one
    what's the exception? - etki
  • An exception of type 'OpenQA.Selenium.NoSuchElementException' occurred in WebDriver.dll but it was not handled in user code - pontekorvo
  • Additional information: {"errorMessage": "Unable to find element with id 'lst-ib'", "request": {"headers": {"Accept": "application / json, image / png", "Connection": "Close", "Content-Length": "31", "Content-Type": "application / json; charset = utf-8", "Host": "localhost: 9483"}, "httpVersion": "1.1" , "method": "POST", "post": "{\" using \ ": \" id \ ", \" value \ ": \" lst-ib \ "}", "url": "/ element "," urlParsed ": {" anchor ":" "," query ":" "," file ":" element "," directory ":" / "," path ":" / element "," relative ": " - pontekorvo
  • / element "," port ":" "," host ":" "," password ":" "," user ":" "," userInfo ":" "," authority ":" "," protocol ": "", "source": "/ element", "queryKey": {}, "chunks": ["element"]}, "urlOriginal": "/ session / c2033b40-d515-11e6-ba5b-39ea095bef93 / element" }} - pontekorvo
  • add to the question, it is impossible to read without formatting - etki

0