Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] #2

Open
mahefasolofo opened this issue Aug 25, 2023 · 12 comments
Open

[BUG] #2

mahefasolofo opened this issue Aug 25, 2023 · 12 comments
Assignees
Labels
answered bug Something isn't working

Comments

@mahefasolofo
Copy link

🐞 Describe the bug:
When I try to run the tests, with the command 'npx playwright test' I have an error :
Error: locator.fill : value : expected string, got undefined
at tests\pages\login-page.ts:24
await this.password.fill(password) ;

👻 To Reproduce:
Steps to reproduce the behavior: (On the project code)

  1. Go to 'Terminal'
  2. run the command 'npx playwright test'
  3. tests don't start
  4. See error

🌵 Expected behavior:
Tests starts

📸 Screenshots/GIFs/Videos:
Capture d’écran (20)

💈 Dependencies' Version (please complete the following information):

  • OS: Windows 10
  • Browser Chromium
  • Playwright Version 1.35.1",
  • DotEnv Version 16.1.4
  • Applitools Version 1.17.5
  • VS Code Version 1.79.1
  • npm Version 9.5.1

🎡 A picture of your pet or a toy or something really cool:
🧪 🤟🏽

@mahefasolofo mahefasolofo added bug Something isn't working pending labels Aug 25, 2023
@raptatinha
Copy link
Owner

Hi @mahefasolofo ,

As per the error message, it's not finding the "password" variable.
The test is getting the password from the .env file.
Could you please check your .env file and see if the password is there?
Here are the instructions I left on the project setup to guide you.

Let me know how it goes :)

@mahefasolofo
Copy link
Author

mahefasolofo commented Aug 25, 2023 via email

@raptatinha
Copy link
Owner

@mahefasolofo
Probably the login is not happening.
Can you create a new account at "https://demoqa.com/login" and update your .env file with your credentials?

@mahefasolofo
Copy link
Author

mahefasolofo commented Aug 25, 2023 via email

@raptatinha
Copy link
Owner

I explain this in the first chapter: https://testautomationu.applitools.com/playwright-advanced/chapter1.1.html

@raptatinha
Copy link
Owner

what command are you using to run the test (https://github.com/raptatinha/tau-advanced-playwright#run-the-project)?

@mahefasolofo
Copy link
Author

mahefasolofo commented Aug 25, 2023 via email

@mahefasolofo
Copy link
Author

mahefasolofo commented Aug 25, 2023 via email

@raptatinha
Copy link
Owner

This is really weird @mahefasolofo ..
You can post your questions here (I may take a few hours/day to reply), or at the discord channel https://aka.ms/playwright/discord (you have the whole community to help)...

@CIALdev
Copy link

CIALdev commented Oct 13, 2023

I have the same issue:

tau-advanced-playwright@1.0.0 test-ui-c
npx playwright test tests/ui/specs/ --project=chromium
Error: locator.fill: value: expected string, got undefined

at tests\ui\pages\login-page.ts:29

27 | async doLogin(email: string, password: string) {
28 | await this.fillEmail(email);

29 | await this.fillPassword(password);
| ^
30 | await this.loginButton.click();
31 | }
32 |

I pasted the content from example.env to the new .env file and replaced USERNAME and PASSWORD with the ones from my new profile on demoqa. The password in .env file is correct as well as the username. Where could it go wrong? Do I need to do anything extra to .env other than just creating it and copy-pasting the structure from example + changing username/password to mine?
Thanks!
UPD:
Looks like login form has changed and now it takes username, not email?
For some reason I can't rum the tests headed using npx playwright test --headed or npm run test-ui-h...
So many bugs in the course on catching bugs :D

BTW I had half the tests red in the basic course as well, probably because something is commented out while it shouldn't or something is not updated

@raptatinha
Copy link
Owner

Hi @CIALdev,
quick question, are you following the classes at test automation university?

I'm asking because the classes show the test execution isolated to exemplify each example (I'll send a PR later updating the readme to make it clear here too).

The application we are using for this training doesn't deal well with multiple sessions (I mention this in some of the chapters), for this reason, we need to use ".only" for a few tests, or do some specific changes to run a test successfully. These tests are not meant to be run all together (due to the application limitation).
For example: In chapter 1.1 around minute 4:54 I show the test passing with the ".only" on line 12. And so on for each chapter...
In chapter 1.2 I also mention other changes that need to be done to run the command "npm run test-ui-auth-user".

Regarding the "UPD" you mentioned: The login locator is "this.userName = page.getByPlaceholder('UserName');" as you can see on file login-page.ts. I named the method "fillEmail" (on line 19 of the same file) but you can see it receives a string, which can be anything, and it will use what is passed as parameter for each test; for example, for the test login.spec.ts it will use "const userName = process.env.USERNAME!;" for the test "test(successfull login, async () => {" line 20; and it will use "userData.invalidUsername;" for the test " test(failing login - invalid username, async () => {" line 25. So it's targeting the right locator of the application (I double-checked) and it's using a different parameter for each test, as expected. I explain more about data management in chapter 4.

Let me know if you need more clarification on how locators are used, I can plan a webinar about it to help you understand better. I recommend you take a look at these 2 resources meanwhile: https://github.com/raptatinha/tau-introduction-to-playwright/blob/main/extra-resources/chapter1.MD and https://github.com/raptatinha/tau-introduction-to-playwright/blob/main/extra-resources/chapter2.MD.

I'll check the Intro Course too and will get back to you ASAP.

@flynnbops
Copy link

@CIALdev

Do I need to do anything extra to .env other than just creating it and copy-pasting the structure from example + changing username/password to mine?

After you create your .env file, and change any values.

You should run source .env in the terminal from the repo root. This will apply your changes.

My test run

Here's what I ran, and the results for a comparison.

I'll have a better understanding of needs fixing when I complete the course. This run was enough for me to know that I'm setup.

// Create a `.env` file which has the same contents as `.env.example`
source .env
npm run test-ui-c 

This resulted in:
Screenshot 2023-11-09 at 15 16 58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants