The Website
<p style="margin:1em auto; padding:0 1em; max-width:700px;">
<b>
Lamborghini</b>
<br>
<img style="width:300px" src="https://i0.wp.com/www.car-revs-daily.com/wp-content/uploads/2016/02/2011-Lamborghini-EGOISTA-22.jpg">
<br>
2013 Lamborghini Egoista
</p>
I want to extract the name of the random car (2013 Lamborghini Egoista).
I have tried:
String text= (String) jsExecutor.executeScript("document.querySelector('#output-container p').innerText;");
System.out.println(text);
,but it didn’t work:
org.openqa.selenium.JavascriptException: javascript error: Cannot read properties of null (reading ‘innerText’)