Cypress
Mesut GüLTEN
ISTQB? CTFL Senior Quality Engineer | Cypress | Selenium | Appium | Black box | Mobile | Web | API | WebdriverIo
Here is a basic example of a test using the Cypress testing framework:
describe('My website homepage', () => {
?it('successfully loads', () => {
??cy.visit('https://www.example.com/')
??cy.contains('Welcome to my website!')
?})
})
In this example, the describe function is used to group together related tests. The it function is used to define a single test. The cy.visit command is used to navigate to the website under test, and the cy.contains command is used to check that a specific element is present on the page.
You can also interact with the elements, use the command .click(), .type(), .clear(), .select(), etc.
describe('My website homepage', () => {
?it('submit form', () => {
??cy.visit('https://www.example.com/')
??cy.get('input[name="email"]').type('[email protected]')
??cy.get('input[name="password"]').type('password')
??cy.get('button[type="submit"]').click()
??cy.contains('Welcome [email protected]!')
?})
})
This is just a basic example, and there are many more commands and options available in Cypress for writing more complex tests.
sincerely