Robot framework,Selenium,Python-key down in loop in combobox skips values -
i need iterate on items in combobox, not created regular combobox (select element), "complicated" js component. wrote while loop in python press key down (to item), check whether there message on page , if messages not there, loop should end. not work properly. not go 1 item, seems go 3 items. (i print out "messages true/false" can see if chooses 15th item, there 5 messages loop instead of 15) have no idea how force key pressed shorter time, move 1 item.
the function:
def find_not_used_protocol(self,entity): actionchain = self.get_action_chain() message = true msgs=[] while message: #actionchain.key_down(keys.arrow_down) #i tried did not behave better actionchain.send_keys(keys.down).perform() actionchain.release() #builtin().sleep(1) #i tried did not behave better message = self.get_library_instance()._is_text_present( "this protocol has "+entity+". please select different protocol.") msgs.append(message) #this here better debug return msgs
use in robot:
set protocol ${entity} wait until element visible ${protocol input} 20 input text ${protocol input} 0001 click element ${protocol arrow down} #set selenium speed .5 seconds #it not ${msgs}= find not used protocol ${entity} log console ${msgs}
this combo, might have 400 items etc. of them there message displayed on page , not. need stop loop on item without message...
code of get_library_instance (my function):
def get_library_instance(self): if self.library none: self.library = builtin().get_library_instance('extendedselenium2library') return self.library
code of _is_text_present (from selenium2library):
def _is_text_present(self, text): locator = "xpath=//*[contains(., %s)]" % utils.escape_xpath_value(text); return self._is_element_present(locator)
i'll glad suggestion how make work. thanks!
so found out why loop did not behave expected. actionchain chains events, has defined out of loop , performed in loop. goes beautifully 1 item in combo. :)
def find_not_used_protocol(self,entity): actionchain = self.get_action_chain() actionchain.send_keys(keys.down) actionchain.release() message = true while message: actionchain.perform() message = self.is_text_present( "this protocol has "+entity+". please select different protocol.")
Comments
Post a Comment