How to use the selenium-webdriver.By.className function in selenium-webdriver

To help you get started, we’ve selected a few selenium-webdriver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redhat-developer / vscode-extension-tester / src / webdriver / components / sidebar / ViewSection.ts View on Github external
async findItem(label: string, maxLevel: number = 0): Promise {
        await this.expand();
        const container = await this.findElement(By.className('monaco-list'));
        await container.sendKeys(Key.HOME);
        let item: ViewItem | undefined = undefined;
        do {
            try {
                const temp = await container.findElement(By.xpath(`.//div[contains(@class, 'monaco-list-row') and @aria-label='${label}']`));
                const level = +await temp.getAttribute('aria-level');
                if (maxLevel > 0 && level <= maxLevel) {
                    item = new ViewItem(label, this);
                }
            } catch (err) {
                try {
                    await container.findElement(By.xpath(`.//div[@data-last-element='true']`));
                    break;
                } catch (err) {
                    // last element not yet found, continue
                }
github intel / ui-widget-toolkit / spec / ui-test / sanity.spec.js View on Github external
graph.findElements(By.tagName('svg')).then(function (graphs) {
                expect(graphs.length).toBe(2);
                graphs[0].findElements(By.className('chart-area')).then(function (charts) {
                    expect(charts.length).toBe(6);
                });
                driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {
                    graphs[0].findElements(By.className('cell')).then(function (cells) {
                        expect(cells.length).toBe(12);
                        cells[0].findElement(By.tagName('text')).then(function (text) {
                            text.getText().then(function (value) {
                                expect(value).toBe('data-0')
                            });
                        });
                        cells[1].findElement(By.tagName('text')).then(function (text) {
                            text.getText().then(function (value) {
                                expect(value).toBe('data-1')
                            });
                        });
                        cells[2].findElement(By.tagName('text')).then(function (text) {
github intel / ui-widget-toolkit / spec / ui-test / sanity.spec.js View on Github external
driver.wait(until.elementLocated(By.className('cell')), 1000).then(function () {
                    graphs[0].findElements(By.className('cell')).then(function (cells) {
                        expect(cells.length).toBe(6);
                        cells[0].findElement(By.tagName('text')).then(function (text) {
                            text.getText().then(function (value) {
                                expect(value).toBe('data-0')
                            });
                        });
                        cells[1].findElement(By.tagName('text')).then(function (text) {
                            text.getText().then(function (value) {
                                expect(value).toBe('data-1')
                            });
                        });
                        cells[2].findElement(By.tagName('text')).then(function (text) {
                            text.getText().then(function (value) {
                                expect(value).toBe('data-2')
                            });
                        });
github redhat-developer / vscode-extension-tester / src / webdriver / locators / versions / 1.37.0.ts View on Github external
const statusBar = {
    StatusBar: {
        constructor: By.id('workbench.parts.statusbar'),
        language: By.id('status.editor.mode'),
        lines: By.id('status.editor.eol'),
        encoding: By.id('status.editor.encoding'),
        indent: By.id('status.editor.indentation'),
        selection: By.id('status.editor.selection'),
        notifications: By.className('notifications-center'),
        bell: By.id('status.notifications')
    }
}

const workbench = {
    Workbench: {
        constructor: By.className('monaco-workbench'),
        notificationContainer: By.className('notification-toast-container'),
        notificationItem: By.className('monaco-list-row')
    },
    Notification: {
        message: By.className('notification-list-item-message'),
        icon: By.className('notification-list-item-icon'),
        source: By.className('notification-list-item-source'),
        progress: By.className('monaco-progress-container'),
        dismiss: By.className('clear-notification-action'),
        actions: By.className('notification-list-item-buttons-container'),
        action: By.className('monaco-button'),
        actionLabel: 'title',
        standalone: (id: string) => By.xpath(`.//div[contains(@class, 'monaco-list-row') and @id='${id}']`),
        standaloneContainer: By.className('notifications-toasts'),
        center: (index: number) => By.xpath(`.//div[contains(@class, 'monaco-list-row') and @data-index='${index}']`),
        buttonConstructor: (title: string) => By.xpath(`.//a[@role='button' and @title='${title}']`)
github redhat-developer / vscode-extension-tester / src / webdriver / locators / versions / 1.37.0.ts View on Github external
selection: By.id('status.editor.selection'),
        notifications: By.className('notifications-center'),
        bell: By.id('status.notifications')
    }
}

const workbench = {
    Workbench: {
        constructor: By.className('monaco-workbench'),
        notificationContainer: By.className('notification-toast-container'),
        notificationItem: By.className('monaco-list-row')
    },
    Notification: {
        message: By.className('notification-list-item-message'),
        icon: By.className('notification-list-item-icon'),
        source: By.className('notification-list-item-source'),
        progress: By.className('monaco-progress-container'),
        dismiss: By.className('clear-notification-action'),
        actions: By.className('notification-list-item-buttons-container'),
        action: By.className('monaco-button'),
        actionLabel: 'title',
        standalone: (id: string) => By.xpath(`.//div[contains(@class, 'monaco-list-row') and @id='${id}']`),
        standaloneContainer: By.className('notifications-toasts'),
        center: (index: number) => By.xpath(`.//div[contains(@class, 'monaco-list-row') and @data-index='${index}']`),
        buttonConstructor: (title: string) => By.xpath(`.//a[@role='button' and @title='${title}']`)
    },
    NotificationsCenter: {
        constructor: By.className('notifications-center'),
        close: By.className('hide-all-notifications-action'),
        clear: By.className('clear-all-notifications-action'),
        row: By.className('monaco-list-row')
    }
github intel / ui-widget-toolkit / spec / ui-test / sanity.spec.js View on Github external
blobs[0].findElements(By.className('radar-area')).then(function (areas) {
                    expect(areas.length).toBe(2);
                });
                blobs[0].findElements(By.className('radar-circle')).then(function (circles) {
                    expect(circles.length).toBe(5);
                });
                blobs[1].findElements(By.className('radar-area')).then(function (areas) {
                    expect(areas.length).toBe(2);
                });
                blobs[1].findElements(By.className('radar-circle')).then(function (circles) {
                    expect(circles.length).toBe(5);
                });
            });

            svgs[1].findElements(By.className('axis-circle')).then(function (axisCircles) {
                expect(axisCircles.length).toBe(5);
            });
            svgs[1].findElements(By.className('axis-line')).then(function (axisLines) {
                expect(axisLines.length).toBe(6);
            });
            svgs[1].findElements(By.className('radar-blob')).then(function (blobs) {
                expect(blobs.length).toBe(2);

                blobs[0].findElements(By.className('radar-area')).then(function (areas) {
                    expect(areas.length).toBe(2);
                });
                blobs[0].findElements(By.className('radar-circle')).then(function (circles) {
                    expect(circles.length).toBe(6);
                });
                blobs[1].findElements(By.className('radar-area')).then(function (areas) {
                    expect(areas.length).toBe(2);
github redhat-developer / vscode-extension-tester / src / webdriver / locators / versions / 1.37.0.ts View on Github external
outputTab: 'Output',
        debugTab: 'Debug Console',
        terminalTab: 'Terminal',
        maximize: 'Maximize Panel Size',
        restore: 'Restore Panel Size',
        tabContainer: By.className('panel-switcher-container'),
        tab: (title: string) => By.xpath(`.//li[starts-with(@title, '${title}')]`),
        actions: By.className('title-actions'),
        action: (label: string) => By.xpath(`.//a[starts-with(@title, '${label}')]`)
    },
    BottomBarViews: {
        actionsContainer: (label: string) => By.xpath(`.//ul[@aria-label='${label}']`),
        channelOption: By.tagName('option'),
        channelCombo: By.tagName('select'),
        channelText: By.className('option-text'),
        channelRow: By.className('monaco-list-row'),
        textArea: By.tagName('textarea'),
        clearText: By.className('clear-output')
    },
    ProblemsView: {
        constructor: By.id('workbench.panel.markers'),
        markersFilter: By.className('markers-panel-action-filter'),
        input: By.tagName('input'),
        collapseAll: By.className('collapse-all'),
        markerRow: By.className('monaco-list-row'),
        rowLabel: 'aria-label',
        markerTwistie: By.className('monaco-tl-twistie')
    },
    TerminalView: {
        constructor: By.id('workbench.panel.terminal'),
        actionsLabel: 'Terminal actions',
        textArea: By.className('xterm-helper-textarea'),
github redhat-developer / vscode-extension-tester / src / webdriver / locators / versions / 1.37.0.ts View on Github external
constructor: By.id('workbench.parts.statusbar'),
        language: By.id('status.editor.mode'),
        lines: By.id('status.editor.eol'),
        encoding: By.id('status.editor.encoding'),
        indent: By.id('status.editor.indentation'),
        selection: By.id('status.editor.selection'),
        notifications: By.className('notifications-center'),
        bell: By.id('status.notifications')
    }
}

const workbench = {
    Workbench: {
        constructor: By.className('monaco-workbench'),
        notificationContainer: By.className('notification-toast-container'),
        notificationItem: By.className('monaco-list-row')
    },
    Notification: {
        message: By.className('notification-list-item-message'),
        icon: By.className('notification-list-item-icon'),
        source: By.className('notification-list-item-source'),
        progress: By.className('monaco-progress-container'),
        dismiss: By.className('clear-notification-action'),
        actions: By.className('notification-list-item-buttons-container'),
        action: By.className('monaco-button'),
        actionLabel: 'title',
        standalone: (id: string) => By.xpath(`.//div[contains(@class, 'monaco-list-row') and @id='${id}']`),
        standaloneContainer: By.className('notifications-toasts'),
        center: (index: number) => By.xpath(`.//div[contains(@class, 'monaco-list-row') and @data-index='${index}']`),
        buttonConstructor: (title: string) => By.xpath(`.//a[@role='button' and @title='${title}']`)
    },
    NotificationsCenter: {
github redhat-developer / vscode-extension-tester / src / webdriver / locators / versions / 1.37.0.ts View on Github external
standaloneContainer: By.className('notifications-toasts'),
        center: (index: number) => By.xpath(`.//div[contains(@class, 'monaco-list-row') and @data-index='${index}']`),
        buttonConstructor: (title: string) => By.xpath(`.//a[@role='button' and @title='${title}']`)
    },
    NotificationsCenter: {
        constructor: By.className('notifications-center'),
        close: By.className('hide-all-notifications-action'),
        clear: By.className('clear-all-notifications-action'),
        row: By.className('monaco-list-row')
    }
}

const input = {
    Input: {
        inputBox: By.className('monaco-inputbox'),
        input: By.className('input'),
        quickPickIndex: (index: number) => By.xpath(`.//div[@role='treeitem' and @data-index='${index}']`),
        quickPickPosition: (index: number) => By.xpath(`.//div[@role='treeitem' and @aria-posinset='${index}']`),
        quickPickText: By.className('monaco-highlighted-label')
    },
    InputBox: {
        constructor: By.className('quick-input-widget'),
        message: By.className('quick-input-message'),
        progress: By.className('quick-input-progress'),
        quickList: By.className('quick-input-list'),
        rows: By.className('monaco-list-rows'),
        row: By.className('monaco-list-row')
    },
    QuickOpenBox: {
        constructor: By.className('monaco-quick-open-widget'),
        progress: By.className('monaco-progress-container'),
        quickList: By.className('quick-open-tree'),
github fossasia / open-event-wsgen / src / selenium / sessionPage.js View on Github external
const sessionPromise = new Promise(function(resolve) {
    const title = self.find(By.className(speaker)).getText();

    resolve(title);
  });