<div class=" arrange-unit__09f24__rqHTg arrange-unit-fill__09f24__CUubG border-color--default__09f24__NPAKY">
<p class=" css-na3oda">Business website</p>
<p class=" css-1p9ibgf" data-font-weight="semibold">
<a href="/biz_redir?url=http%3A%2F%2FSouthalabamaconstruction.com&cachebuster=1677298534&website_link_type=website&src_bizid=S8nQqc5JRUn9q-HFI0x8kA&s=76c44f0c24c6e853246a79bc1ceb3260cde63054f3a223e5dd725bd2146bc5f5" class="css-1um3nx" target="_blank" rel="noopener" role="link">http://Southalabamaconstructio…</a>
</p></div>
I'm trying to use playwright to get the a href link in here and not succeeding. Is there a way to possibly try to find the <p>
element that has Business website in it and then go two elements below to get the <a>
element?
I think this is the best way I'm just not sure how to implement it.
I need the vlaue of the href from the a
element. The text inside doesn't have the full name for the href link.
await page.locator('a[rel="noopener"]').nth(1).innerHTML()
await page.locator('div > p > a').nth(1).innerHTML()
await page
.locator('div:has-text("Business website") > a')
.nth(1)
.innerHTML()
await page.getByRole('link', { name: /^(http|https):/i })
await page.getByText(/^(http|https):/i).innerHTML()
I tried a plethora of other stuff with either errors, maximum calls, or getting the wrong link.