How to share page object | Playwright & Cucumber - Typescript | Part 3

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 88

  • @fariskanbur5428
    @fariskanbur5428 Год назад +2

    If you use an arrow function in Hooks, the reason you get an error is because the arrow functions have their own lexical context and do not correctly determine the this context. Hooks use context significantly and this context must be set as expected by the hook function.
    Instead, you should use regular function definition in hooks instead of arrow function. Normal functions automatically get the context and this context is set correctly.

    • @letcode
      @letcode  Год назад

      Yes, thanks for the explanation.

  • @andyshort9471
    @andyshort9471 Год назад +1

    Very good demo, man. Impressive stuff

  • @Ankushkumar213
    @Ankushkumar213 4 месяца назад +1

    Bro.. your videos are absolutely great.. but it would be great if you share the code base as well ..
    1-playlist = 1 repo and per video per branch..

    • @letcode
      @letcode  4 месяца назад

      Thanks, the source code is in the description.
      GitHub link

    • @letcode
      @letcode  4 месяца назад

      github.com/ortoniKC/Playwright_Cucumber_TS

  • @ravirai121
    @ravirai121 Год назад +1

    can you suggest changes if i have list of devices defined in playwright config ts file and want to use that instead of defining specific browsers in the hooks

    • @letcode
      @letcode  Год назад

      Playwright config and cucumber config are different, we cannot use them from there.

  • @HariBaabu-dp1mf
    @HariBaabu-dp1mf Год назад +1

    Very helpful thanks

  • @blecomp
    @blecomp Год назад +1

    Hello my friend, in the minute 7:04 you do an import from qick fix.. There is an extensión for that? Thanks

    • @letcode
      @letcode  Год назад

      That's the vscode feature, you can click on the bulb icon to get the quick fix.

  • @PritiKothavale
    @PritiKothavale Год назад +1

    I added code as you have instructed Kuoshik but when I run the test I get this error in hooks file - "SyntaxError: Cannot use import statement outside a module". The only difference is in my project application, they already have typescript and ts-loader installed. I am not sure if that would make the difference.

    • @letcode
      @letcode  Год назад

      You have to use this
      "resolveJsonModule": true
      In your tsconfig file.

  • @bhargavgurav3160
    @bhargavgurav3160 Месяц назад +1

    why is it like same things run in your device does not run in my device. like cucumber extension automatically take from feature to step function but it does not work in my system. Also this video's adding to cart using two users does not work.

    • @letcode
      @letcode  Месяц назад

      😅, I'm not hiding anything.
      You might have missed a few things.
      Please watch the whole playlist once, you'll definitely get all the answers.

  • @techridermahtoji
    @techridermahtoji Год назад +2

    Hi Koushik,, thanks for the videos. It's really helpful. I am seeing issue in navigating from features file to respective definitions when I using ctrl plus click. It doesn't show underscore in gwt on pressing ctrl button. What could be issue and how can I fix that?

    • @letcode
      @letcode  Год назад

      Hi. In the part 1 video i have explained the configuration, did u follow that?

    • @techridermahtoji
      @techridermahtoji Год назад +1

      @@letcode yes, but still I am facing issue, rest everything working fine

    • @letcode
      @letcode  Год назад

      Share your screenshots here discord.gg/rK9Mr3YA
      I'll check.

  • @Narutouzumaki-t6c
    @Narutouzumaki-t6c 4 месяца назад +1

    Great tutorial. I am facing the below issue:
    1. I copied the step definitions generated and pasted them. When I ran the command “npm run test” I am getting steps undefined?
    Could you please help me with the above issue?

    • @letcode
      @letcode  4 месяца назад

      Is the required and path values are set properly?

    • @Narutouzumaki-t6c
      @Narutouzumaki-t6c 4 месяца назад

      @@letcode yes

    • @Narutouzumaki-t6c
      @Narutouzumaki-t6c 4 месяца назад

      @@letcode yes

    • @letcode
      @letcode  4 месяца назад +1

      It must be path issue only, rewatch the first video about configuration.

  • @mtibi85
    @mtibi85 9 месяцев назад +1

    Instead of creating a pageFixture to store the shared objects, could we use the "world" provided by cucumberJS? Is there a best practice on this?

    • @letcode
      @letcode  9 месяцев назад

      Yes we can, but I thought this implementation will be easier.

  • @jampanisiva6795
    @jampanisiva6795 Год назад +1

    ​ @LetCode with Koushik When I am running with npm run test getting below issue. its not picking the scenarios. Also tried with your repo . its same issue
    1 scenario (1 skipped)
    2 steps (2 skipped)
    0m00.003s (executing steps: 0m00.000s)

    • @letcode
      @letcode  Год назад

      Is dryrun false?

    • @jampanisiva6795
      @jampanisiva6795 Год назад +1

      @@letcode I changed it to false and it worked . Thanks

  • @MrPriyank23
    @MrPriyank23 Год назад +1

    hI koushik
    can you please create video on api testing with cucumber and playwright as well as tracing functionality video too.

  • @sridharramachandran4113
    @sridharramachandran4113 Год назад +1

    Hi Bro, your video is really helpful and it is very clear for learning . Can you pls post video how to connect this project to saucelab integration

  • @maopuerta3430
    @maopuerta3430 Год назад +1

    excellent

    • @letcode
      @letcode  Год назад

      Thank you! Cheers!

  • @amruthasnair6884
    @amruthasnair6884 9 месяцев назад +1

    Hi, I am reciving this error :
    error TS2305: Module '"../../hooks/PageFixture"' has no exported member 'PageFixture'.
    2 import { PageFixture } from "../../hooks/PageFixture";

    • @letcode
      @letcode  9 месяцев назад +1

      Have you added an export default class ?

  • @manishdangwal8433
    @manishdangwal8433 Год назад +1

    Thanks it is very helpful. Can you please help how we can use soft assertion in playwright with cucumber Typescript. The existing playwright method .soft() is not working over cucumber framework.

    • @letcode
      @letcode  Год назад

      Soft assertion is specific to the playwright test runner only.
      Cucumber runner will not understand that.

    • @manishdangwal8433
      @manishdangwal8433 Год назад +1

      @@letcode is there any alternate way to perform soft assertion in cucumber bdd typescript

    • @letcode
      @letcode  Год назад

      I'm not sure for now, I'll check.

  • @jagrutibachhav-m4o
    @jagrutibachhav-m4o Год назад +1

    Hi Kaushik,
    Previously I was facing "TypeError: Cannot read properties of undefined" for .locator then I have done all your mentioned changes in hooks and pageFixture files, it is working for .locator(pre-define) methods now, but when I am trying to call POM method in step def file, it is showing me that similar error "TypeError: Cannot read properties of undefined"(this is working fine for single feature file, but when I have created multiple feature files then it started showing mi this undefined error while accessing POM method)

    • @letcode
      @letcode  Год назад

      Hi, it should work for one or multiple, the problem here i guess is u r not passing the page object properly to all the files.

    • @jagrutibachhav-m4o
      @jagrutibachhav-m4o Год назад +1

      @@letcode Yes, got it, Thank You.
      I have another question regarding maintenance, If there will be any major UI changes in future(and no unique locators currently) then will it be feasible to use your mentioned folder structure or should we use any other approach for script maintenance? Could you please suggest??

    • @letcode
      @letcode  Год назад +1

      @@jagrutibachhav-m4o i always prefer to keep my locators and method with in the same class.
      It will be easier to find the locator changes and fix it.

  • @P-nf7vl
    @P-nf7vl Год назад +1

    I am trying this is in Mac OS, my feature file doesnt show link to step definition, have tried the keyboard shortcut, but no use

    • @letcode
      @letcode  Год назад

      Did u do the steps mentioned in first video of the playlist?

    • @P-nf7vl
      @P-nf7vl Год назад +1

      Yes, I did follow step, my test works, but the link is not shown

    • @letcode
      @letcode  Год назад

      May be the plugin issue.

    • @P-nf7vl
      @P-nf7vl Год назад +1

      @@letcode updated plugin, had installed some other, working now. Thank you for quick response and helpful video

    • @letcode
      @letcode  Год назад

      @@P-nf7vl great 😃

  • @Jinjr322
    @Jinjr322 Год назад +1

    9:20 but how to do it without ts-ignore?

    • @letcode
      @letcode  Год назад

      It is used to ignore the compile time issue.
      I don't think we have alternate for that.

  • @JanagarJohn
    @JanagarJohn Год назад +1

    Hi Koushik - how to run feature files(sequential order) not scenario

    • @letcode
      @letcode  Год назад

      By default it runs by the alphabetic order, not sure how to sequence it, I'll check and let u know.

    • @JanagarJohn
      @JanagarJohn Год назад +1

      @@letcode thanks brother, waiting for you

  • @dealsdiscount475
    @dealsdiscount475 Год назад +1

    VError: a BeforeAll hook errored, process exiting: src\hooks\hooks.js:13: Cannot set properties of undefined (setting 'page')

    • @letcode
      @letcode  Год назад

      Check the code example, link in the video description.
      I guess, u have used issue with local and global scope page variable.

  • @Ashokkumar-uv4fs
    @Ashokkumar-uv4fs Год назад +1

    Hi Bro,
    I am getting error locator. textcontent: Timeout 30000ms exceed. Waiting for locator, how to fix this issue

    • @letcode
      @letcode  Год назад

      Is the locator correct?
      Try with different XPath or any other locator.

    • @Ashokkumar-uv4fs
      @Ashokkumar-uv4fs Год назад

      @@letcode Error: function uses multiple asynchronous interfaces: callback and promise
      to use the callback interface: do not return a promise
      to use the promise interface: remove the last argument to the function i am getting error.

    • @letcode
      @letcode  Год назад

      to use the text content u have to use the await locator.textContent();

  • @ShijithKannoth
    @ShijithKannoth Год назад +1

    How to create page object model for this framework ??

    • @letcode
      @letcode  Год назад

      ruclips.net/video/kl6jR6vHqZg/видео.htmlsi=qtH6Sx-foQY15z7e

  • @user-uw4qp4qr3j
    @user-uw4qp4qr3j 4 месяца назад +1

    I'm getting an "Error: Cannot find module ~pageFixturePath~ imported from ~stepsPath~"

    • @letcode
      @letcode  4 месяца назад

      Pls follow the steps from the 1st video.

    • @dhirajkumarsharman6499
      @dhirajkumarsharman6499 Месяц назад

      ​@@letcodeI m getting the same error after following the steps from 1st video

    • @dhirajkumarsharman6499
      @dhirajkumarsharman6499 Месяц назад

      Can you please share the solution

  • @vikrantchaudhari7017
    @vikrantchaudhari7017 Год назад +1

    Nice video! In every step defination file you are writing setDefaultTimeout(60 * 1000 * 2). Is there any way by which we can write it once instead of writing in every step file?

    • @letcode
      @letcode  Год назад +1

      Yes we can from the hooks I guess.

    • @batistababu3038
      @batistababu3038 7 месяцев назад

      But why we need this?

  • @kidvikvlogs
    @kidvikvlogs Год назад +1

    How to debug code using playwright with cucumber.kindly share the inputs

    • @letcode
      @letcode  Год назад +1

      Ok bro, I'll create a video.

  • @user-uw4qp4qr3j
    @user-uw4qp4qr3j 4 месяца назад +1

    What's the solution for doing pageFixture without @ts-ignore

    • @letcode
      @letcode  4 месяца назад

      Adding declaration file should fix that

    • @user-uw4qp4qr3j
      @user-uw4qp4qr3j 4 месяца назад +1

      @@letcode What's a declaration file?

    • @letcode
      @letcode  4 месяца назад

      It's only a typescript feature, I'll add a video about it

  • @mohanpalle0806
    @mohanpalle0806 7 месяцев назад

    Need one help, how we can set browser zoom at 67% in playwright?

    • @letcode
      @letcode  7 месяцев назад

      Not sure, probably you can try setting using javascript window query.

  • @JanagarJohn
    @JanagarJohn Год назад

    Hi, why every-time new window open for one scenario and another(opening & closing behaviour) ?

    • @JanagarJohn
      @JanagarJohn Год назад +1

      Because in webdriverIO end2end open then browser closed after all tests passed, sorry i am new to playwright thats why am asking.

    • @letcode
      @letcode  Год назад

      We can change that, it should be configured within the hooks

  • @eveakospokua
    @eveakospokua Год назад +1

    Thank you for sharing these videos. Could you please, add api testing to this cucumber with typescript videos?
    Thank you.

    • @letcode
      @letcode  Год назад

      Yeah, it's in progress. I'll start in a few weeks.

  • @Cecile-p4v
    @Cecile-p4v Год назад +1

    thanks a lot, really helpful.
    ✖ Given Go to google page # src/test/steps/first.ts:4
    TypeError: Cannot read properties of undefined (reading 'goto')
    at World.
    for this error what should I do?

    • @letcode
      @letcode  Год назад

      Is page is defined properly in hooks ?