How can I to tell if something blocks the vision of my enemy?

I have an enemy that follows a player if the player is withing a cone of vision. I need a way to stop the enemy from chasing the player if the player is behind something. I am trying to make a ray or spherecast that will go between player and enemy when the player is in the view of the enemy and if the ray or spherecast hits an object before hitting the player then the enemy should not know that the player is there. Here is a chink of the code that I am talking about.

if((Vector3.Angle(targetDirection, front) <= (fieldOfView / 2.0)) && ((pToE).magnitude <= appHorizon ))
   {
      //Debug.Log("Saw The Play Theif");
      if(!seePlayer)
      {
         seePlayer = true;
      }
      if((!sawPlayer) && (seePlayer))    
      {
         sawPlayer = true;
      }
      //Casts a elongated sphere with    origin               radius         direction        distance      layermask[NOT USED OPTIONAL] [pToE is player to enemy (vector3)]   
      if(Physics.SphereCast(transform.position, transform.localScale.y, pToE, thingSeen, Vector3.Distance(playerPos, transform.position)))
      {
         if(thingSeen.collider.gameObject.tag == player.tag)
         {
            Debug.Log("found player");
         }
         else
         {
            Debug.Log(thingSeen.collider.gameObject.tag);
         }
      }

For some reason the player.tag is only shown for a few frames and then it goes away even if the player is still in the view of the enemy. In other words the “Found player” message only appears briefly and then goes away when the player is in the field of view. The Enemy does not see walls because the Debug.Log(thingSeen.collider.gameObject.tag); returns “untagged” message and never “cube” which is what every object other then player is named.

send a ray cast from the enemy to the player and see if the object it hits is the same as the player.

 RaycastHit hit = new RaycastHit();
    

if(Physics.Raycast(enemy.transform.position, enemy.transform.position - player.transform.position, out hit))
{
     if(hit.gameObject.tag == player.tag && Vector3.Angle(enemy.transform.forward, enemy.transform.position - player.transform.position) <= fieldOfView / 2)
          seePlayer = true;
}