Today, contemporary people might look askance at a purportedly "factual" document that includes supposedly realistic encounters with gods, monsters, ghosts, magicians with supernatural powers, etc. - but how do historians deal with such fantastical elements? Are they disregarded as fictitious, or what?
It really depends on what you're trying to study and on what the "fantastical element" is doing in a particular source.
In some cases, you're trying to understand how people in a particular place and time understood the world around them, how they interpreted causality, and in those cases what we think of as "fantastical elements" are valuable evidence of what you're interested in--and you have no particular need to remind yourself constantly that these events or descriptions are untrue or imaginary. You're interested in them as a window into the worldview and everyday understandings of people in the past, interested in them in their context.
You may still be faced with a question of whether in fact those people actually believed in what they describe, and whether those beliefs actually motivated their actions. To cite an example from my field, in 1856-57, a young Xhosa woman named Nongqawuse living in the Eastern Cape in South Africa reported that she had a prophetic vision that if the Xhosa living in the region killed all their cattle and burned all their crops, ancestral spirits would return and chase invading British armies into the sea, restoring the autonomy and wealth of the Xhosa people. Many people acted upon this vision and did what she asked; the result was a famine that killed many thousands.
I had a professor in graduate school who was fond of saying that the notable thing about the prophecy is that it was wrong--the ancestors did not return. This seemed to me then and still seems rather beside the point--to look at this episode and think the most interesting thing about it is that people believed in the wrong thing is to announce a complete lack of interest in the Xhosa themselves or in the times in which they lived. Much as it would be sort of pointless to study the Catholic Church's history as a history of failed beliefs in non-existent fantastical events. That's ok if you're involved in a philosophical fight about religion, but it's not ok as a basis for historical study.
Nevertheless, there might be some reasons for paying less attention to Nongqawuse and her prophecies in studying the events of 1856-57. The historian J.B. Peires has argued that the cattle-killing was not primarily motivated by her prophecies, but was instead a dramatic example of a routine response to rinderpest and other diseases affecting cattle, and that crops had already failed due to drought--that the Xhosa were doing what skilled pastoralists and agriculturalists do in the face of environmental or ecological disasters, that there was going to be a famine regardless of the prophecy. Other scholars have pointed out that the Xhosa had just lost the most catastrophic of a long series of losing frontier wars with the British--and that "burning the boats behind you" can be one way to motivate people to continue fighting in some form of total war where surrender might mean annihilation.
So sometimes you might not want to simply accept that people in the past were primarily motivated by a belief in spiritual, supernatural or otherwise seemingly unreal forces or concepts and instead hunt for other explanations. I think most historians would avoid going too far in that direction--say, like the materialist anthropologist Marvin Harris, who argues that every spiritual, religious or supernatural belief or practice is actually just a superficial disguise for some highly adaptive underlying cause or explanation for what people do.
Occasionally, it may also be worth asking if there is something 'real' lurking underneath some form of fantastical report. Most historians have taken for granted that Herodotus' report of ants that dug for gold in South Asia was not in any meaningful sense true, but quite a few historians have wondered whether that was a garbled, distorted version of something real. Most of the time I personally find that genre of history--the "quest to show that a crazy, fantastical sounding thing was in fact real!"--to be pretty dubious. It's usually someone play-acting at being Indiana Jones, someone who is painfully literalist, or occasionally just an outright nutcase. But it's not unreasonable to posit that some mythological or fabulistic stories in human history may refer to real events that have acquired more exotic or mythological trappings over time.
A lot of the time “is this true or not?” Isn’t the best question to ask of this kind of material. Better questions are things like Did the source believe it was true? If so, what does that tell us about how that person understood the world/their place in it/society? How did that affect their/their contemporaries behavior? How does this narrative help them make sense of events? What beliefs led to the inclusion of the fantastical elements? Whether we think the source believed the fantastical elements or not (but especially interesting if we think not) why did they include it? What does getting other people to believe it do for them/their patrons?
A lot of the time whether or not a historical account is factual is the least interesting thing about it.
There’s a question and answer(s) from u/typhon1714 and u/nientenada dealing with specific fantastical elements (battling giant spiders) here