No video

JavaScript | Mocha: Selenium Page Object Model Tutorial

  Рет қаралды 12,539

QA Underground

QA Underground

Күн бұрын

In this video we will go over how to create a Selenium Page Object Model framework using JavaScript and Mocha.
Link to GitHub Repo:
🔗 github.com/QAU...

Пікірлер: 37
@chathunm
@chathunm 3 жыл бұрын
Simple and straight !!! Everything in the right order...!!! This helped me lot
@QAUnderground
@QAUnderground 3 жыл бұрын
Thank you!
@edward0591
@edward0591 Жыл бұрын
now this is called a masterpiece in tutorial short simple easy to understand.
@gustavosiqueira1246
@gustavosiqueira1246 Жыл бұрын
Still saving at the end of 2022! Great video! I was having difficulty with multiple instances being open at the same time. My problem was with the constructor of the BasePage class (actually I called it DriverFactory class). But I managed to fix it with the help of this video. Thanks from Brazil!
@QAUnderground
@QAUnderground Жыл бұрын
Glad it helped!
@ro_sharp
@ro_sharp Жыл бұрын
Thank you for a great tutorial! Helped me a lot to set up my first POM project.
@QAUnderground
@QAUnderground Жыл бұрын
Glad it helped!
@Kumarkumar-gf3kk
@Kumarkumar-gf3kk 2 жыл бұрын
Nice Back ground music . its very pleasent
@diegoeliannava3246
@diegoeliannava3246 Жыл бұрын
Thank you for the video, just what I was looking for
@NPT95
@NPT95 2 жыл бұрын
thanks man! saved me hours of googling
@QAUnderground
@QAUnderground Жыл бұрын
Glad it helped!
@ivson
@ivson Жыл бұрын
Excellent video, mate 🙌
@yaroslavbuiukli4355
@yaroslavbuiukli4355 2 жыл бұрын
It's amazing! Why are you finished creating videos? You have a talent for this Ты реально крутой мужик))
@QAUnderground
@QAUnderground Жыл бұрын
More videos are coming soon, I think you will enjoy! Keep an eye out for them and thank you so much for the kind words!
@abdulazeemms7256
@abdulazeemms7256 3 жыл бұрын
Very Useful
@QAUnderground
@QAUnderground 3 жыл бұрын
Glad you think so!
@joseomv07
@joseomv07 Жыл бұрын
mine say all papss but it does not search anything on the search box.
@cshah2009
@cshah2009 3 жыл бұрын
Love to see how to take snapshot on failure for web driver JS
@QAUnderground
@QAUnderground 3 жыл бұрын
Hi @Mr Shah, Thanks for the great suggestion! Keep a look out for future content! ;)
@manulourdes
@manulourdes 2 жыл бұрын
Hey man, this is an old video hopefully you can help me out. I am running the same scripts and the test are passing but its not typing anything,
@QAUnderground
@QAUnderground Жыл бұрын
There are a few potential issues that could cause Selenium to not type anything when running a JavaScript Mocha test. Here are a few things to check: 1) WebDriver is not connected to the correct browser instance: Make sure that Selenium is connecting to the correct browser instance and that the browser is open and running before the test is run. 2) Locator is not correct: Verify that the locator that you are using to identify the element you want to type into is correct. You can try using browser developer tools to find the correct locator of the element. 3) Incorrect wait time: Selenium uses an implicit wait time to determine how long it should wait for an element to appear before timing out. If the implicit wait time is set too low, Selenium may not have enough time to find the element before timing out. Make sure that the implicit wait time is set to a reasonable value for your test. 4) Disable of 'javascript' execution: Verify that JavaScript is enabled in the browser instance that Selenium is connecting to. 5) Incorrect value of attribute "disabled" : Make sure that the input field is not disabled. If the input field is disabled, Selenium will not be able to interact with it. 6) Incorrectly setting the focus on the element: Make sure that the element has the focus before trying to type into it. If the element doesn't have the focus, Selenium won't be able to interact with it. 7) Incorrectly handling of element to type: Try interacting with the element using the actions class instead of the sendKeys method. If after checking these, the problem persist it's best to log the request, the html of the page, locator value. This will help you understand where the problem is coming from. I hope this helps! Happy coding!
@enmanuelamaurydeleonguzman8744
@enmanuelamaurydeleonguzman8744 2 жыл бұрын
Hello, i have a question how can i used driver.close or driver.quit here?, The script open the browser but i can't see any action because it closed almost immediately. I want to see the action on the screen and for all the steps to be executed and at the end close the browser. I place the driver.close method in the base class. Appreciate your help, Ty!!!
@hakan2048
@hakan2048 3 жыл бұрын
hello, where are you running the project from? I wish you showed it too. I have done everything in the video but it is not run.
@QAUnderground
@QAUnderground 3 жыл бұрын
Hi, At the very start of the video, we go over creating the project on the Desktop called “javascript_mocha_selenium”, we then install all of our dependencies to that directory via the terminal. At the end of the video we can run our tests from the same location via “npm test ./test/homepage.js”. Thanks!
@noork8369
@noork8369 3 жыл бұрын
Great video! very simple to follow. One question however. My chrome opens and closes too quickly for me to see the test actually happen. Any idea why? P.s, I have version "chromedriver": "^91.0.1"
@gustavosiqueira1246
@gustavosiqueira1246 Жыл бұрын
I had this problem too. In my case, I put: await driver.wait(until.titleIs(title)) Before await driver.quit() Now it waits before closing.
@QAUnderground
@QAUnderground Жыл бұрын
Thanks for the assist!
@MoniraAzad
@MoniraAzad Жыл бұрын
My code is run successfully but i can't see the browser. Please suggest me how can i see the browser?
@QAUnderground
@QAUnderground Жыл бұрын
There could be a few reasons why you're not seeing the browser when you run your code. Here are a few things to check: 1) Browser is running in headless mode: Some test frameworks allow you to run the browser in headless mode, which means that it runs in the background without showing a graphical user interface. Make sure that headless mode is not enabled in your test configuration. 2) Browser instance is running on a different display: If you are running your code on a machine with multiple monitors, make sure that the browser instance is running on the same display as the one you are currently working on. 3) Incorrect window size setting: Make sure that the window size of the browser is set to something visible, some test run on maximized or minimized windows. 4) Incorrect use of driver: You are trying to run the test on an unsupported browser. Some WebDriver implementation can run on multiple browser, make sure that you are using the correct implementation. 5) Incorrect display environment variable : In some cases, you need to set the correct display environment variable to properly launch the browser. Try adjusting these settings and see if that resolves the issue. If you still have trouble, please provide more information about your test configuration and setup, that will help me to understand more about the problem and can suggest the best solution.
@willtom8146
@willtom8146 2 жыл бұрын
Got some problems with making another test case as it's error is: NoSuchSessionError: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used. With me using: await driver.quit(); driver == null; after each test.
@QAUnderground
@QAUnderground Жыл бұрын
The "NoSuchSessionError: This driver instance does not have a valid session ID" error message typically occurs when you are trying to use a WebDriver instance after it has been closed or quit. This can happen in the following situations: 1) When the browser was closed manually or by an unexpected error before calling driver.quit() 2) When driver.quit() is not being called at all 3) when driver is not getting instantiated after being nullified before the next test Here's what you can try to resolve this error: 1) Verify that await driver.quit(); is being called at the end of each test. 2) Make sure that driver = null; is used after the driver has quit. This way, the next test can instantiate a new driver. 3) Use a try-catch block around the await driver.quit(); command in case the browser crashes or closed unexpectedly I hope this helps!
@xinyichua9613
@xinyichua9613 3 жыл бұрын
Hello Im really new to Mocha and selenium and thank you for this video. I'm wondering about the driver.findElement line, why did you put [name=q] for the google search box? How does it know that it refers to the search box? I'm not understanding how find element works. Thank you once again!
@QAUnderground
@QAUnderground 3 жыл бұрын
Hi Xin Yi Chua, "name" refers to the attribute that is assigned to the element on the page. In this case, the developers assigned the name attribute the value of "q" for the search box. You can choose from several different attribute types when selecting an element (name, id, etc...). The best way to find one for an element is to inspect it using the browsers development tools. Thanks for the great question!
@boyapatiramakrishna2068
@boyapatiramakrishna2068 2 жыл бұрын
Maaaaaan Why all of you are only telling to run the code from terminal? Please tell me how to run all test cases from html page with a click of a button. We use this testing for automation also. if we develop any automation and give it to users, then they can use this by a click of a button from html page. How they can run the test cases from terminal?
@QAUnderground
@QAUnderground Жыл бұрын
Absolutely! You're right, running test cases from a terminal can be a bit intimidating for some users, especially if they're not familiar with command-line interfaces. There are a few different ways to run Selenium tests from an HTML page, one way is to use a test runner like TestNG, it has a built-in feature for running tests through an HTML interface. It allows you to create a testng.xml file, where you can specify which test cases you want to run and then run it via the TestNG plugin for Eclipse or via the command line. Another option is to use a test management tool like TestRail, It allows you to manage, track and organize your test cases, and also provides an integration with Selenium that allows you to run tests and track results directly from the web interface. Additionally, you can use the Selenium-Grid, it allows you to run your tests on multiple machines and browsers simultaneously, and also has a Hub/Node architecture where you can run your test on a remote machine and can run it via hub. Thank you for bringing this up, it's always great to consider the end-user experience and make our testing as user-friendly as possible.
@MelEllington
@MelEllington Жыл бұрын
Does not work for me. I get error: ChromeDriver could not be found on the current PATH. Please download the latest version. I have the latest version and the path is set correctly according to Chromedriver documentation at C:\bin, which is where the Chromedriver.exe is copied to.
@QAUnderground
@QAUnderground Жыл бұрын
This error occurs when Selenium is unable to find the ChromeDriver executable on your system. To resolve this issue, you will need to download the appropriate version of ChromeDriver for your system and add it to your system's PATH. Firstly, ensure that you have the correct version of Chrome installed on your system. You can check the version by navigating to chrome://settings/help in the Chrome browser. Next, download the appropriate version of ChromeDriver from the official website (chromedriver.chromium.org/home) that matches the version of Chrome you have installed. Extract the contents of the downloaded file and copy the executable to a directory that is included in your system's PATH. (or you can set the path to chrome driver in your code when initializing the driver) Finally, try running your Selenium test again to see if the error is resolved. Note: If you want to avoid versioning mismatch, you can use web driver manager package to initialize the chrome driver in your test, the package will take care of downloading and setting the path of the driver Hope this helps!
Page Object Model In Playwright With JavaScript
41:48
Mukesh otwani
Рет қаралды 8 М.
Doing This Instead Of Studying.. 😳
00:12
Jojo Sim
Рет қаралды 38 МЛН
Чёрная ДЫРА 🕳️ | WICSUR #shorts
00:49
Бискас
Рет қаралды 5 МЛН
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 20 МЛН
Easiest way | Playwright Page Object Model | Step by Step DEMO
34:10
Automation Step by Step
Рет қаралды 43 М.
Intro To JavaScript Unit Testing With Mocha JS & Chai
17:51
Traversy Media
Рет қаралды 316 М.
Complete Page Object Model (POM) using Page Factory in Selenium
31:04
Mukesh otwani
Рет қаралды 275 М.
Selenium cucumber javascript combined
35:12
Haardic '~'
Рет қаралды 15 М.
Inheritance in JavaScript - Prototypal Inheritance tutorial
20:06
Page Object Model Interview Questions and answer for Experienced Automation Tester
12:58