本文整理匯總了TypeScript中selenium-webdriver.By.name方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript By.name方法的具體用法?TypeScript By.name怎麽用?TypeScript By.name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類selenium-webdriver.By
的用法示例。
在下文中一共展示了By.name方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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) => {});
}
示例2:
flow.execute(() => {
driver.get('http://www.google.com/ncr');
driver.findElement(By.name('q')).sendKeys('webdriver');
driver.findElement(By.name('btnG')).click();
driver.wait(until.titleIs('webdriver - Google Search'), 1000);
});
示例3:
toolkit.dataFlush<ISearch>(search, (item) => {
driver.get('http://www.google.com/ncr');
driver.findElement(By.name('q')).sendKeys(item.query);
driver.findElement(By.name('btnG')).click();
driver.wait(until.titleIs(item.query + ' - Google Search'), 1000);
});