Everyone who believes that the Bible is the inerrant and infallible word of God believes that all of the Hebrew Bible is inspired (literally "God-breathed"). So we can look to the Hebrew Bible to test the doctrine that God is omniscient and omniscience fails the test. I will look at two examples to show this.
The first example can be found in the book of Exodus. In the third chapter, Moses is tending the flock of his father-in-law, Jethro. As the story goes, an angel of Yahweh appeared to Moses in a burning bush but the bush is not consumed by the flames (v 2). His curiosity piqued, he decides to go over and investigate it and is told to take off his sandals for he is standing on holy ground (v 5). A conversation ensues with Yahweh telling Moses about the plight of his people in Egypt and how Moses is chosen to lead Yahweh's people out of Egypt. The conversation continues into the next chapter, where Moses asks Yahweh what should happen if the Hebrews do not believe him. In Exodus 4: 1-9, we read:
Moses answered, “What if they do not believe me or listen to me and say, ‘The Lord did not appear to you’?”
2 Then the Lord said to him, “What is that in your hand?”
“A staff,” he replied.
3 The Lord said, “Throw it on the ground.”
Moses threw it on the ground and it became a snake, and he ran from it. 4 Then the Lord said to him, “Reach out your hand and take it by the tail.” So Moses reached out and took hold of the snake and it turned back into a staff in his hand. 5 “This,” said the Lord, “is so that they may believe that the Lord, the God of their fathers—the God of Abraham, the God of Isaac and the God of Jacob—has appeared to you.”
6 Then the Lord said, “Put your hand inside your cloak.” So Moses put his hand into his cloak, and when he took it out, the skin was leprous—it had become as white as snow.
7 “Now put it back into your cloak,” he said. So Moses put his hand back into his cloak, and when he took it out, it was restored, like the rest of his flesh.
8 Then the Lord said, “If they do not believe you or pay attention to the first sign, they may believe the second. 9 But if they do not believe these two signs or listen to you, take some water from the Nile and pour it on the dry ground. The water you take from the river will become blood on the ground.”
Moses is instructed to be prepared to give the Hebrews three signs. The first is to throw a staff on the ground, which will become a snake, the second is to put his hand in his cloak and to take it out and show the leprous appearance of it, and the third is to pour water from the Nile and it will become blood. What is really telling about this passage is the part highlighted in bold. Yahweh tells Moses that if the Hebrews do not believe or pay attention to the first sign, they may believe the second. The Hebrews might believe the second?
And if they don't believe either the snake trick or the leprous hand, then Moses is to do his third miraculous act, pouring water from the Nile onto the ground. But why would Yahweh need to tell Moses that the Hebrews might believe the second one? If he is omniscient, then Yahweh knows what it's going to take to convince the Hebrews that Moses is who he says that he is. Either the Hebrews will believe the first sign or they won't. If they won't be convinced by the snake trick, why even bother with it? If the Hebrews aren't convinced by the first miracle, but may believe the second one, then what Yahweh is saying here is that even he doesn't know if the first two miracles will succeed.
How is this to be reconciled with the doctrine that Yahweh is omniscient?
As we move through the Hebrew Bible, the problem only worsens. Another example comes from the book of Jeremiah. In Jeremiah 3: 6-10, we read the following:
6 During the reign of King Josiah, the Lord said to me, “Have you seen what faithless Israel has done? She has gone up on every high hill and under every spreading tree and has committed adultery there. 7 I thought that after she had done all this she would return to me but she did not, and her unfaithful sister Judah saw it. 8 I gave faithless Israel her certificate of divorce and sent her away because of all her adulteries. Yet I saw that her unfaithful sister Judah had no fear; she also went out and committed adultery. 9 Because Israel’s immorality mattered so little to her, she defiled the land and committed adultery with stone and wood. 10 In spite of all this, her unfaithful sister Judah did not return to me with all her heart, but only in pretense,” declares the Lord.
In this passage, Yahweh is complaining to the prophet Jeremiah about how unfaithful both Israel and Judah have been during the reign of King Josiah. I have highlighted verse seven to show the problem that this poses for the omniscience doctrine. Yahweh complains that faithless Israel "has gone up on every high hill and under spreading tree and has committed adultery there". In verse seven, Yahweh states "I thought that after she had done all of this she would return to me but she did not, and her unfaithful sister Judah saw it".
So Yahweh thought that Israel would return to him but Israel didn't. So Yahweh, here, is admitting that he is mistaken. He is clearly deceived in his expectations and mistakenly thought that Israel would turn to him. How can an omniscient being be mistaken in his thoughts? If Yahweh is truly omniscient, then he would've known that Israel wouldn't have turned to him.
Things don't get any better when we move onto the New Testament. We have to remember that conservative, Bible-believing Christians believe that Jesus is God incarnate in human flesh. They believe that God is one being or essence, in three persons, Father, Son, and Holy Spirit. Therefore, according to their theology, the essence of God consists of God the Father, God the Son, and God the Holy Spirit. Jesus Christ is simply God the Son incarnate in human flesh and is a perfect union of God and man. He is 100% God and 100% man, in a "hypostatic union". Therefore, we can deduce that Jesus Christ, being God the Son, has all of the attributes of God the Father, including omniscience.
However, in Matthew 24: 36-41, we read:
But about that day or hour no one knows, not even the angels in heaven, nor the Son, but only the Father. 37 As it was in the days of Noah, so it will be at the coming of the Son of Man. 38 For in the days before the flood, people were eating and drinking, marrying and giving in marriage, up to the day Noah entered the ark; 39 and they knew nothing about what would happen until the flood came and took them all away. That is how it will be at the coming of the Son of Man. 40 Two men will be in the field; one will be taken and the other left. 41 Two women will be grinding with a hand mill; one will be taken and the other left.
In the context, Jesus is addressing his disciples about his "second coming" and the "end of the age" (Matthew 24: 3). As for when Jesus will come back, according to verse 36, no one knows, including angels or Jesus himself. Only the Father knows. But if Jesus is 100% God, and God is omniscient, then Jesus is, necessarily, omniscient. How can an omniscient being not know something that is going to happen in the future? Inerrantists love to point to the gospel of John's prologue as strong evidence that Jesus is God: "In the beginning was the Word, and the Word was with God, and the Word was God" (John 1:1) is used to argue that Jesus, being the Word is, himself, God.
Then, we have it out of the horse's mouth that even he is ignorant of at least something. We have seen that there are instances where God is either ignorant or mistaken in his thinking. In any case, God is not omniscient. If God is not omniscient, he doesn't have perfect knowledge. If God doesn't have perfect knowledge, then God is not a perfect being, perfect in all of his attributes.