1

I'm new to Selenium. I'm using Visual Studio 2012 and programming in C#. I can get IE11 to open and navigate to the page, but no matter which method I use to try and find an element, VS returns the NoSuchElementException. This includes when I copy/paste from an example online. There must be something I'm missing here.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;

namespace mySelenium
{
    class Program
    {
        static void Main(string[] args)
        {

            IWebDriver driver = new InternetExplorerDriver(@"C:\Users\Mike\Documents\selenium");

            //navigate to signup page
            driver.Navigate().GoToUrl("https://login.aboutone.com/sts/register?wa=wsignin1.0&wtrealm=https%3a%2f%2fgo.aboutone.com%2fhome%2ffederationresult&wctx=%2f");

            IWebElement element = driver.FindElement(By.Name("Email"));
            element.SendKeys("Tester");


        }
    }
}

The HTML for the field I'm trying to interact with is here.

<div class="form-group ">
      <label class="col-sm-4 control-label" for="Email">Email</label>
      <div class="col-sm-8">
             <input name="Email" class="form-control" id="Email" type="text" value="" data-val-required="The Email field is required." data-val-regex-pattern="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$" data-val-regex="Invalid Email Address." data-val="true">
      </div>
</div>
MikeyH
  • 25
  • 7

2 Answers2

2

I don't see your driver pointing to IEdriver it's rather pointing to the folder(may be). Correct code should look like the following

IWebDriver driver = new InternetExplorerDriver(@"C:\Users\Mike\Documents\selenium\IEDriverServer.exe");

Edit: Also, make sure to set the protected mode to same for all zoneenter image description here

Saifur
  • 16,081
  • 6
  • 49
  • 73
  • If I add " IEDriverServer.exe", I get a DriverServicenotFoundException error stating "The file C:\Users\Mike\Documents\selenium\IEDriverServer.exe\IEDriverServer.exe does not exist". – MikeyH Nov 12 '14 at 21:56
  • I suggest you use nuget instead. The configuration for IE is little bit tricky. See http://stackoverflow.com/questions/10995314/driver-executable-must-be-set-by-the-webdriver-ie-driver-system-property – Saifur Nov 12 '14 at 22:01
  • The post you linked in in Java. I know they're fairly similar, but I don't know how to convert what it says on that post to resolve my issue. – MikeyH Nov 12 '14 at 22:14
  • http://stackoverflow.com/questions/15247095/how-to-instantiate-internetexplorerdriver this is another solution to your problem. As I said try nuget instead for a cleaner maintainability – Saifur Nov 12 '14 at 22:25
  • IEDriverServer is already being accessed, opened, and navigating to web pages. I don't see how this resolves the issue of the driver not finding elements. – MikeyH Nov 12 '14 at 22:34
0

MikeyH:

The issue of the driver not finding elements is because, maybe, you are not using the correct IEDriverServer. I was facing the same behavior and I look the next:

My Selenium Version: 3.11.0

You should look for the IEDriverServer.exe for your Selenium Version (In some cases, the Windows 32 version works fine and better than the X64 version)

Try with this link:

enter link description here

nosequeweaponer
  • 511
  • 10
  • 38