我有一个案文领域,其中载有缺省案文<条码>abc条码>。 当我写该领域的某件事或幕后,缺省案文就消失了。 该领域的超文本标签是:
<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")
但这只是一些不起作用。 问题是什么,是否有更好的/滥用的解决办法?