8000 [Bug]: IntelliSense Not Working for expect(locator).to_be_... in VS Code with Pylance · Issue #2901 · microsoft/playwright-python · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: IntelliSense Not Working for expect(locator).to_be_... in VS Code with Pylance #2901
Closed
@willischu-caprx

Description

@willischu-caprx

Version

Version 1.50.0

Steps to reproduce

  1. Create a virtual environment and install Playwright:
  • python3 -m venv .venv
  • source .venv/bin/activate
  • pip install playwright
  1. Use the following code in VSCode:
from playwright.sync_api import sync_playwright, expect, Locator

def run():
    with sync_playwright() as p:
        browser = p.chromium.launch()
        page = browser.new_page()
        locator: Locator = page.locator("text=Submit")
        result = expect(locator)
        result.to_be_  # <- IntelliSense does not suggest anything here

  1. Hovering over result or using reveal_type(result) shows "No definition found" or Unknown.

Expected behavior

VS Code should suggest assertion methods like .to_be_visible(), .to_be_hidden(), etc., when using expect(locator).

Actual behavior

When using expect(locator) in Playwright Python, IntelliSense/autocompletion in VS Code (with Pylance) does not suggest any .to_be_... assertion methods, even when the locator is explicitly typed.

Additional context

No response

Environment

OS: macOS
Python: 3.12.3
Playwright: 1.50.0
VS Code: 1.101.1 (Universal)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0