I am automating a website, there's web page containing few text fields, dropdowns. There is a mandatory field check for a dropdown, if I select the default option (which is 'Select') I get an error message - 'This field is required' which is expected.

If I automate the above scenario, using selenium c#, I do not get any error message if I select the default option using my user defined function(taking dropdown elements into a list and clicking on 0th element which is 'Select'). I am navigated to the next page, which is not expected.

I am just curious to know why this different behavior for automation and manual parts. I am giving sufficient wait time for the error messages, even after entering the data I have given wait time, then why the difference?

Update: DOM Snapshot

  • Can you please share the HTML code as well? Can only guess without it.
    – Yu Zhang
    Feb 16, 2018 at 16:02
  • Added the DOM snippet. Feb 16, 2018 at 16:28
  • 1
    Need to see the HTML select tag code. Perhaps Select is placeholder text and selecting the element at index 0 is actually a valid option. Feb 16, 2018 at 18:17
  • Index 0 has 'Select' option. The list of items contains: [0] : Select [1] : 1 month [2] : 2 months ..... till [13] elements like this. The HTML DOM has <ul> with 13 <list items>. I am using findElements(By.TagName("li")) to get all the list items into a list and then using list[0].Click() to click on the Select option. But from automation it is selecting that and navigating to next page, which should not happen. Feb 17, 2018 at 14:52
  • I changed the NextButton.Submit() to NextButton.Click(). It is working fine now, getting error message upon click next button. I believe that upon using Click() method, javascript validations are getting executed. But upon Submit() - form2Url execution happens. This variation might be occurring due to difference between Submit() and Click() functions? Can someone throw some light on this? Feb 19, 2018 at 9:42

1 Answer 1


There is no difference with some exceptions. The way how Selenium clicks or types into the web elements is different from real behavior. Selenium does not simulate mouse moves and clicks or keyboard types but just injects the events.

That could be the reason why the application is not triggered the same way. Please try to use de-focusing / focusing the object first.

But most probably you have a wrong xpath/identifier as you refer to the "0th element" which looks quite strange. Please try to validate the xpath in Chrome DEV tools.

  • I am looking for first element of the list which is stored at index 0. Please excuse the typo. Feb 19, 2018 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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