当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript By.id方法代码示例

本文整理汇总了TypeScript中selenium-webdriver.By.id方法的典型用法代码示例。如果您正苦于以下问题:TypeScript By.id方法的具体用法?TypeScript By.id怎么用?TypeScript By.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在selenium-webdriver.By的用法示例。


在下文中一共展示了By.id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: TestUntilModule

function TestUntilModule() {
    let driver: webdriver.WebDriver = new webdriver.Builder().
        withCapabilities(webdriver.Capabilities.chrome()).
        build();

    let conditionB: webdriver.Condition<boolean> = new webdriver.Condition<boolean>('message', (driver: webdriver.WebDriver) => true);
    let conditionBBase: webdriver.Condition<boolean> = conditionB;
    let conditionWebElement: webdriver.WebElementCondition;
    let conditionWebElements: webdriver.Condition<webdriver.WebElement[]>;

    conditionB = webdriver.until.ableToSwitchToFrame(5);
    let conditionAlert: webdriver.Condition<webdriver.Alert> = webdriver.until.alertIsPresent();
    let el: webdriver.WebElement = driver.findElement(webdriver.By.id('id'));
    conditionB = webdriver.until.stalenessOf(el);
    conditionB = webdriver.until.titleContains('text');
    conditionB = webdriver.until.titleIs('text');
    conditionB = webdriver.until.titleMatches(/text/);
    conditionB = webdriver.until.urlContains('text');
    conditionB = webdriver.until.urlIs('text');
    conditionB = webdriver.until.urlMatches(/text/);

    conditionWebElement = webdriver.until.elementIsDisabled(el);
    conditionWebElement = webdriver.until.elementIsEnabled(el);
    conditionWebElement = webdriver.until.elementIsNotSelected(el);
    conditionWebElement = webdriver.until.elementIsNotVisible(el);
    conditionWebElement = webdriver.until.elementIsSelected(el);
    conditionWebElement = webdriver.until.elementIsVisible(el);
    conditionWebElement = webdriver.until.elementLocated(webdriver.By.id('id'));
    conditionWebElement = webdriver.until.elementTextContains(el, 'text');
    conditionWebElement = webdriver.until.elementTextIs(el, 'text');
    conditionWebElement = webdriver.until.elementTextMatches(el, /text/);
    conditionWebElements = webdriver.until.elementsLocated(webdriver.By.className('class'));
}
开发者ID:Rick-Kirkham,项目名称:DefinitelyTyped,代码行数:33,代码来源:index.ts

示例2: TestBy

function TestBy() {
    let driver: webdriver.WebDriver = new webdriver.Builder().
        withCapabilities(webdriver.Capabilities.chrome()).
        build();

    let locator: webdriver.By = new webdriver.By('class name', 'class');

    let str: string = locator.toString();

    locator = webdriver.By.className('class');
    locator = webdriver.By.css('css');
    locator = webdriver.By.id('id');
    locator = webdriver.By.linkText('link');
    locator = webdriver.By.name('name');
    locator = webdriver.By.partialLinkText('text');
    locator = webdriver.By.tagName('tag');
    locator = webdriver.By.xpath('xpath');

    // Can import 'By' without import declarations
    let By = webdriver.By;

    let locatorHash: webdriver.ByHash;
    locatorHash = { className: 'class' };
    locatorHash = { css: 'css' };
    locatorHash = { id: 'id' };
    locatorHash = { linkText: 'link' };
    locatorHash = { name: 'name' };
    locatorHash = { partialLinkText: 'text' };
    locatorHash = { tagName: 'tag' };
    locatorHash = { xpath: 'xpath' };

    webdriver.By.js('script', 1, 2, 3)(driver).then((abc: number) => {});
}
开发者ID:Rick-Kirkham,项目名称:DefinitelyTyped,代码行数:33,代码来源:index.ts

示例3: checkContent

  @AsyncTest("everyone gets a nice welcome")
  public async checkContent() {
    // get the wiki body
    const title = await this._driver.findElement(By.id("wiki-body")).getText();

    // check it contains what we'd expect
    Expect(title).toContain("Welcome to the alsatian wiki!");
  }
开发者ID:alsatian-test,项目名称:alsatian,代码行数:8,代码来源:alsatian-wiki.spec.ts

示例4: function

 async function(driver) { 
     try {
         let elem = await shadowRoot(driver);
         elem = await elem.findElement(By.id(id));
         return true;
     } catch(err) {
         console.log("ignoring error in testElementLocatedById for id = "+id,err.toString().split("\n")[0]);
     }
 }, timeout); 
开发者ID:localvoid,项目名称:js-framework-benchmark,代码行数:9,代码来源:webdriverAccess.ts

示例5: it

	it('should be possible to click the "allow and install" button', async function() {
		this.timeout(20000);
		this.slow(15000);
		await wait(3000);
		await findElement(webdriver.By.tagName('install-page'))
			.findElement(webdriver.By.tagName('install-confirm'))
			.findElement(webdriver.By.id('acceptAndInstallbutton'))
			.click();
		await wait(5000);
	});
开发者ID:SanderRonde,项目名称:CustomRightClickMenu,代码行数:10,代码来源:installation-test.ts

示例6: findExtensionElement

async function findExtensionElement(driver: TypedWebdriver, capabilities: BrowserstackCapabilities) {
	const version = getVersion(capabilities);

	if (version < 36) {
		console.error('Chrome extension testing before chrome 36 won\'t work,'
			+ ' please try a higher chrome version or remove the --test-extension flag');
		process.exit(1);
		throw new Error('Chrome extension testing before chrome 36 won\'t work,'
			+ ' please try a higher chrome version or remove the --test-extension flag');
	} else if (version < 61) {
		await driver.get('chrome://extensions-frame/frame');
	} else {
		await driver.get('chrome://extensions');
	}
	if (version < 66) {
		const extensions = await driver.findElements(
			webdriver.By.className('extension-list-item-wrapper'));
		for (const extension of extensions) {
			const title = await extension.findElement(
				webdriver.By.className('extension-title'));
			if ((await title.getText()).indexOf('Custom Right-Click Menu') > -1) {
				return extension;
			}
		}
		return null;
	} else {
		const extensions = await findElement(webdriver.By.tagName('extensions-manager'))
			.findElement(webdriver.By.tagName('extensions-item-list'))
			.findElements(webdriver.By.tagName('extensions-item'));
		for (const extension of extensions) {
			const title = await extension.findElement(webdriver.By.id('name'));
			if ((await title.getText()).indexOf('Custom Right-Click Menu') > -1) {
				await extension.findElement(webdriver.By.id('detailsButton')).click();
				await wait(1000);
				return driver;
			}
		}
		return null;
	}
}
开发者ID:SanderRonde,项目名称:CustomRightClickMenu,代码行数:40,代码来源:chrome-extension.ts

示例7: openOptionsPage

export async function openOptionsPage(driver: TypedWebdriver, capabilities: BrowserstackCapabilities) {
	const version = getVersion(capabilities);
	
	await wait(500);

	const extensionElement = await findExtensionElement(driver, capabilities);
	if (!extensionElement) {
		console.error('Failed to find extension options page');
		process.exit(1);
		return;
	}

	if (version < 66) {
		await extensionElement
			.findElement(webdriver.By.className('options-link'))
			.click();
		const currentTab = await driver.getWindowHandle();
		const tabs = await driver.getAllWindowHandles();
		const nonCurrentTabs = tabs.filter((tab) => {
			return tab !== currentTab;
		});
		
		//Close the curent tab
		await driver.close();

		//Switch to next tab
		await driver.switchTo().window(nonCurrentTabs[0]);
		return;
	} else {
		await findElement(webdriver.By.tagName('extensions-manager'))
			.findElement(webdriver.By.tagName('extensions-detail-view'))
			.findElement(webdriver.By.id('extensions-options'))
			.click();

		const currentTab = await driver.getWindowHandle();
		const tabs = await driver.getAllWindowHandles();
		const nonCurrentTabs = tabs.filter((tab) => {
			return tab !== currentTab;
		});
		
		//Close the curent tab
		await driver.close();

		//Switch to next tab
		await driver.switchTo().window(nonCurrentTabs[0]);
		return;
	}
}
开发者ID:SanderRonde,项目名称:CustomRightClickMenu,代码行数:48,代码来源:chrome-extension.ts

示例8: TestWebElement

function TestWebElement() {
    var driver: webdriver.WebDriver = new webdriver.Builder().
        withCapabilities(webdriver.Capabilities.chrome()).
        build();

    var promise: webdriver.promise.Promise<string>;
    var element: webdriver.WebElement;

    element = new webdriver.WebElement(driver, 'elementId');
    element = new webdriver.WebElement(driver, promise);

    var voidPromise: webdriver.promise.Promise<void>;
    var stringPromise: webdriver.promise.Promise<string>;
    var booleanPromise: webdriver.promise.Promise<boolean>;

    voidPromise = element.clear();
    voidPromise = element.click();

    element = element.findElement(webdriver.By.id('ABC'));
    element.findElements(webdriver.By.className('ABC')).then(function (elements: webdriver.WebElement[]) { });
    booleanPromise = element.isElementPresent(webdriver.By.className('ABC'));

    stringPromise = element.getAttribute('class');
    stringPromise = element.getCssValue('display');
    driver = element.getDriver();
    stringPromise = element.getInnerHtml();
    element.getLocation().then(function (location: webdriver.ILocation) { });
    stringPromise = element.getOuterHtml();
    element.getSize().then(function (size: webdriver.ISize) { });
    stringPromise = element.getTagName();
    stringPromise = element.getText();
    booleanPromise = element.isDisplayed();
    booleanPromise = element.isEnabled();
    booleanPromise = element.isSelected();
    voidPromise = element.sendKeys('A', 'B', 'C');
    voidPromise = element.sendKeys(1, 2, 3);
    voidPromise = element.sendKeys(webdriver.Key.BACK_SPACE);
    voidPromise = element.sendKeys(stringPromise, stringPromise, stringPromise);
    voidPromise = element.sendKeys('A', 1, webdriver.Key.BACK_SPACE, stringPromise);
    voidPromise = element.submit();
    element.getId().then(function (id: string) { });
    element.getRawId().then(function (id: string) { });
    element.serialize().then(function (id: webdriver.IWebElementId) { });

    booleanPromise = webdriver.WebElement.equals(element, new webdriver.WebElement(driver, 'elementId'));
}
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:46,代码来源:index.ts


注:本文中的selenium-webdriver.By.id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。