[Python] I'm getting an error using playwright nth-match

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    I just discovered playwright and I'm trying to see if it would be better to use than selenium. One issue I have is that none of the items in the application I write testing scripts for have names and this will not change. I'm trying to use nth-math with text to find the second instance of "login" to click the "button" on the front page, but I keep getting an error.

    Line that throws an error:

    page.locator(':nth-match:)text("Login"), 2').click()


    I also tried

    page.click(':nth-match:)text("Login"), 2')


    Both of these throw the same error playwright._impl._api_types.Error: Unexpected token "" while parsing selector ":nth-match:)text("Login"), 2"

    Continue reading...

Compartilhe esta Página