Click here to Skip to main content
15,887,376 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
am trying unit testing on this code. But this program throw unhandled exception.
C#
//Create reference for out browser
          IWebDriver driver = new ChromeDriver();
          //Navigate to our page
          driver.Navigate().GoToUrl("http://www.google.com");
          //Find an element
          IWebElement element = driver.FindElement(By.Name("q"));
          //Profrom Ops
          element.SendKeys("executeautomation");
          Console.Read();


What I have tried:

what is expectation please give me solution
Posted
Comments
Richard MacCutchan 3-Mar-16 8:37am    
Add a try/catch block so you catch the exception. You can then examine the details to find out why it is thrown.
CHill60 3-Mar-16 8:38am    
What is the exception and on what line is it thrown?
I suspect that you have no element called "q" so element is null and the SendKeys fails.
Arslan saif 7-Mar-16 10:52am    
its work thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900