def factory_message(js_obj, driver):
    """Factory function for creating appropriate object given selenium JS object"""
    if js_obj is None:
        return

    if "lat" in js_obj and "lng" in js_obj and js_obj["lat"] and js_obj["lng"]:
        return GeoMessage(js_obj, driver)

    if js_obj["isMedia"]:
        return MediaMessage(js_obj, driver)

    if js_obj["isNotification"]:
        return NotificationMessage(js_obj, driver)

    if 'isMMS' in js_obj and js_obj["isMMS"]:
        return MMSMessage(js_obj, driver)

    if js_obj["type"] in ["vcard", "multi_vcard"]:
        return VCardMessage(js_obj, driver)

    return Message(js_obj, driver)
Factory function for creating appropriate object given selenium JS object