Using Single Sign On with applications that support OpenID
[ { "firstName": "John", "city": "New York", "dateOfBirth": "1985-02-15" }, { "firstName": "Maria", "city": "Los Angeles", "dateOfBirth": "1992-07-24" }, { "firstName": "David", "city": "Chicago", "dateOfBirth": "1978-11-03" }]
Feature: Login to TestQuality website
As a registered user
I want to login to the TestQuality website
So that I can access my account
Scenario: Login with valid credentials
Given I am on the TestQuality login page
When I enter valid login credentials
And click the login button
Then I should be redirected to the TestQuality dashboard page
Scenario: Login with invalid credentials
Given I am on the TestQuality login page
When I enter invalid login credentials
And click the login button
Then I should see an error message displayed on the page
const { Given, When, Then } = require('cucumber');
const { Builder, By, Key, until } = require('selenium-webdriver');
const driver = new Builder().forBrowser('chrome').build();
Given('I am on the TestQuality login page', async function () {
await driver.get('https://web.testquality.com/login');
});
When('I enter valid login credentials', async function () {
await driver.findElement(By.name('email')).sendKeys('user@example.com');
await driver.findElement(By.name('password')).sendKeys('password123', Key.RETURN);
});
When('I enter invalid login credentials', async function () {
await driver.findElement(By.name('email')).sendKeys('user@example.com');
await driver.findElement(By.name('password')).sendKeys('invalidpassword', Key.RETURN);
});
Then('I should be redirected to the TestQuality dashboard page', async function () {
await driver.wait(until.urlContains('dashboard'));
await driver.quit();
});
Then('I should see an error message displayed on the page', async function () {
const errorMessage = await driver.findElement(By.css('.error-message')).getText();
expect(errorMessage).to.equal('Invalid email or password.');
await driver.quit();
});
describe('Login Test', () => {
it('Should successfully log in', () => {
cy.visit('https://web.testquality.com')
cy.get('input[name=email]').type('your_email')
cy.get('input[name=password]').type('your_password')
cy.get('button[type=submit]').click()
cy.url().should('include', '/dashboard')
})
it('Should fail to log in with incorrect credentials', () => {
cy.visit('https://web.testquality.com')
cy.get('input[name=email]').type('incorrect_email')
cy.get('input[name=password]').type('incorrect_password')
cy.get('button[type=submit]').click()
cy.contains('Invalid email or password').should('be.visible')
})
})