-1

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sunny
  • 7,444
  • 22
  • 63
  • 104

1 Answers1

-1

Use selenium.is_visible(locator). If it doesn't work then use selenium.is_text_present(value) or if (Expectedvalue == selobj.get_value(parameter)).

If it still doesn't work, refresh the page and try the above.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sirga
  • 246
  • 1
  • 4
  • 13