Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error CS0103: The name 'page' does not exist in the current context using sample code in documentation #2738

Closed
marketier opened this issue Oct 31, 2023 · 0 comments · Fixed by microsoft/playwright#27988
Assignees
Labels

Comments

@marketier
Copy link

System info

  • Playwright Version: 1.35.0
  • Operating System: Windows Serve 2019, .net6.0
  • Browser: Chromium

Source code

The code is from the documentation.

using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Playwright;
using Microsoft.Playwright.NUnit;
using NUnit.Framework;

namespace PlaywrightTests;

[Parallelizable(ParallelScope.Self)]
[TestFixture]
public class Tests : PageTest
{
    [Test]
    public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
    {
        await Page.GotoAsync("https://playwright.dev");

        // Expect a title "to contain" a substring.
        await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));

        // create a locator
        var getStarted = Page.GetByRole(AriaRole.Link, new() { Name = "Get started" });

        // Expect an attribute "to be strictly equal" to the value.
        await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro");

        // Click the get started link.
        await getStarted.ClickAsync();

        // Expects page to have a heading with the name of Installation.
        await Expect(page
            .GetByRole(AriaRole.Heading, new() { Name = "Installation" }))
            .ToBeVisibleAsync();
    }
}

Steps

  • dotnet test --settings PlaywrightTests.runsettings

Expected

Chromium browser to launch and test to run for https://playwright.dev

Actual

The following error is reported:

error CS0103: The name 'page' does not exist in the current context

@marketier marketier changed the title [BUG] Error CS0103: The name 'page' does not exist in the current context using sample from documentation [BUG] Error CS0103: The name 'page' does not exist in the current context using sample code in documentation Oct 31, 2023
@mxschmitt mxschmitt added the v1.40 label Nov 6, 2023
@mxschmitt mxschmitt self-assigned this Nov 6, 2023
mxschmitt added a commit to microsoft/playwright that referenced this issue Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants