how to write XPath of a nested element

Solution 1:

Converting your description to XPath is strait-forward.
It will be:

//oj-input-text[@class = 'input' and @label-hint = 'pfg']//input[@class = 'text-input-entry']

or in case if oj-input-text is not a regular element tag name as it looks here

//*[name()=oj-input-text and @class = 'input' and @label-hint = 'pfg']//input[@class = 'text-input-entry']

//oj-input-text[@class = 'input' and @label-hint = 'pfg']//input[@class = 'text-input-entry'] means as following:
// somewhere on the document
oj-input-text node with oj-input-text tag name
@class = 'input' element class attribute value is input
and - another condition there @label-hint = 'pfg' - label-hint attribute has value of pgf
second // - somewhere below this element, inside it
input - tag name input
class = 'text-input-entry' - class attribute with value of text-input-entry

Solution 2:

Use Chrome DevTools -> Inspect -> Copy -> Copy XPath This will give you an example of how to build the XPath. i.e. The XPath of your question's code: //*[@id="question"]/div/div[2]/div[1]/pre[1]/code