本文整理汇总了TypeScript中selenium-webdriver.By.xpath方法的典型用法代码示例。如果您正苦于以下问题:TypeScript By.xpath方法的具体用法?TypeScript By.xpath怎么用?TypeScript By.xpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium-webdriver.By
的用法示例。
在下文中一共展示了By.xpath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _getRatesForIndicative
private _getRatesForIndicative(skipOptionClick) {
var promises = [];
if (!skipOptionClick) {
promises.push(this._waitAndClick(By.xpath(`//*[@id='nonINRradio']/*[@id='moneyType']`)));
}
promises.push(driver.wait(until.elementLocated(By.xpath(`//*[@id="txnAmountDiv1"]/input`)), 5 * 1000)
.then(el => el.sendKeys('1000')));
promises.push(this._waitAndClick(By.xpath(`//a[@onclick='calculate();']`)));
return promise.all(promises)
.then(_ => this._extractRates(true))
.then(resultPromise => promise.all(resultPromise));
}
示例2: _setSearchParameters
private _setSearchParameters(currency, transferMode, deliveryMode) {
driver.get(URL);
var locators = [
By.xpath(`//*[@id='currencyId']/option[text()='${currency}'] `),
By.xpath(`//*[@id='product']/option[text()='${transferMode}'] `),
By.xpath(`//*[@id='deliveryMode']/option[text()='${deliveryMode}']`)];
var promises = locators.map(locator => this._waitAndClick(locator));
return promise.all(promises)
.then(_ => console.log(`Search parameters currency: ${currency}, transferMode:${transferMode}, deliveryMode: ${deliveryMode} set successfully`))
.thenCatch(err => console.log(`Error while setting search parameters currency:
${currency}, transferMode:${transferMode}, deliveryMode: ${deliveryMode}. Error: ${err.message}`));
}
示例3: 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) => {});
}
示例4: _extractRates
private _extractRates(isIndicative) {
var path = `//*[@id="fixslabs"]/table/tbody/tr/td`
if (isIndicative) {
path = `//*[@id="slabsMe"]/table/tbody/tr/td`;
}
return driver.wait(until.elementsLocated(By.xpath(path)), 5 * 1000)
.then(els => els.map(el1 => el1.getText()));
}
示例5: _getIndicativeRate
private _getIndicativeRate(pageMap) {
driver.get(URL);
driver.wait(until.elementLocated(By.css("#paymentAmount")), 5 * 1000)
.then(el => el.sendKeys("1"));
// driver.wait(until.elementLocated(By.xpath(`//*[@id="paymentCurrencies"]/option[text()="${pageMap.currencyValue}"]`)), 15 * 1000)
//.then(el => el.click());
driver.findElement(By.xpath(`//*[@id='deliveryCountries']/option[text()='India']`))
.then(el => el.click())
// driver.findElement(By.css("#deliveryAmount"))
// .then(el => el.getText().then(text => console.log(text)));
}
示例6: it
it('visits System Configuration', async () => {
await navigation.visitSystemConfiguration()
await navigation.blur()
ctx.driver.findElement(By.xpath("//div[@class='alert alert-danger']"))
})