<button class="button width-full button--primary" data-automation-id="signin-submit-btn" data-tl-id="signin-submit-btn" type="submit"><span class="button-wrapper">Sign in</span></button>
I need to scrape the value of "data-automation-id" with puppeteer which would be "signin-submit-btn". I know that I can grab the text by doing this
document.querySelector('button[class="button width-full button--primary"]').innerText;
but I need to know how to grab that value of "data-automation-id"
It looks like you're trying to capture the value of a Data Attribute. You can do it by referencing the button element's dataset
like this:
let mybutton = document.querySelector('button[class="button width-full button--primary"]');
let autoId = mybutton.dataset.automationId;
console.log(autoId);
<button class="button width-full button--primary" data-automation-id="signin-submit-btn" data-tl-id="signin-submit-btn" type="submit"><span class="button-wrapper">Sign in</span></button>
Reference here: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes