The selection does not contain text frames, it contains "text". If you query the parent, you get a Story, and although that
i does
have a frame property ("textFrames"), it contains all text frames that story runs through, not just of your selection.
However, the text object you selected
i also
has a "textFrames" property -- all the text frames
i in
your selection. That would be any inline text frames...
Now,
b I can't check right now
but I think
>app.selection[0].parentTextFrames[0]
points the first text frame -- the one at the start of your selection, as it may span multiple frames --, and from that you can get to
>app.selection[0].parentTextFrames[0].parent
which is "a Spread, MasterSpread, PageItem, Oval, Rectangle, Polygon, GraphicLine, Group, State, Document, Layer, Page, Button, TextFrame, Story, Text, Character, Word, Line, TextColumn, Paragraph, TextStyleRange, Cell, Table, InsertionPoint or Footnote" (as the Help helpfully states). Now, if it is a simple document without any nested frames, the parent typically will be a Page. From that on, you can get the actual page number:
>app.selection[0].parentTextFrames[0].parent.name
Use "name" because this will return the page number as a string, because it can be any one of "1", "a", "i", or even "Section1:1".