Website has a button with text that changes dynamically.
Elements before button text change:
<button _ngcontent-wex-c70=""
class="btn btn-wait buy font-family-title height-70 pp-sun-ins"><label _ngcontent-wex-c70="" translate=""
class="font-family-title label">BUY</label>
</button>
Elements after button text change:
<button _ngcontent-wex-c70=""
class="btn btn-root press font-family-title pp-sun-ins"><span _ngcontent-wex-c70=""
class="d-power power-column justify-content-center align-items-center"><label _ngcontent-wex-c70="" translate="">EXIT NOW</label><label _ngcontent-wex-c70=""
class="price"><span _ngcontent-wex-c70=""
class="cost">1.46</span><i _ngcontent-wex-c70=""
class="UNT"></i></label></span>
</button>
I can get the value of cost using this method:
<script>
var cost = document.getElementsByClassName("cost")[0].innerText;
console.log("my cost is: "+cost)
</script>
This works from the online JavaScript tester at "https://jsfiddle.net/"
However on the Chrome browser the following error is returned:
Uncaught TypeError: Cannot read properties of undefined (reading 'innertext')
I can confirm that the elements shown from "Elements after button text change" are present using the Developer Elements Inspector.
In the Chrome browser console I only run the following code:
var cost = document.getElementsByClassName("cost")[0].innerText;
console.log("my cost is: "+cost)