I have the following HTML in my LWC component-
<template>
<div class="firstdiv">
<div class="firstinsidefirstdiv fifd">
1234
</div>
<div class="secondinsidefirstdiv sifd">
5678
</div>
</div>
<div class="seconddiv">
<!-- <div data-id="firstinsideseconddiv fisd"> -->
<div class="firstinsideseconddiv fisd">
9876
</div>
<div class="secondinsideseconddiv sisd">
5432
</div>
</div>
<lightning-record-view-form
record-id="00xxxxxxxxxxxJ"
object-api-name="Contact">
<div class="slds-box slds-theme_default">
<span>inside span</span>
<lightning-output-field field-name="Name">
</lightning-output-field>
<lightning-output-field field-name="Phone">
</lightning-output-field>
<lightning-output-field field-name="Email">
</lightning-output-field>
<lightning-output-field field-name="Birthdate">
</lightning-output-field>
<lightning-output-field field-name="LeadSource">
</lightning-output-field>
</div>
</lightning-record-view-form>
and the following JS -
renderedCallback(){
let div = this.template.querySelectorAll('.seconddiv>.firstinsideseconddiv');
console.log("inside renderedCallback");
div.forEach(element => {
console.log("text content " + element.textContent);
console.log("inner html " + element.innerHTML);
});
console.log('second console');
div = this.template.querySelectorAll('lightning-output-field');
console.log(this.template);
console.log(this.template.childNodes);
console.log(this.template.childNodes[2].children["0"].children[1].outerHTML);
console.log(this.template.childNodes[2].children["0"].children[1].shadowRoot);
console.log(this.template.childNodes[2].children["0"].children[1].shadowRoot.children[0].innerHTML);
I am unable to access the shadowRoot element even though it shows up in the dom in chrome- Also when i try to print the innerText of "" nothing is printed even though it has a value-
Please let me know how I can access the shadowRoot of an element and why the innerText is not being printed.