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
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.seleniumTester– seleniumTester2018年02月19日 13:05:32 +00:00Commented Feb 19, 2018 at 13:05
Explore related questions
See similar questions with these tags.
Select
is placeholder text and selecting the element at index 0 is actually a valid option.