title: Playwright Python. - How to check if an element is hidden
body: <p>I'm currently using Playwright / Python / Pytest and I am attempting to user login as a particular type of user role and then check to see if various buttons are visible or hiddedn.</p>
  <p>I am using page object and have set properties up for each button element i.e.</p>
  <pre><code>    @property
      def manage_placements_button(self):
      return self.page.wait_for_selector(&quot;xpath=//h3[normalize-space()='Manage Placements']&quot;)
      
      @property
      def my_holiday_button(self):
      return self.page.wait_for_selector(&quot;xpath=//h3[normalize-space()='My Holiday']&quot;)
  
      @property
      def my_payments_button(self):
      return self.page.wait_for_selector(&quot;xpath=//h3[normalize-space()='My Payments']&quot;)
  
      @property
      def my_compliances_button(self):
      return self.page.wait_for_selector(&quot;xpath=//h3[normalize-space()='My Compliances']&quot;)
  </code></pre>
  <p>Then I am using a verify method for the visible buttons:</p>
  <pre><code>    def verify_candidiate_can_see(self):
      result = self.manage_timesheets_button.is_visible()
      result = self.my_payments_button.is_visible() and result
      result = self.my_holiday_button.is_visible() and result
      result = self.my_compliances_button.is_visible() and result
      return result
  </code></pre>
  <p>This works fine and it passes back true for the assertion in the test.</p>
  <p>I am then attempting to do the same with the hidden values using:</p>
  <pre><code>    def verify_candidiate_cant_see(self):
      result = self.manage_placements_button.is_hidden()
      return result
  </code></pre>
  <p>but I get this error - waiting for selector &quot;xpath=//h3[normalize-space()='Manage Placements']&quot; to be visible</p>
  <p>Here is the test:</p>
  <pre><code>  @pytest.mark.order(2)
    def test_candidate_login(context, env):
    page = context.new_page()
    home_page = HomePage(page)
    login_page = LoginPage(page)
    login_page.navigate(env)
    login_page.login(env, &quot;Candidate&quot;)
    result1 = home_page.verify_candidiate_can_see()
    assert result1 == True
    result2 = home_page.verify_candidiate_cant_see()
    assert result2 == True
    context.close()
  </code></pre>
  <p>I assumed as I added is_hidden it would be ok as the element does not exist on the page but it appears it's still waiting for it to be visible. Any help would be greatly appreciated</p>