The Romans faced war elephants a few years before the First Punic War. In 280 B.C. Pyrrhus brought 20 war elephants from Greece to Rome. As Cassius Dio (via Zonaras) reports in book IX:
Now Pyrrhus set out, not even awaiting the coming of spring, taking along a large, picked army, and twenty elephants, beasts never previously beheld by the Italians; hence they were invariably filled with alarm and astonishment.
Before the battle, the Roman consul Laevinus made a speech to alleviate fear among his legionaries, fear caused by the reputation of Pyrrhus and the presence of elephants. Pyrrhus kept his elephants in reserve initially. During the battle he used them to counter Roman cavalry which was threatening his rear. The account Cassius Dio / Zonaras gives is quite something:
Then, indeed, at the sight of the animals, which was out of all common experience, at their frightful trumpeting, and also at the clatter of arms which their riders made, seated in the towers, both the Romans themselves were panic-stricken and their horses became frenzied and bolted, either shaking off their riders or bearing them away. Disheartened at this, the Roman army was turned to flight, and in their rout some soldiers were slain by the men in the towers on the elephants' backs, and others by the beasts themselves, which destroyed many with their trunks and tusks (or teeth) and crushed and trampled under foot as many more.
Keep in mind that Cassius Dio wrote his history in the 2nd century AD, more than four centuries after the battle, and this part was excerpted by Zonaras 1000 years after that. So this shouldn't be taken too literally, but the takeaway is that the Romans didn't manage the first encounter with elephants very well.