def test_get_element_by_rimo_id(self): elm = WebElement(tag='a', id='a', rimo_id='b') self.assertIsNone(getElementById('a')) self.assertIsNone(getElementByRimoId('b')) self.doc.appendChild(elm) self.assertIs(getElementById('a'), elm) self.assertIsNone(getElementByRimoId('a')) self.assertIs(getElementByRimoId('b'), elm)
def event_handler(msg: dict): """Handle events emitted on browser.""" from wdom.document import getElementByRimoId e = Event(**msg.get('event')) _id = e.currentTarget.get('id') currentTarget = getElementByRimoId(_id) if currentTarget is None: logger.warning('No such element: rimo_id={}'.format(_id)) return currentTarget.on_event_pre(e) e.currentTarget = currentTarget e.target = getElementByRimoId(e.target.get('id')) e.currentTarget.dispatchEvent(e)
def response_handler(msg: dict): """Handle response sent by browser.""" from wdom.document import getElementByRimoId id = msg.get('id') elm = getElementByRimoId(id) if elm: elm.on_response(msg) else: logger.warning('No such element: rimo_id={}'.format(id))