Issues with the other, currently accepted, answer: Careful, both XPaths in the other answer have problems:
//button[contains(div,'Save')] works in this case, but be aware that it will fail when
- The
button contains a span or another or no element, rather than a div.
- Other buttons exist with
div elements whose string values contain the substring, "Save": "Save this", "Save that", "Jesus Saves", etc.
//button[contains(.//div,'Save')] also works in this case, but be aware that it will fail if there are multiple div descendants and,
- XPath 1.0: the
Save div is not the first div.
- XPath 2.0+: it is an error to pass a sequence of more than one item (
div elements, in this case) as the first argument to contains().
Consider instead this XPath,
//button[normalize-space() = 'Save']
which will select button elements whose space-normalized string value is exactly "Save".
Or, if for substring testing:
//button[contains(., 'Save')]
See also