I'm trying to read an element from a dynamic website, but am facing a weird (at least to my poor understanding) issue.
Below is a snapshot from the Developer Tool from Chrome

I'm trying to read the innertText of the highlighted line (please note this is a dynamic website, so the "li id's"change).
When I'm firing document.querySelector("#\\31 60698c8-9d6c-492b-acf8-13b82467f873 > div > span.room-display-message-message") in the DevTools Console while highlighting the line as in the above snapshot the innerText is returned, but when I'm moving my selection higher up in the tree, e.g. to "iframe class = "trollbox-iframe" and then running the same script it returns "null".
This behavior also pops up when making the script more random like document.querySelector("* > div > span.room-display-message-message")
Am I getting crazy or is this normal and should I take another approach?
I'm asking this because I'm developing a tool in C# using a CEFSharp Chromium webbrowser to read contents of this website, but that's not relevant at the nmoment
OK, itr took me a few days, but I finally got what I wanted. For those interested here's my solution:
First thing is to add a CefSharp.WinForms.CefSettings to your browser element, being "--disable-web-security"
For calling this trollbox iframe I'm using below Javascript (I know it can be simplified, but hey...it works
var script2 = "function foo(){" + "var re = /[^-a - zA - Z!, '?\s]/g;" + "var messages = [];" + "doc = document.getElementsByClassName('trollbox-container open')[0];" + "ifrm = doc.getElementsByTagName('iframe')[0];" + "docInside = ifrm.contentDocument ? ifrm.contentDocument : ifrm.contentWindow.document;" + "docTag = docInside.getElementsByClassName('content small')[0];" + "msgList = docTag.getElementsByClassName('message-list')[0];" + "msgList_sender = msgList.getElementsByClassName('room-display-message-sender');" + "msgList_message = msgList.getElementsByClassName('room-display-message-message');" + "for (var i = 0; i < msgList_sender.length; i++)" + " {" + " var sender = msgList_sender[i].innerText;" + " var message = msgList_message[i].innerText;" + " messages.push(sender + ': ' + message);" + " }" + "return messages;" + "}" + "foo();";
Finally running this code
JavascriptResponse response = await browser1.EvaluateScriptAsync(script2);
returns me the information from the trollbox I wanted