Elffuss BraidHub

kikocis/continue public

main · 1.4 KiBRawPermalink
1import { By, WebDriver, WebElement, WebView } from "vscode-extension-tester";
2
3export class SelectorUtils {
4 /**
5 * Finds a web element by its data-testid attribute within a WebView.
6 * @param view - The WebView to search within.
7 * @param testId - The data-testid value to search for.
8 * @returns A promise that resolves to the WebElement found.
9 */
10 public static getElementByDataTestId(
11 view: WebView,
12 testId: string,
13 ): Promise<WebElement> {
14 return view.findWebElement(By.css(`[data-testid='${testId}']`));
15 }
16
17 /**
18 * Finds a web element by its aria-label attribute within a WebView.
19 * @param view - The WebView to search within.
20 * @param ariaLabel - The aria-label value to search for.
21 * @returns A promise that resolves to the WebElement found.
22 */
23 public static getElementByAriaLabel(
24 view: WebView,
25 ariaLabel: string,
26 ): Promise<WebElement> {
27 return view.findWebElement(By.css(`[aria-label='${ariaLabel}']`));
28 }
29
30 public static getElementByClassName(
31 driver: WebDriver,
32 className: string,
33 ): Promise<WebElement> {
34 return driver.findElement(
35 // By.xpath("//*[contains(@class, 'ced-') and matches(@class, 'ced-2-TextEditorDecorationType[0-9]+-4')]")
36 By.css(`*[class*='${className}']`),
37 // By.xpath(`//span[contains(@class, '${className}')]`),
38 // By.css("div[class*='TextEditorDecorationType'][style*='filter']")
39 );
40 }
41}