In my Gmail, the xpath for the subject and body fields constantly changes every time I compose a new email. So the xpath is not a valid solution.
var subjectElem = document.querySelectorAll('[name="subjectbox"]');
subjectElem.value = document.kmvar.Subject;
where the subject field has an input name of "subjectbox" - so good so far.
All set with the subject.
Now for the body field, which as stated, the xpath ID constantly changes.
The body does not have an input name:
but it does have an 'aria-label' which equals "Message Body"
I did find this out on the web,
but am not sure how to implement it.
Any help would be appreciated.
Chrome’s Copy As > XPath can easily give the impression that there is a single unique way of referencing an element using the XPath syntax. (‘the XPath’ as you understandably put it)
In fact, however, Chrome is just doing its best to offer an XPath (one of many different possibilities) that it hopes may be helpful – there is no one-to-one function from a given element to a unique XPath for it. As in the rest of nature, there are generally many different paths from A to B :- )
Here, for example, you might try using this XPath:
If that path ‘over-produces’ (turns out to find more than one match/destination if you use it with ⌘F in Chrome’s source viewer), then you could refine it a little until it reliably produces a unique hit.
The next step, for example, might be to test:
//*[@aria-label="Message Body" and @g_editable="true"]
awesome, although I’m not able to ‘set safari field’ I can get the cursor to the body and then I’ll be able to paste whatever variable I need.
Would there be ‘one-fell-swoop’ technique that would go to and populate that field that you know of?
Or is the best I can do it to, go to the field and then paste?
(I do understand about tab, shift-tabbing to move the cursor, but want to hard code)
I haven’t experimented with Google Mail pages, but with more sophisticated pages like that, pasting is probably the right bet.