Тёмный

How To Automate Date Pickers | Playwright With TypeScript Tutorial 🎭| Part VII | LambdaTest 

LambdaTest
Подписаться 29 тыс.
Просмотров 11 тыс.
50% 1

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 16   
@LambdaTest
@LambdaTest 2 года назад
GitHub URL: github.com/ortoniKC/playwright-ts-lambdatest
@MartinsJDPower
@MartinsJDPower Месяц назад
This was quite helpful! Thanks a bunch!
@mayureshkelhar6968
@mayureshkelhar6968 2 года назад
hello Koushik, Thanks for all the videos you made available on youtube and all of them are really helpful . In this video, just want to know if you found any workaround for 6:04 ? Thanks!
@letcode
@letcode 2 года назад
No, that seems to be a page issue, I'll connect with the lambda test dev team and will check.
@grantlane6512
@grantlane6512 2 года назад
Hello Koushik. I’m using Playwright with typescript. Could you recommend an alternative to Moment for date selectors please. The Moment site advised its end of life and to use something else. Will date-fns be ok with ts?
@LambdaTest
@LambdaTest 8 месяцев назад
Yes, date-fns is a great alternative to Moment.js and works well with TypeScript. It's modular, lightweight, and offers a wide range of date operations. You should find it a good fit for handling date selectors in Playwright with TypeScript. 👍
@HybridFox_Ava
@HybridFox_Ava 9 месяцев назад
How to close the calendar after selecting the date?
@LambdaTest
@LambdaTest 9 месяцев назад
Hey there, Closing a calendar widget after selecting a date in an automation script typically involves simulating the same user interactions that would close the calendar in a manual use case. In Playwright with TypeScript, you can accomplish this depending on how the calendar UI is designed. Here are a few common strategies: Click on the Date: If the calendar closes upon date selection: await page.click('selector-for-date'); Click Outside: If clicking outside the calendar closes it: await page.click('element-selector'); Close Button: If there's a specific close button: await page.click('selector-for-close-button'); Escape Key: To close with the Escape key: await page.keyboard.press('Escape'); Validate Closure: Ensure the calendar is closed: await expect(page.locator('calendar-selector')).not.toBeVisible(); Adjust the selectors to suit your application's UI elements.
@anucoonjan3348
@anucoonjan3348 6 месяцев назад
How can we put this selectDate function in a different custom command file and call it in our spec file in between tests pls.Thanks
@LambdaTest
@LambdaTest 6 месяцев назад
Hey there, To organize your Cypress tests better and reuse functions across different spec files, you can define custom commands in Cypress. Here’s a step-by-step guide on how to put a selectDate function in a custom command file and then call it in your spec file. Step 1: Define the Custom Command - Create a Custom Command File (if not already present): By default, Cypress looks for custom commands in cypress/support/commands.js. If this file doesn't exist, create it. - Add the selectDate Function as a Custom Command: Open cypress/support/commands.js and use Cypress.Commands.add to define your custom command. Step 2: Include the Custom Commands File Ensure that cypress/support/commands.js is correctly imported in your cypress/support/index.js file, which is where Cypress automatically imports files for global availability. This is usually set up by default when you initialize a Cypress project. Step 3: Use the Custom Command in Your Spec File Now, in any of your spec files (e.g., cypress/integration/yourTestSpec.js), you can use the selectDate command just like any other Cypress command. By following these steps, you can effectively organize your Cypress tests, making them cleaner and promoting code reuse across your testing suite.
@lululula5783
@lululula5783 6 месяцев назад
​@@LambdaTesthello, how would you reuse code in playwright.. Like calling the same datepicker code, different dates in different files?
@LambdaTest
@LambdaTest 6 месяцев назад
Hey there, In Playwright, code reuse, especially for common actions like interacting with a datepicker across different tests or files, is typically achieved through a combination of custom functions, helper classes, or Playwright's fixtures. These techniques allow you to encapsulate logic in a single place and call it from anywhere in your test suite, making your tests more maintainable and readable. 1. Custom Functions You can create a custom function for interacting with the datepicker and export this function to use it across different test files. 2. Playwright Fixtures Playwright fixtures allow you to extend the test context with custom functionalities. You can create a fixture that adds a method to the page or context objects for selecting a date. 3. Helper Classes For complex interactions, encapsulate the logic in a class.
@fardhanafirdhause9783
@fardhanafirdhause9783 Год назад
you skipped an important part buddy. How to pick a date which is enabled in the calendar out of many disabled date?
@LambdaTest
@LambdaTest Год назад
Hey there! To pick an enabled date among many disabled ones, identify the HTML attributes indicating a date's status. For ex: _// Select an enabled date const enabledDate = await page.$('.date:not(.disabled-date)'); await enabledDate?.click();_ Here, '.date:not(.disabled-date)' selects elements with class 'date' and without 'disabled-date'. Adjust this to match your date picker's actual classes.
Далее
Airpod Through Glass Trick! 😱 #shorts
00:19
Просмотров 356 тыс.
Teeth gadget every dentist should have 😬
00:20
Просмотров 941 тыс.