本文整理汇总了TypeScript中protractor.browser.manage方法的典型用法代码示例。如果您正苦于以下问题:TypeScript browser.manage方法的具体用法?TypeScript browser.manage怎么用?TypeScript browser.manage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类protractor.browser
的用法示例。
在下文中一共展示了browser.manage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: expect
browser.sleep(5000).then(() => {
// At the end of the time the scrolling should be at the specific target position
page.getScrollPos().then((pos: number) => {
expect(pos).toBeCloseTo(headingLocation.y, Closeness.ofByOne);
});
// Inspect the console logs, they should contain all in between scroll positions
// Using the browser.sleep() to execute some code while the animation is running does not work
// consistently across browser, especially causing problems with the CI server
browser.manage().logs().get('browser').then(browserLog => {
const scrollPositionHistory = browserLog
.filter(log => log.message.indexOf('Scroll Position: ') >= 0) // only take scroll position logs
.map(log => parseInt(log.message.split(' ').reverse()[0], 10)); // parse scroll logs into ints
expect(scrollPositionHistory.length).toBeGreaterThan(0);
// Iterate over all scroll position logs and make sure the increment is always nearly the same
// (as it should be the case for linear easing)
const totalScrollDistance = headingLocation.y - initialPos;
const averageScrollPosChange = scrollPositionHistory[scrollPositionHistory.length - 1]
/ scrollPositionHistory.length;
// Allow some variation (the exact absolute value is made to depend on the total scroll distance)
const closeToEpsilon = Closeness.ofBy(totalScrollDistance * 0.0075);
for (let i = 0; i < scrollPositionHistory.length - 2; i++) {
const scrollPosChange = scrollPositionHistory[i + 1] - scrollPositionHistory[i];
expect(scrollPosChange).toBeCloseTo(averageScrollPosChange, closeToEpsilon);
}
});
});
示例2: it
it('should go through the checkout process', async() => {
await pageElements.productListLinks.get(0).click();
const checkoutLink = pageElements.topBarCheckoutLink;
const productDetailsPage = pageElements.productDetailsPage;
const buyButton = await productDetailsPage.element(by.css('button'));
const cartPage = pageElements.cartPage;
const inputFields = cartPage.all(by.css('form input'));
const purchaseButton = await cartPage.element(by.css('button'));
const nameField = inputFields.get(0);
const addressField = inputFields.get(1);
await buyButton.click();
await browser.wait(EC.alertIsPresent(), 1000);
await browser.switchTo().alert().accept();
await checkoutLink.click();
await nameField.sendKeys('Customer');
await addressField.sendKeys('Address');
await purchaseButton.click();
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
const cartMessages = logs.filter(({ message }) => message.includes('Your order has been submitted'));
expect(cartMessages.length).toBe(1);
});
示例3: afterEach
afterEach(done =>
browser.manage().logs().get('browser').then(function(browserLog) {
// uncomment when following bug is fixed https://crbug.com/902918
// console.log(browserLog);
// expect(browserLog.length).toEqual(0);
return done();
})
示例4: function
onPrepare: function () {
const Reporting = require('perfecto-reporting');
browser.manage().timeouts().implicitlyWait(30000);
reportingClient = new Reporting.Perfecto.PerfectoReportingClient(new Reporting.Perfecto.PerfectoExecutionContext({
webdriver: browser.driver,
tags: ['expenseTrackerTS', 'expenseTrackerJasmineTS']
}));
browser.reportingClient = reportingClient;
var myReporter = {
specStarted: function (result) {
reportingClient.testStart(result.fullName);
},
specDone: function (result) {
if (result.status === 'failed') {
const failure = result.failedExpectations[result.failedExpectations.length - 1];
reportingClient.testStop({
status: Reporting.Constants.results.failed,
message: `${failure.message} ${failure.stack}`
});
} else {
reportingClient.testStop({
status: Reporting.Constants.results.passed
});
}
}
}
jasmine.getEnv().addReporter(myReporter);
}
示例5: afterEach
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry));
});
示例6: initializeEnvironment
/** Adds a custom jasmine reporter that simply keeps track of the current test name. */
function initializeEnvironment(jasmine: any) {
browser.manage().window().setSize(WIDTH, HEIGHT);
let reporter = new jasmine.JsApiReporter({});
reporter.specStarted = function(result: any) {
currentJasmineSpecName = result.fullName;
};
jasmine.getEnv().addReporter(reporter);
}
示例7: done
.then(function (capabilities) {
if (capabilities.get('browserName') !== 'firefox') {
browser.manage().logs().get('browser').then(done, done.fail);
browser.waitForAngular();
} else {
done();
}
});
示例8: afterEach
afterEach(() => {
browser
.manage()
.logs()
.get('browser')
.then((browserLog: any[]) => {
expect(browserLog).toEqual([]);
});
});
示例9: it
it('should display the expanded navbar for high resolutions', () => {
browser.manage().window().setSize(1024, 768);
page.navigateTo();
expect(page.getNavbarElement(0)).toEqual('Home');
expect(page.getNavbarElement(1)).toEqual('Cats');
expect(page.getNavbarElement(2)).toEqual('Login');
expect(page.getNavbarElement(3)).toEqual('Register');
expect(page.getNavbarButton()).toBeFalsy();
});
示例10: it
it('AngularHomePage test' , async()=> {
let angularPage = new AngularHome();
await browser.get('https://angularjs.org/');
await browser.manage().window().maximize();
await angularPage.angularLink.click();
await angularPage.searchText.sendKeys("angular").then(function () {
browser.sleep(3000); // sleep added just to see the results
});
});
开发者ID:ashutoshchittora,项目名称:TypeScriptCucumberProtractorVisualStudioCode,代码行数:10,代码来源:testSpecChainLocators.ts