Тёмный

How To Handle Alerts And Dropdowns | Playwright With TypeScript Tutorial 🎭| Part V | LambdaTest 

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

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

 

28 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 18   
@LambdaTest
@LambdaTest 2 года назад
GitHub Repo: github.com/ortoniKC/playwright-ts-lambdatest
@kinzakhan7698
@kinzakhan7698 2 года назад
Amazing video 😁 Can you please have a video on the Playwright's assertions?
@LambdaTest
@LambdaTest 2 года назад
Thanks Kinza, Sure. Will consider this while creating next set of videos
@AdmixKraft
@AdmixKraft 2 года назад
Quality content, thanks 🤩
@LambdaTest
@LambdaTest 2 года назад
Thanks Mansi
@kaushikichauhan2362
@kaushikichauhan2362 2 года назад
Great video 😍 Can you show us how to use this feature to automate the date picker in Playwright?
@LambdaTest
@LambdaTest 2 года назад
Hi Kaushiki, You can follow this video to automate the date picker in Playwright: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-EtpASWgbWPg.html
@Vasavi_J
@Vasavi_J 6 месяцев назад
Very nice explanation. Iam struggling to find locator of an input textbox with id = "username134". Where the number is 134 keeps on changing every time. Could you help with the locator. I tried the below but not working in typescript page.locator("//input[contains(@id, 'username')]")
@LambdaTest
@LambdaTest 6 месяцев назад
Hey there, For handling dynamic element IDs in your test scripts with Playwright in TypeScript, when the ID changes as in your example (username134 where 134 can change), using contains with the @id attribute is a good approach. However, Playwright's locator API uses CSS selectors and text selectors by default, not XPath, which is why your current approach may not be working as expected. To target an element with a dynamic ID that always starts with a specific prefix (like username in your case) using Playwright, you can use the CSS attribute selector that matches the beginning of the attribute value. Here's how you can do it: page.locator('input[id^="username"]') This selector uses the ^= operator, which matches elements whose id attribute value begins with "username". Here's what each part means: input: Targets elements. [id^="username"]: Targets elements whose id attribute value starts with "username". This approach should work reliably for any input element whose ID starts with "username", regardless of the digits that follow.
@SehriGokcan-Altas
@SehriGokcan-Altas Год назад
I want to handle prompt alert voor username and password? How can I do this? Help you please..
@LambdaTest
@LambdaTest Год назад
Hey there, You can handle alerts by using the page.on('dialog', async dialog => { await dialog.dismiss(); }); method in Playwright. For username and password, use the page.authenticate({username, password}) function. For more, please refer to the documentation here: playwright.dev/docs/auth
@meenachauhan8824
@meenachauhan8824 2 года назад
Thanks for the video. It really helped me with my query 👍 Can you please create a quick video on Selenium vs Playwright? Which one is better to use?
@LambdaTest
@LambdaTest 2 года назад
Hey Meena, Glad the video helped you! Selenium and Playwright are the two most popular frameworks when it comes to test automation. Selenium is quite old as compared to Playwright, and both of them have their own set of advantages and limitations. However, will surely consider creating a video around the comparison.
@StingerSingh21
@StingerSingh21 2 месяца назад
I'm working on a test where I have I get an alert with two options: Ok and Cancel. I have to click Ok to continue with the test. When I do the steps manually then the alert appears and I can click Ok and proceed with the test. When I do it with Playwright, then the alert just doesn't appear so it continues without that which leads to some changes on the page not being saved. What can I do for that? Is there something that I have to change in playwright config that could be causing the alert to not appear?
@LambdaTest
@LambdaTest 2 месяца назад
Hi Damanbir, It sounds like the issue with Playwright might be related to the way it handles JavaScript dialogs such as alerts, confirms, and prompts by default. Playwright typically auto-dismisses these dialogs, which might explain why you don’t see the alert when running your tests. You can manage this behavior by setting up an event listener for the dialog event, which will allow you to intercept and interact with dialogs programmatically.
@StingerSingh21
@StingerSingh21 2 месяца назад
Thank you for your help. I had figured it out after I left this comment. I just had to add the dialog handling before the action that triggers it. I was clicking on a button that would trigger a JS alert but because I was handling it after that, it was already dismissed by that time. When I worked with Selenium, I would trigger the alert first and them handle it so that confused me. Once again, thank you.
@sonardhananjay
@sonardhananjay Год назад
//button[text()='Save Changes'])[1] is not valid xpath its not working with this , changed to //*[@id='myModal']/div/div/div[3]/button[2]
@LambdaTest
@LambdaTest Год назад
Hey there, Glad you liked it 😇 Make sure you subscribe to our RU-vid channel for more 👋🏻