SOLVED:Webdriver unable to locate element

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

SOLVED:Webdriver unable to locate element

ccox
This post was updated on .
I am using Visual Studio with Selenium Webdriver and NUnit and I am unable to interact with any element on a page for this site. Selenium IDE can interact with most of it, but Webdriver can't interact with any.  I used the same code against Google it works as expected so I know its not a set up error.  

This is the html:
<input name="txtDisplayName" class="textbox" id="txtDisplayName" type="text" size="50" maxLength="64"/>

This is the command I use:
 driver.FindElement(By.Id("txtDisplayName")).SendKeys("Display Name");

This is the error:
TestSelenium.Class1.AddClass:
OpenQA.Selenium.NoSuchElementException : Unable to find element with id == txtDisplayName

This is the log
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 983
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 844
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 873
at OpenQA.Selenium.By.FindElement(ISearchContext context) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\By.cs:line 306
at TestSelenium.Class1.AddClass() in C:\Users\MyDocuments\Documents\Visual Studio 2010\Projects\TestSelenium\TestSelenium\Class1.cs:line 31
Reply | Threaded
Open this post in threaded view
|

Re: Webdriver unable to locate element

ccox
No ideas?
Reply | Threaded
Open this post in threaded view
|

Re: Webdriver unable to locate element

softwaretestingforum
Administrator
Could you post more of your test scripts ?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Webdriver unable to locate element

ccox
The browser opens fine, but the script is unable to interact with anything in the browser.

public class Class1
    {
        public IWebDriver driver;
        public String baseURL;

        [SetUp]
        public void SetUp()
        {
            var options = new InternetExplorerOptions();
            options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
            driver = new InternetExplorerDriver(@"C:\", options);
            baseURL = "http://testURL";
         
        }
        [Test]
        public void AddClass()
        {
            driver.Navigate().GoToUrl(baseURL + "/Pages/Process/Configuration/Class/Details.aspx");    
            driver.FindElement(By.Id("txtDisplayName")).SendKeys("Display Name");
Reply | Threaded
Open this post in threaded view
|

Re: Webdriver unable to locate element

softwaretestingforum
Administrator
I don't really work on IE so can not comment.
Could you try with FF and Chrome to find out if it is IE only issue?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Webdriver unable to locate element

ccox
I tried in Firefox and get basically the same error: TestSelenium.Class1.AddClass:
OpenQA.Selenium.NoSuchElementException : Unable to locate element: {"method":"id","selector":"txtDisplayName"}

This product is only supported in IE.  Do you have any other ideas, Tarun?
Reply | Threaded
Open this post in threaded view
|

Re: Webdriver unable to locate element

softwaretestingforum
Administrator
Could you keep a break point at this step and check if element is really available -

            driver.FindElement(By.Id("txtDisplayName")).SendKeys("Display Name");
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Webdriver unable to locate element

ccox
It is still unable to find any of the elements with the break point added and stepping through them.
Reply | Threaded
Open this post in threaded view
|

Re: Webdriver unable to locate element

softwaretestingforum
Administrator
Is there any way for me to access you application.
You could drop me details at - tkumarb @ gmail.com
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

SOLVED:Webdriver unable to locate element

ccox
I did end up figuring this out.  The page I was on contains iframes.  I had to switch to the iframe for WebDriver to interact with the content.
Reply | Threaded
Open this post in threaded view
|

Re: SOLVED:Webdriver unable to locate element

softwaretestingforum
Administrator
glad that you were able to solve it :)
~ seleniumtests.com