To identify elemental resistances should be done within the system of the Loremaster ability.
Not really required. At least if there is trial or error logic.
AI should be able, based on final damage it does to the enemy, and what is expected damage against non-resistant enemy, to get approx. level of the resistance of the opponent, and based on that add this to decision chain, either to continue attacks with such element, or switch to something else.