0

I am attempting to create Coded UI tests for my organization. I'm using Selenium IDE 2.9.1, the plugin for Firefox. I'm recording my steps using the plugin, and then exporting my test case as a "C# / NUnit / WebDriver" file. I then open this file in Visual Studio 2015.

My current issue is that I cannot get the FindElement function to select the proper field. I'm using the following to select the field, but it's not working properly:

driver.FindElement(By.Id("FIELDID")).SendKeys("TEXTTOINPUT");

When I debug, this step causes Firefox to focus on the URL bar at the top of the page and then causes a System.NullReference exception.

I have searched all over, and cannot find a solution that works for my problem. I'd appreciate any information you can provide.

Regards, JM

Tagc
  • 8,736
  • 7
  • 61
  • 114
JacobCoy9
  • 1
  • 1
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – AdrianHHH Jan 06 '17 at 10:55

2 Answers2

0

Can you inspect the page using FireBug? That will give you the actual name of the field you are trying to find in Selenium. My guess is that either the id isn't actually set or it is dynamically generated which would make it different than what you are using the FindElement(By.Id("FIELDID")).

Andy J
  • 556
  • 3
  • 21
  • Turned out to be because the item i was selecting was in a frame. We used 'driver.SwitchTo().Frame(driver.FindElement(By.Id("tabRequests_frame0")));' which worked perfectly. – JacobCoy9 Jan 06 '17 at 14:33
0

We used

driver.SwitchTo().Frame(driver.FindElement(By.Id("tabRequests_frame0")));

...because the item we were selecting was in a frame.

JacobCoy9
  • 1
  • 1