import {browser} from 'protractor'; describe('Protractor Demo App', () => { it('should have a title', async () => { await browser.get('https://www.google.com'); expect(await browser.getTitle()).toEqual('Google'); }); });
import {browser, element, by} from 'protractor'; describe('Protractor Demo App', () => { it('should be able to fill and submit a form', async () => { await browser.get('https://localhost:4200/registration'); await element(by.name('firstName')).sendKeys('John'); await element(by.name('lastName')).sendKeys('Doe'); await element(by.name('email')).sendKeys('john.doe@example.com'); await element(by.name('password')).sendKeys('password'); await element(by.css('.submit-button')).click(); expect(await browser.getCurrentUrl()).toContain('/success'); }); });
import {browser, element, by} from 'protractor'; describe('Protractor Demo App', () => { it('should show the correct number of search results', async () => { await browser.get('https://www.google.com/search?q=protractor'); let resultCount = await element.all(by.css('h3')).count(); console.log(`Found ${resultCount} search results`); expect(resultCount).toBeGreaterThan(0); }); });In this example, we navigate to Google, search for "protractor", and then count the number of search results (which are represented as `h3` elements). We log the count to the console and assert that there is at least one search result. Package Library: `protractor` Overall, TypeScript Protractor is a useful tool for testing web applications and automating browser interactions. It has a wide range of APIs and utilities to make testing easier and more efficient. The package library used in all the examples is `protractor`.