I have a text field, which contains the default text 'abc'
. When I write something inside this field or the cursor is inside this field then the default text disappears. The underlying HTML tag for this field is:
<div id="InputDefault" class="defaultText" style="visibility: visible;">abc</div>
Now, manually everything works fine. I am writing a test-case in Selenium to check if the default text appears once the field is empty. But in the test-case, it somtimes works and more often it fails. I have written the following function:
#I first delete the text in the field (I have used a text element)/
self.se.type(#I first delete the text in the field (I have used a text element).
self.se.type(locators["search_field_header"], "")
#Then I focus on the field.
self.se.set_cursor_position("headerParam", "")
#Then I focus on the field
self.se.set_cursor_position("headerParam",0)
#Press the TAB key to move focus away from the search field to get default text.
self.se.key_press_native("9")
self.se.set_speed(1000)
is_footer_default_text_present = self.is_element_available("InputDefault")
But this is somehow not working. What is the problem and is there a better/robust solution?