Search code examples
c#puppeteer-sharp

Puppeteer.net: cant figure out the selector


I am using puppeteer in trying to find the selector for a login page. the login html is:

<form action="/login?app=LM&var=au" method="POST" name="login-form" id="login-form">
           
<input type="hidden" name="_csrf" value="BQ2YoR3d-5P__6b5HfqlVOjv8YgTypKV92XA" />
            
            <div class="form-group text-center">
              <input type="text" name="username" id="login-form-username" placeholder="Username" class="form-control" required value="">
            </div>
            <div class="form-group text-center">
              <input type="password" name="password" id="login-form-password" placeholder="Password" class="form-control" required>
            </div>
            <div class="text-center">
              <button type="submit" class="btn btn-danger btn-lg btn-block">Login</button>
            </div>
</form>

I tried #submit, #login-form-submit and several others for the selector. what would the selector for the login button be as there is no ID name?

i am using ClickAsync();


Solution

  • Either give your submit button an id property and use the #submit selector you previously tried:

    <button id="submit" type="submit" class="btn btn-danger btn-lg btn-block">Login</button>
    

    Or use form button[type=submit] as selector.