I'm trying to get the phone number based on a string value of a cousin.
My goal is to search for "Owner" and end up with the value of the phone number.
<div>
<h3>
<a href="#">Owner</a>
</h3>
<p>
(555) 555-5555
</p>
</div>
Here's what I have so far, but I keep getting undefined
. Can you explain what I'm doing wrong?
console.log(await this.page.$("//h3[contains(a, 'Owner')]/../p").innerText);
There are some issues:
page.$()
needs a CSS selector, not an XPath.page.$x()
will return an array with ElementHandle-s.a
element with'#'
href, only with full URL, but this may be a test case issue.This is what works for me: