本文整理汇总了TypeScript中selenium-webdriver.Capabilities类的典型用法代码示例。如果您正苦于以下问题:TypeScript Capabilities类的具体用法?TypeScript Capabilities怎么用?TypeScript Capabilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Capabilities类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: TestWebDriverWindow
function TestWebDriverWindow() {
let driver: webdriver.WebDriver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
let window: webdriver.Window = new webdriver.Window(driver);
let locationPromise: webdriver.promise.Promise<webdriver.ILocation>;
let sizePromise: webdriver.promise.Promise<webdriver.ISize>;
let voidPromise: webdriver.promise.Promise<void>;
locationPromise = window.getPosition();
sizePromise = window.getSize();
voidPromise = window.maximize();
voidPromise = window.setPosition(12, 34);
voidPromise = window.setSize(12, 34);
}
示例2: 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'));
}
示例3: TestWebElement
function TestWebElement() {
let driver: webdriver.WebDriver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
let element: webdriver.WebElement;
element = new webdriver.WebElement(driver, 'elementId');
let voidPromise: Promise<void>;
let stringPromise: Promise<string>;
let booleanPromise: Promise<boolean>;
voidPromise = element.clear();
voidPromise = element.click();
element = element.findElement(webdriver.By.id('ABC'));
element = element.findElement({id: 'ABC'});
element.findElements({className: 'ABC'}).then((elements: webdriver.WebElement[]) => { });
stringPromise = element.getAttribute('class');
stringPromise = element.getCssValue('display');
driver = element.getDriver();
element.getLocation().then((location: webdriver.ILocation) => {});
element.getSize().then((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((id: string) => {});
element.serialize().then((id: webdriver.IWebElementId) => {});
booleanPromise = webdriver.WebElement.equals(element, new webdriver.WebElement(driver, 'elementId'));
}
示例4: TestTouchSequence
function TestTouchSequence() {
let driver: webdriver.WebDriver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
let element: webdriver.WebElement = new webdriver.WebElement(driver, 'elementId');
let sequence: webdriver.TouchSequence = new webdriver.TouchSequence(driver);
sequence = sequence.tap(element);
sequence = sequence.doubleTap(element);
sequence = sequence.longPress(element);
sequence = sequence.tapAndHold({ x: 100, y: 100 });
sequence = sequence.move({ x: 100, y: 100 });
sequence = sequence.release({ x: 100, y: 100 });
sequence = sequence.scroll({ x: 100, y: 100 });
sequence = sequence.scrollFromElement(element, { x: 100, y: 100 });
sequence = sequence.flick({ xspeed: 100, yspeed: 100 });
sequence = sequence.flickElement(element, { x: 100, y: 100 }, 100);
sequence.perform().then(() => {});
}
示例5: TestWebElementPromise
function TestWebElementPromise() {
var driver: webdriver.WebDriver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
var elementPromise: webdriver.WebElementPromise = driver.findElement(webdriver.By.id('id'));
elementPromise.cancel();
elementPromise.cancel('reason');
var bool: boolean = elementPromise.isPending();
elementPromise.then();
elementPromise.then(function (element: webdriver.WebElement) { });
elementPromise.then(function (element: webdriver.WebElement) { }, function (error: any) { });
elementPromise.then(function (element: webdriver.WebElement) { return 'foo'; }, function (error: any) { }).then(function (result: string) { });
elementPromise.thenCatch(function (error: any) { }).then(function (value: any) { });
elementPromise.thenFinally(function () { });
}
示例6: TestWebElementPromise
function TestWebElementPromise() {
const driver: webdriver.WebDriver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
const elementPromise: webdriver.WebElementPromise = driver.findElement(webdriver.By.id('id'));
elementPromise.cancel();
elementPromise.cancel('reason');
const bool: boolean = elementPromise.isPending();
elementPromise.then();
elementPromise.then((element: webdriver.WebElement) => {});
elementPromise.then((element: webdriver.WebElement) => {}, (error: any) => {});
elementPromise.then((element: webdriver.WebElement) => 'foo', (error: any) => {}).then((result: string) => {});
elementPromise.thenCatch((error: any) => {}).then((value: any) => {});
elementPromise.thenFinally(() => {});
}
示例7: TestChromeOptions
function TestChromeOptions() {
let options: chrome.Options = new chrome.Options();
options = chrome.Options.fromCapabilities(webdriver.Capabilities.chrome());
options = options.addArguments('a', 'b', 'c');
options = options.addExtensions('a', 'b', 'c');
options = options.excludeSwitches('a', 'b', 'c');
options = options.detachDriver(true);
options = options.setChromeBinaryPath('path');
options = options.setChromeLogFile('logfile');
options = options.setLocalState('state');
options = options.androidActivity('com.example.Activity');
options = options.headless();
options = options.androidDeviceSerial('emulator-5554');
options = options.androidChrome();
options = options.androidPackage('com.android.chrome');
options = options.androidProcess('com.android.chrome');
options = options.androidUseRunningApp(true);
options = options.setPerfLoggingPrefs({
enableNetwork: true, enablePage: true, enableTimeline: true,
tracingCategories: 'category', bufferUsageReportingInterval: 1000 });
options = options.setUserPreferences('preferences');
}
示例8: TestWebDriver
function TestWebDriver() {
let session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android());
let httpClient: http.HttpClient = new http.HttpClient('http://someserver');
let executor: http.Executor = new http.Executor(httpClient);
let flow: webdriver.promise.ControlFlow = new webdriver.promise.ControlFlow();
let driver: webdriver.WebDriver = new webdriver.WebDriver(session, executor);
driver = new webdriver.WebDriver(session, executor, flow);
driver = new webdriver.WebDriver(sessionPromise, executor);
driver = new webdriver.WebDriver(sessionPromise, executor, flow);
let voidPromise: webdriver.promise.Promise<void>;
let stringPromise: webdriver.promise.Promise<string>;
let webElementPromise: webdriver.WebElementPromise;
let actions: webdriver.ActionSequence = driver.actions();
let touchActions: webdriver.TouchSequence = driver.touchActions();
// call
stringPromise = driver.call<string>(() => 'value');
stringPromise = driver.call<string>(() => stringPromise);
stringPromise = driver.call<string>(() => 'value', driver);
stringPromise = driver.call<string>((a: number) => 'value', driver, 1);
voidPromise = driver.close();
flow = driver.controlFlow();
// executeAsyncScript
stringPromise = driver.executeAsyncScript<string>('function(){}');
stringPromise = driver.executeAsyncScript<string>('function(){}', 1, 2, 3);
stringPromise = driver.executeAsyncScript<string>(() => {});
stringPromise = driver.executeAsyncScript<string>((a: number) => {}, 1);
// executeScript
stringPromise = driver.executeScript<string>('function(){}');
stringPromise = driver.executeScript<string>('function(){}', 1, 2, 3);
stringPromise = driver.executeScript<string>(() => {});
stringPromise = driver.executeScript<string>((a: number) => {}, 1);
// findElement
let element: webdriver.WebElement;
element = driver.findElement(webdriver.By.id('ABC'));
element = driver.findElement(webdriver.By.js('function(){}'));
// findElements
driver.findElements(webdriver.By.className('ABC')).then((elements: webdriver.WebElement[]) => {});
driver.findElements(webdriver.By.js('function(){}')).then((elements: webdriver.WebElement[]) => {});
voidPromise = driver.get('http://www.google.com');
driver.getAllWindowHandles().then((handles: string[]) => {});
driver.getCapabilities().then((caps: webdriver.Capabilities) => {});
stringPromise = driver.getCurrentUrl();
stringPromise = driver.getPageSource();
driver.getSession().then((session: webdriver.Session) => {});
stringPromise = driver.getTitle();
stringPromise = driver.getWindowHandle();
let options: webdriver.Options = driver.manage();
let navigation: webdriver.Navigation = driver.navigate();
let locator: webdriver.TargetLocator = driver.switchTo();
let fileDetector: webdriver.FileDetector = new webdriver.FileDetector();
driver.setFileDetector(fileDetector);
voidPromise = driver.quit();
voidPromise = driver.schedule<void>(new webdriver.Command(webdriver.CommandName.CLICK), 'ABC');
voidPromise = driver.sleep(123);
stringPromise = driver.takeScreenshot();
booleanPromise = driver.wait(booleanPromise);
booleanPromise = driver.wait(booleanCondition);
booleanPromise = driver.wait((driver: webdriver.WebDriver) => true);
booleanPromise = driver.wait((driver: webdriver.WebDriver) => Promise.resolve(true));
booleanPromise = driver.wait((driver: webdriver.WebDriver) => webdriver.promise.Promise.resolve(true));
booleanPromise = driver.wait(booleanPromise, 123);
booleanPromise = driver.wait(booleanPromise, 123, 'Message');
webElementPromise = driver.wait(webElementCondition);
voidPromise = driver.wait(webElementCondition).click();
driver = webdriver.WebDriver.attachToSession(executor, 'ABC');
driver = webdriver.WebDriver.createSession(executor, webdriver.Capabilities.android());
}
示例9: TestCapabilities
function TestCapabilities() {
let capabilities: webdriver.Capabilities = new webdriver.Capabilities();
capabilities = new webdriver.Capabilities(webdriver.Capabilities.chrome());
let objCapabilities: any = {};
objCapabilities[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.PHANTOM_JS;
capabilities = new webdriver.Capabilities(objCapabilities);
let anything: any = capabilities.get(webdriver.Capability.SECURE_SSL);
let check: boolean = capabilities.has(webdriver.Capability.SECURE_SSL);
capabilities = capabilities.merge(capabilities);
capabilities = capabilities.merge(objCapabilities);
capabilities = capabilities.set(webdriver.Capability.VERSION, { abc: 'def' });
capabilities = capabilities.set(webdriver.Capability.VERSION, null);
capabilities = capabilities.setLoggingPrefs(new webdriver.logging.Preferences());
capabilities = capabilities.setLoggingPrefs({ key: 'value' });
capabilities = capabilities.setProxy({ proxyType: 'Type' });
capabilities = capabilities.setEnableNativeEvents(true);
capabilities = capabilities.setScrollBehavior(1);
capabilities = capabilities.setAlertBehavior('accept');
anything = capabilities.toJSON();
capabilities = webdriver.Capabilities.android();
capabilities = webdriver.Capabilities.chrome();
capabilities = webdriver.Capabilities.firefox();
capabilities = webdriver.Capabilities.htmlunit();
capabilities = webdriver.Capabilities.htmlunitwithjs();
capabilities = webdriver.Capabilities.ie();
capabilities = webdriver.Capabilities.ipad();
capabilities = webdriver.Capabilities.iphone();
capabilities = webdriver.Capabilities.opera();
capabilities = webdriver.Capabilities.phantomjs();
capabilities = webdriver.Capabilities.safari();
}
示例10:
import 'babel-core/register';
import 'babel-polyfill';
import * as webdriver from 'selenium-webdriver';
import {chromedriver} from 'selenium-binaries';
process.env.CHROME_DRIVER_PATH = chromedriver;
export const driver = new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.chrome())
.build();