本文整理汇总了TypeScript中selenium-webdriver.By.css方法的典型用法代码示例。如果您正苦于以下问题:TypeScript By.css方法的具体用法?TypeScript By.css怎么用?TypeScript By.css使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium-webdriver.By
的用法示例。
在下文中一共展示了By.css方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
return () => {
// self._driver.get(page.URL);
self._driver.findElement(By.css(page.LOGIN)).sendKeys('wronglogin@test.test');
self._driver.findElement(By.css(page.PASS)).sendKeys('159236');
self._driver.findElement(By.css(page.SUBMIT)).click();
self._driver.wait(until.elementLocated(By.css(page.ERROR)));
self._driver.quit();
};
示例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) => {});
}
示例3: loginPositive
public loginPositive(email, pass, callback) {
let pageLogin = new LoginPage(this._driver);
let page = new Page();
let pageSideMenu = new SideMenu();
console.log('start test');
pageLogin.openPage();
// this._driver.findElement(By.css(page.LOGIN)).sendKeys(email);
pageLogin.getLogin().sendKeys(email);
pageLogin.getPass().sendKeys(pass);
pageLogin.getSubmit().click();
pageLogin.waitToLocateIWE();
page.waitToLocateIWE( pageSideMenu._settingsBtn);
page.getElementByCss(pageSideMenu._settingsBtn).click();
pageLogin.getElementCss(
By.css('body > div:nth-child(4) > div > div > div > ' +
'div:nth-child(3) > div:nth-child(5) > button')).click();
// page.waitToLocateIWE()
// let loginLocator = page.waitToLocateIWE(pageLogin._login);
loginLocator.then(() => {
callback();
});
// this._driver.quit()
}
示例4: checkNavTitle
@AsyncTest("check nav title spelled correctly")
public async checkNavTitle() {
const driver = new Builder().
withCapabilities(Capabilities.chrome()).
build();
await driver.get("localhost:3000");
const headingTitle = driver.findElement(By.css("nav h1"));
const headingText = await headingTitle.getText();
Expect(headingText).toBe("Alsatian");
}
示例5: findByXPath
// Fake findByXPath for simple XPath expressions to allow usage with shadow dom
async function findByXPath(node: WebElement, path: string): Promise<WebElement> {
let paths = convertPath(path);
let n = node;
try {
for (let p of paths) {
// n = n.then(nd => nd.findElements(By.tagName(p.tagName))).then(elems => { // costly since it fetches all elements
let elems = await n.findElements(By.css(p.tagName+":nth-child("+(p.index)+")"));
if (elems==null || elems.length==0) { return null};
n = elems[0];
}
} catch (e) {
//can happen for StaleElementReferenceError
return null;
}
return n;
}
示例6: _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)));
}
示例7: waitToLocateIWE
public waitToLocateIWE(locator: string): any {
return this._driver.wait(until.elementLocated(By.css(locator)), 2000);
}
示例8: getElementCss
public getElementCss(locator: string): IWebElement {
this.getDriver().findElement(By.css(locator));
}
示例9: getElementByCss
export function getElementByCss(driver: WebDriver, locator: string): IWebElement {
return driver.findElement(By.css(locator));
}
示例10:
n = n.then(nd => nd.findElements(By.css(p.tagName+":nth-child("+(p.index)+")"))).then(elems => {