Playwright Java Tutorial 🎭 | How To Handle Windows, Tabs, And Popups | Part VIII | LambdaTest

Поділитися
Вставка

КОМЕНТАРІ • 10

  • @LambdaTest
    @LambdaTest  Рік тому +1

    📍𝐆𝐢𝐭𝐇𝐮𝐛 𝐋𝐢𝐧𝐤: github.com/ortoniKC/LambdaTest-Playwright-Java

  • @pradipvaghela3179
    @pradipvaghela3179 6 місяців тому +2

    Hey brother, can you please assist me how can i use one test login into another tab without closing 1st tab. this is my code. test.describe('Login tab demo', () => {
    test('1st admin login 1st tab', async function ({ page }) {
    await adminSigin.adminLogin(page)
    })
    test('2nd tab login', async function ({ page }) {
    // how to use 1st tab login in new opened tab without close 1st tab
    await page.goto('admin link')
    })
    }) Your help will useful for my work. thank

    • @LambdaTest
      @LambdaTest  6 місяців тому

      Hey there,
      Thanks for reaching out,
      Certainly! In Playwright, to use a login session from one tab in another without closing the first tab, you can share context or cookies between the tabs. Since tabs within the same browser context share cookies and storage by default, you can simply open a new tab in the same context and navigate to your desired URL. If your authentication state is stored in cookies or session storage, this method will allow the new tab to inherit the logged-in state from the first tab.
      test.describe('Login tab demo', () => {
      test('admin login and open a new tab', async ({ browser, context }) => {
      // First tab login
      const page = await context.newPage();
      await adminSigin.adminLogin(page); // Perform login on the first tab
      // Open a new tab within the same context
      const newPage = await context.newPage();
      // Now, navigate to the admin link in the new tab
      await newPage.goto('admin link');
      // You can perform your tests here in the new tab
      // The new tab should have the same login session as the first tab
      // Optionally, if you need to interact with the first tab again, you can do so
      // Example: await page.goto('some other link');
      // Cleanup: Closing tabs if necessary (optional)
      // await page.close();
      // await newPage.close();
      });
      });

  • @FlashTracer
    @FlashTracer 10 місяців тому

    Hi Koushik, thank you so much for your videos, you are a great teacher!
    I got a question: do you have a video about how to handle popup modal(1:16) ?

    • @LambdaTest
      @LambdaTest  10 місяців тому +1

      Glad to hear that!
      While we don't currently have a video on Popup modals, we'll consider creating one in the future.
      Please subscribe to our channel for updates on all our latest tutorials.

  • @SasTest-e4w
    @SasTest-e4w Рік тому +1

    how to open new tab without any popup ?

    • @LambdaTest
      @LambdaTest  Рік тому

      Hey there 👋🏻
      To open a new tab without any pop-up using Playwright in Java, you can use
      page.click("a[target=_blank]");
      This code finds a link () element on the page with the target attribute set to _blank (indicating that it should open in a new tab) and clicks on it. This will open a new tab without any pop-up.

    • @SasTest-e4w
      @SasTest-e4w Рік тому

      @@LambdaTest it didn't work for me.

  • @smeeangle
    @smeeangle Рік тому

    Awesome. Thank you.

    • @LambdaTest
      @LambdaTest  Рік тому

      Thanks 😊
      Subscribe to our channel to never miss an update on the upcoming tutorials! ✨