I have checked Google for this error. But the solution has not been very helpful. I would appreciate your help, please.
The URL of the webpage that I am trying to automate is: https://www.starwoodhotels.com/preferredguest/account/sign_in.html
The code that I have written up to automate the login page is:
using System;
using System.Collections.Generic; using System.Linq; using System.Text; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System.Threading.Tasks;
namespace StarWood_Hotels_Valid_User_Login { class Program { static void Main(string[] args) { //Instantiate Firefox Driver var driver = new FirefoxDriver(); driver.Navigate().GoToUrl("https://www.starwoodhotels.com/preferredguest/account/sign_in.html");
//Enter User Name - AutoTest1
var user = driver.FindElement(By.Id("userName"));
user.SendKeys("AutoTest1");
//Enter Password - Testing123
var pass = driver.FindElement(By.Id("userPassword"));
pass.SendKeys("Testing123");
//Click on submit button
driver.FindElement(By.Id("actionLink right")).Click();
}
}
}
=======================================================================
I have used HTML elements from Firebug to identify the necessary web elements.
========================================================================
Here is the error:
An unhandled exception of type 'OpenQA.Selenium.NoSuchElementException' occurred in WebDriver.dll
Additional information: Unable to locate element: #userName