In my scenario I have multiple classes using

            driver.FindElement(By.Id("password")).SendKeys("54321" + Keys.Enter);

When I execute the line


I get Exception Error

Source Code:

<a class="hr" href="URL">
                        <div class="foo pixelated">
                            <img class="hr_resp" src="/Content/images/splash-images/icon_hr.png" style="margin-top:25px;">
                            <img class="hr_resp" src="/Content/images/splash-images/icon_hr_hub1.png" style="margin-top:25px;">
                        <p>Hr Managment</p>

closed as off-topic by dzieciou, c32hedge, IAmMilinPatel, Bharat Mane, Nitin Rastogi Jan 20 '18 at 3:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers." – c32hedge, IAmMilinPatel, Nitin Rastogi
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Can you please add the detail question, no one of us will be able to answer question without any resources provided by you. – Jeevan Bhushetty Jan 16 '18 at 10:44
  • 1
    please consider reading the guidelines on asking a good question , you haven't provided enough info and you have assumed your urgency applies to others. – Amias Jan 16 '18 at 10:54
  • Would you please add more details? like what is programming language you use and sample code that you are trying to execute it. – Ahmed Assem Jan 16 '18 at 11:07
  • 1
    What is the error text? Without knowing what error you are getting there is not enough information to answer your question. – Kate Paulk Jan 16 '18 at 12:37
  • Error: Unable to locate element: hr – user30347 Jan 16 '18 at 12:58

driver.FindElement(By.ClassName("")) - you need to provide a class name. Your argument is empty, obviously it cannot find it.


If you have doubt about using the driver.findElement(By.ClassName(//class name of the element)) please use the below link it's described how to find element using the class name

Blog link-softwaretestingmaterial

Git hub-seleniumhq.github

Initially search your question if any other questions answers are posted related to your asking question in before post your question.


Try to comment/delete this line driver.FindElement(By.ClassName("")); As I think it is not doing any thing in your code.

Before trying to find the element wait for it to get loaded. You can do that by using

  1. Thread.sleep() [Which is not advisable]
  2. You can use WebDriverWait to check whether the element is loaded or not. Then do a driver.findelement()

Always ask question with all the relevant details or else others will not be able to help. Go through this link how to ask question


Would you please try this :


If you use chrome, in the source code, right click on the line "<div class="foo pixelated"> and choose copy then copy XPath and paste it above.

  • Thank you for your suggestion but I am not using but I am not using XPath – user30347 Jan 16 '18 at 13:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.