Skip to content

Instantly share code, notes, and snippets.

@JarvisPrestidge
Created August 21, 2017 09:03
Show Gist options
  • Save JarvisPrestidge/3929417fe63f878bac6392b05915fa0f to your computer and use it in GitHub Desktop.
Save JarvisPrestidge/3929417fe63f878bac6392b05915fa0f to your computer and use it in GitHub Desktop.
Account link from 'displayName'
// Returns the href of the account with the given account title
const accountLink = await browser.evaluate((displayName: string) => {
const accountTitleSelector = "a[id*='lnkAccName_des-m-sat-xx-']";
const titles = [...document.querySelectorAll(accountTitleSelector)] as HTMLAnchorElement[];
const title = titles.filter((ele) => ele.textContent.toLowerCase().includes(displayName.toLowerCase()))[0];
return title ? title.getAttribute("href") : null;
}, account.displayName) as string;
// Get account href from camel-cased display name
if (!accountLink) {
throw new Error("Cannot find matching account title");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment