Everything is understandable, I wrote tests in my company based on your videos and even got a job thanks to them. I wonder how i can pass variable from one test to another in pytest, i now that is now best solution. I know there was such a thing as Namespace before, but it was removed from Pytest 4.0
Hi Robert, happy to know. You can store a value in global variable or some common location (properties) and refer from here. Can check online for more ways and examples.
I was looking for pytest and got so happy after a lesson listed from you on youtube. Writing this comment before watching as I know it would be really helpful by default Thanks Raghav :)
Raghav, Great video and explanation! Few questions if i may: 1. What frame work would you suggest to work with, UnitTest or PyTest? 2. Do you have by chance some guide/video for setup page object model with PyTest? i know you have POM video with UnitTest. Thanks again and continue with the great work!
@@RaghavPal Hello Raghav, thank you for this tutorial. Regarding the second question from Jacob, you are referencing to your website. However, I am trying to find Page Object Model done with PyTest and unfortunatelly, I am not able to find it. Same as Jacob, I know about the POM video with UnitTest but not with PyTest. Would you please advise? Thank you very much.
Well explained about the use of PyTest in a clear way. Very helpful !!! Can you just expalin a little bit about the use and purpose of "Yield" keyword?? It will be very helpful
Sir how to use it to the website where there is a captcha to type? I did like yours but it didnt wait for me to write captcha. I want to automate from excel sheet to the web browser and needed to write captcha. I am planning to automate multiple data at a time
Hi, Captcha is to prevent robots or automated scripts mimic humans. So ideally we should not automate Captcha, However there are ways to handle it. I will say check the following 1. How imp is to automate this scenario 2. Check the time and effort required 3. Check with your dev team if Captcha can be disabled in testing env 4. Check with your team if a static Captcha be provided in QA env
HI Raghav, I am working on the API testing in Python and I am unable find a solution to whitespace and any symbol that is in the json file. I am doing a data driven testing using csv file to verify data against the api call. It fails in the description due to whitespace and symbols such as ? + **. How to resolve this issue? def read_test_data_from_csv(): test_data = [] with open("datatest.csv", newline='') as csvfile: data = csv.reader(csvfile, delimiter=',') next(data) # skip header row for row in data: test_data.append(row) return test_data @pytest.mark.parametrize("id,resourcetype,source,name,concept_class,description",read_test_data_from_csv()) def test_using_csv_get_location_data_check_place_name(id,resourcetype,source,name,concept_class,description): response = requests.get(f"api/{id}") response_body = response.json() assert response.status_code == 200 assert response_body["id"] == id assert response_body["type"] == resourcetype assert response_body["source"] == source assert response_body['display_name'] == name assert response_body['concept_class'] == concept_class assert response_body['extras']['Description'] == description
Hi Raghav. Nice video and thank you for sharing. Where are the results of the test run saved, when using PyTest? Like default reports of JUnit or NUnit?
Hi Sandeep, we can add options to create and store results for e.g. to create junit styled report pytest --junitxml=path To create result log files pytest --resultlog=path You can also create html reports - pypi.org/project/pytest-html/ Can see tutorials here automationstepbystep.com/online-courses/
Hi Raghav , That was very well explained. Thanks a Lot. Can we use Webdriver Manager for browsers under Setup Method? If so can you show how can that be used.
Hi, thank you for explaining these concepts, I only have one doubt - in unittest we use unittest.testsuite to create our testsuite, then how can we build testsuite in pytest, what is the alternative for unittest.testsuite in pytest??
@@RaghavPal I have gone through it, but if that's the case then it would become mandatory that we must use unittest with pytest, in cases where testsuite is required and this also mean that we will have support of some pytest features with boilerplate code of unittest
Losing the login button ID in Inspect Elements can be frustrating, but don't worry, there are still ways to identify and interact with the button! Here are some options you can consider: 1. Look for alternative identifiers: Class names: Look for unique class names associated with the button. Often, buttons have specific class names for styling or functionality that you can use for identification. Data attributes: Many elements use custom data attributes for various purposes. Look for attributes like data-login, data-submit, or specific attributes related to the button's function. Text content: If the button has unique text content like "Log In" or "Sign In," you can use cy.contains in Cypress to locate it. Accessibility attributes: Elements often have accessibility attributes like aria-label or role that describe their purpose. Identifying buttons using these attributes can be a reliable approach. 2. Use relative positioning: If the button has a consistent relationship with other elements on the page, you can use relative positioning based on those elements. For example, you could locate the button as "the next sibling of the element with class 'header-logo'". 3. Shadow DOM exploration: Some web frameworks use Shadow DOM to encapsulate components. If you suspect the button might be hidden within Shadow DOM, you can use libraries like cypress-shadow-dom or framework-specific methods to access and interact with it.
@@RaghavPal Oh I meant that in every single of your runs, I see a -> print("Test ended") but is not actually showing at the end of the runs/logs . greetings
Thank you very much for your help I just Have a question if it possible Can I use my pytest for every Tab I open in my code I want to open tab in browser and call my pytest
@@RaghavPal Can you tell me how I make the pytest now it work perfetly but I don't know how to use it in parallel or how to work one by one Thank you again Brother
this can help www.jetbrains.com/help/pycharm/configuring-project-structure.html#:~:text=Create%20a%20content%20root%EF%BB%BF,to%20configure%20content%20roots%20for.&text=In%20the%20dialog%20that%20opens,desired%20directory%20and%20click%20OK.
Hi Chandana Selenium with Python: Selenium is a popular open-source automation framework for web application testing, and Python is a widely used programming language in the automation testing domain. The combination of Selenium and Python provides a powerful toolset for automating web testing tasks The market for Selenium with Python is quite strong, as many companies and organizations leverage these technologies for their web application testing needs. Python's simplicity, readability, and extensive libraries make it a preferred choice for automation testers. Therefore, learning Selenium with Python can be beneficial in terms of career opportunities and market demand. Robot Framework: Robot Framework is another popular open-source automation framework that offers a keyword-driven approach for test automation. It provides a simple and readable syntax that allows testers to create test cases using keywords and reusable test libraries. Robot Framework supports various test automation aspects, including web testing, API testing, and mobile testing. It has a vibrant and active community, which contributes to its continuous growth and improvement The market for Robot Framework is also promising, with many organizations adopting it for their automation testing needs. Its keyword-driven approach, easy-to-read syntax, and extensibility make it appealing to both technical and non-technical users. The versatility of Robot Framework, allowing integration with other tools and technologies, further adds to its market value.
Both are good and depends on needs. No of jobs with Selenium Java are more but the skills available are also huge. If you can learn Selenium with Python that will help a lot.
Hey Raghav, Very detailed and very illustrative. I followed your 14 videos on selenium with Python; and was playing around with pytest. But got stuck in a situation, where I am trying to use or call another user defined module into my python file. Below error is always been thrown. I googled and few suggested to remove __init__.py file and then it will work. But that file is not getting deleted because some dependencies. (venv) C:\Users\arkaj\PycharmProjects\SampleProject1\TestCases>pytest test_userlogin_TC03.py ============================test session starts ============================= platform win32 -- Python 3.7.1, pytest-3.9.3, py-1.7.0, pluggy-0.8.0 rootdir: C:\Users\arkaj\PycharmProjects\SampleProject1\TestCases, inifile: plugins: allure-adaptor-1.7.10 collected 0 items / 1 errors ==============================ERRORS ==================================== ___________________ ERROR collecting test_userlogin_TC03.py ___________________ ImportError while importing test module 'C:\Users\arkaj\PycharmProjects\SampleProject1\TestCases\test_userlogin_TC03.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: test_userlogin_TC03.py:4: in import Screenshots E ModuleNotFoundError: No module named 'Screenshots' Can you please help. Strange thing is that when I am importing in my code, it is getting imported but when trying to run with pytest then above error is thrown. Please suggest.
Hi Arkajyoti, I have shown the solution in this video from ruclips.net/video/BURK7wMcCwU/видео.html. Please check. I have the complete course on Udemy here - www.udemy.com/selenium-python-step-by-step-for-beginners/ User Coupon - DISCOUNT_UDEMY
hi sir after installation of pytest and checking the version it is still giving me below error C:\Users\91956>pytest 'pytest' is not recognized as an internal or external command, operable program or batch file.
Shubham Here are a few steps you can follow to resolve this issue: 1. Install pytest in PyCharm: - Open PyCharm. - Go to File > Settings > Project: \ > Python Interpreter. - In the search bar, type "selenium" and click on the "+" button to install it². 2. Check Python Interpreter: - Make sure that the Python interpreter you're using in PyCharm is the same one where you installed pytest. - You can verify this by going to File > Settings > Project: \ > Python Interpreter and ensuring that the correct interpreter is selected. 3. Verify Selenium Installation: - Sometimes, issues can arise due to missing or incorrect installations. - Open a terminal/command prompt and run the following command to check if Selenium is installed: ``` pip show selenium ``` - If it's not installed, you can install it using: ``` pip install selenium ``` 4. Restart PyCharm: - After making any changes, restart PyCharm to ensure that the changes take effect. 5. Path Environment Variable: - Ensure that the directory containing the pytest executable is included in your system's PATH environment variable. - You can add the path to the directory where pytest is installed to your system's PATH. 6. Check for Typos: - Double-check that you're running the correct command. It should be: ``` pytest ``` - Make sure there are no typos or misspellings. --
Hello Raghav, thanks for your videos.They are very informative. Can you please also do this using eclipse as in eclipse we don't have terminal .Also when I run through command prompt , I don't get any results printed . Do I need to choose pyCharm or continue using Eclipse IDE .Kindly guide , I also want to keep using the same IDE to link my project to Jenkins and Maven.
Hi Swastika, if you have installed python on your system and added pydev in eclipse, you can continue with eclipse. Although as PyCharm is built for python projects, it may be more easier to follow. You can just install it and get started
Thanks, Raghav for the session. Once again easy to understand, and it is really helpfully helpful. is there a session related to the Pytest, Gherkin - BDD framework. Please guide
I am facing an error while running my code. The browser opens but closes within few seconds without getting the URL of the website. How I can share my code with you?
down vote favorite I installed a virtual environment and then inside installed selenium, py.test and webdriverdownloader furthermore I set up a system environment variable and added path to geckodriver But when I executed Python test from command line it fails with error : geckodriver executable needs to be in path what went wrong from my side?
Hi Joel. pls check the following: 1. pytest was installed properly: on cmd run pip check pytest 2. ensure the name of python file has format test_*.py OR *_test.py 3. the function name has test_ in the start of the name 4. In case you are defining a class, its name should start with Test 5. On command-line you have to run it with command pytest or py.test or python -m pytest (as shown in video)
Cannot open Local Terminal Failed to start [powershell.exe] in C:/Users/Putty/PycharmProjects/pythonProject/Q45M3/program/Pytest/pytest Error running process: CreateProcess failed. Code 2 See IDE log (Help | Show Log in Explorer) for the details. Im observing this error when i opened terminal I installed pytest in command prompt as shown in video
Hi Raghav, very good tutorial, appreciate it. My problem for using pytest is: I cannot import pytest, I checked my installation, everything is doing as per your video, please help on this. Thanks Tony
Hi Lu Tony, as per your other comment you resolved it. You can just reply to the same comment to set context, I am putting your comment here: Hi Raghav, I just changed my project settings > project interpreter> inherit global site-packages, which solve the problem. Thanks
@@RaghavPal Thank you this navigation solved my issue. Just to add after above steps. 1. Go to 'Python Interpreter' in your project. 2. Click on Setting icon. 3. New Env will be there bydefault let it be 4.In Location path just add any character to end. It creates new folder(virtual environment) like mine was 'venv' and I changed to 'venva' added a letter. 5. Click two checkboxes below path to inherit and make available. 6.Now you'll able to see 'ok' button enabled which was earlier disabled, click and its done. 7.you' can see your new virtual Env folder in your structure.. ((PS : I was getting Error "ModuleNotFoundError: No module named 'pytest' ") and it was solved
when i write this (venv) C:\Users\khirod\PycharmProjects\orangeHM>allure serve reports/allure-reports 'allure' is not recognized as an internal or external command, operable program or batch file. (venv) C:\Users\khirod\PycharmProjects\orangeHM> i am getting this message i have installed allure-pytest what to do
Hi, This is what has helped others. Pls check We have to manual installation of Allure docs.qameta.io/allure/ and set complete path of directory of test executed folder 1. Go to dl.bintray.com/qameta/generic/io/qameta/allure/allure 2. Download the zip and unzip it inside the bat folder that is in your python installation, e.g. C:\Libs\Python\bat 3. Go to edit system variable and in system section look for PATH variable and add the bin path of that allure in the path, e.g. C:\Libs\Python\bat\allure-2.7.0\bin\ 4. close and open console and it should work :) ===================================== I resolved this issue. Issue is Allure is not installed in our system that is why we facing this issue.Steps how to fix this issue fro windows 10 OS: 1. Open Power Shell and run this command : iex (new-object net.webclient).downloadstring('get.scoop.sh') Note: if you get an error you might need to change the execution policy (i.e. enable Powershell) with Set-ExecutionPolicy RemoteSigned -scope CurrentUser 2. After installing Allure add environment variable under System Variable : C:\Users\test123\scoop\apps\allure\current\bin 3. Restart your machine and allure serve /path of file will work.
Hi raghav How can I create exe for the parallel testing with pytest. I am trying to automate file download in parallel proceess for the team . I goggled and tried still no luck. Can you kindly help advise?
@@RaghavPal Yes, i want to run the parallel downloads at the users PC where python is not installed. My code is in 2 of the .py files which i am currently running codes at my own PC and i am thinking how can i deploy this to the users . Name of my first py file is TkintersApp.py and has the below code. import pytest from selenium import webdriver from selenium.webdriver.common.keys import Keys from test_twotest import test_first from test_twotest import test_second def RunBoth(): #pytest.main(["-s","-v","-n 3"]) pytest.main(["test_twotest.py","-n 2"])
from tkinter import * window = Tk() window.configure(bg="lightblue") window.geometry("300x150+120+120") window.resizable(width=False, height=False) window.title("IFW Form") entry1 = Entry(window) entry2 = Entry(window,show="*") entry1.grid(row=0,column=1) entry2.grid(row=1,column=1) LoginButton = Button(window,text="Login", command=RunBoth, height=1,width=12) LoginButton.grid(row=2,column=0) window.mainloop() Name of the second .py file is test_twotest and has the below code. from selenium import webdriver from selenium.webdriver.common.keys import Keys def test_first(): driver = webdriver.Chrome("C:\\Selenium Drivers\\chromedriver.exe") driver.get("www.facebook.com") def test_second():
Hi Lukky, I have a Udemy course on it www.udemy.com/selenium-python-step-by-step-for-beginners/ You can try coupon code - DISCOUNT_UDEMY_SE For other courses - automationstepbystep.com/909-2/online-course
Hi Raghav, Thank you for the video, it is really helpful. When I created more than one module, it did not run from command line using any of the commands given in the video, i.e. pytest or python -m pytest The error is: python cannot find related modules imported in my test file.... Thank you
Again depends, generally, we see Dev paid little more than Testers of same experience, but as I said in my earlier comment, if you have real passion for testing and you can get some really in demand skills, you can get paid higher.
Hi Syed, are you behind corporate firewall, If yes you can try this command pip install --proxy domain\user:password@proxyaddress:port package github.com/pypa/pip/issues/4417
Class will help you create objects and use Object Oriented Programming.. You can watch Python basics videos for more information - automationstepbystep.com/
Structure of my project: RT_python: .idea drivers program Project: POMRT: Pages: Home_Page.py Tests: test_home.py reports venv I have code - prntscr.com/l6lr3q But when I try to run in a command line my test, I receive error - prntscr.com/l6luem
Glad to know that . Use Pytest, its most commonly used for frameworks and you can use many other features. You can also check my Udemy course on complete framework creation - www.udemy.com/selenium-python-step-by-step-for-beginners/ Use coupon - DISCOUNT_UDEMY
Thats what I said, see ultimately the otp must be stored somewhere, if you have an api to call and get the value, you will not have to do the email step as it will take some time and may be flaky
Hi Raghav, Thanks for the Video. I have two issues, can you help me out please?: 1. pytest module is not available to import: prntscr.com/p6gf1w 2. Global driver variable shows error : prntscr.com/p6ghnl
Hi Amir, 1. Check the required libraries are imported in the project PyCharm (File in windows) -> Preferences (Settings on Windows) -> Project -> Project InterpreterHere you can see list of libaries You can also click on '+' sign to add new library (python module) 2. Why do you need it global. Also check this.confluence.jetbrains.com/display/PYH/PyCharm+193.2956.40+Release+Notes
Traceback (most recent call last): File "sample.py", line 1, in from selenium import webdriver ImportError: No module named selenium I am facing this error. Can you please tell me how to resolve this issue?
Hi Arijit, I have shown the solution in this video from ruclips.net/video/BURK7wMcCwU/видео.html. Please check. stackoverflow.com/questions/10253826/path-issue-with-pytest-importerror-no-module-named-yadayadayada On command line go one folder up from the folder from where you have any imports in your script For example this is your project structure: ProjectFolder/Example/Demo/file.py In you file.py you have your code with import statements. Suppose one of the import is from Demo folder So on command line goto folder Example (parent of demo folder) and then say command python -m unittest Demo.file . (note do not give .py extension)
Hi Pallavi, nose library can be used to extend the testing framework to make testing easier and efficient. I will plan to have a dedicated session on this
Exactly what i was looking for !... Thank you sir ... I highly recommend for beginners in python frame work....
You are most welcome
I want complete pytest framework
well explained and easy to follow and understand. Thank you Raghav.
Most welcome
Everything is understandable, I wrote tests in my company based on your videos and even got a job thanks to them. I wonder how i can pass variable from one test to another in pytest, i now that is now best solution. I know there was such a thing as Namespace before, but it was removed from Pytest 4.0
Hi Robert, happy to know. You can store a value in global variable or some common location (properties) and refer from here. Can check online for more ways and examples.
Raghav you're the master of straightforward tutorials, thanks.
Glad you like them Federico
Very precise and understandable. Now I am going to watch other tutorials of yours as well.
Awesome, thank you Ayushi
I was looking for pytest and got so happy after a lesson listed from you on youtube. Writing this comment before watching as I know it would be really helpful by default
Thanks Raghav :)
You're very welcome!
Thanks a lot Raghav for very informatory video.
So nice of you Anupriya
Perfect! Thank you very much for your lessons!
Most welcome
Thanks a lot, Raghav! Great lesson!!!
Most welcome
Raghav, Great video and explanation!
Few questions if i may:
1. What frame work would you suggest to work with, UnitTest or PyTest?
2. Do you have by chance some guide/video for setup page object model with PyTest? i know you have POM video with UnitTest.
Thanks again and continue with the great work!
Hi Jacob, thanks for watching
1. Pytest
2. You can check here - automationstepbystep.com/online-courses/
@@RaghavPal Hello Raghav, thank you for this tutorial. Regarding the second question from Jacob, you are referencing to your website. However, I am trying to find Page Object Model done with PyTest and unfortunatelly, I am not able to find it. Same as Jacob, I know about the POM video with UnitTest but not with PyTest. Would you please advise? Thank you very much.
Awesome raghav highly appreciate for clear cut explanation
Thanks Kiran
Exactly what I was looking for..
Thank you Sir
You're welcome Rabz
Well explained, Thank you for sharing the knowledge. Keep going on.
Most welcome Antriksh
Well explained about the use of PyTest in a clear way. Very helpful !!!
Can you just expalin a little bit about the use and purpose of "Yield" keyword?? It will be very helpful
I will plan a session Hassan
Nice, I got some knowledge from this video..thank you
Nice to know that
Thank you I was looking for that tutorial. Now I can learn step by step :)
You’re welcome 😊Neeraj
Thanks, understood clearly
Most welcome
Thank you so much for selenium with python course
You're welcome Bhavika
Thanks so much for all your step by step sessions
You're welcome Joel
Thanks a lot, Mr. Raghav! Your videos are easy to understand. Already subscribed and liked!
You're welcome Albino. Thanks for watching
What is better to use for easier and simple Page Object Model implementation: pyttest or unittest?
Go with Pytest
Raghav your post is very informative and easy to understand, thanks alot :)
You're welcome Amar
Sir how to use it to the website where there is a captcha to type? I did like yours but it didnt wait for me to write captcha.
I want to automate from excel sheet to the web browser and needed to write captcha.
I am planning to automate multiple data at a time
Hi, Captcha is to prevent robots or automated scripts mimic humans. So ideally we should not automate Captcha, However there are ways to handle it. I will say check the following
1. How imp is to automate this scenario
2. Check the time and effort required
3. Check with your dev team if Captcha can be disabled in testing env
4. Check with your team if a static Captcha be provided in QA env
Great job Raghav,Curious to know more about different frameworks.
Thanks for watching
HI Raghav, I am working on the API testing in Python and I am unable find a solution to whitespace and any symbol that is in the json file. I am doing a data driven testing using csv file to verify data against the api call. It fails in the description due to whitespace and symbols such as ? + **. How to resolve this issue?
def read_test_data_from_csv():
test_data = []
with open("datatest.csv", newline='') as csvfile:
data = csv.reader(csvfile, delimiter=',')
next(data) # skip header row
for row in data:
test_data.append(row)
return test_data
@pytest.mark.parametrize("id,resourcetype,source,name,concept_class,description",read_test_data_from_csv())
def test_using_csv_get_location_data_check_place_name(id,resourcetype,source,name,concept_class,description):
response = requests.get(f"api/{id}")
response_body = response.json()
assert response.status_code == 200
assert response_body["id"] == id
assert response_body["type"] == resourcetype
assert response_body["source"] == source
assert response_body['display_name'] == name
assert response_body['concept_class'] == concept_class
assert response_body['extras']['Description'] == description
Hi Pete, You can use some python json library to ensure the json format is correct
Hello sir, by using python pytest we can open installed applications?....how we will use for browser application that is selenium
Hi Gayatri, you just need to add Selenium lib and use its functions as shown
Hi Raghav, I just changed my project settings > project interpreter> inherit global site-packages, which solve the problem. Thanks
Glad to know that.
Hello Raghav, Do you have any live tutorial coming up for python selenium and pycharm with pytest framework?
Hi Shruthi
I have recently started Python Selenium on Pycharm 2023. Check here - automationstepbystep.com/
Hi Raghav. Nice video and thank you for sharing. Where are the results of the test run saved, when using PyTest? Like default reports of JUnit or NUnit?
Hi Sandeep, we can add options to create and store results for e.g. to create junit styled report
pytest --junitxml=path
To create result log files
pytest --resultlog=path
You can also create html reports - pypi.org/project/pytest-html/
Can see tutorials here automationstepbystep.com/online-courses/
And thanks for ur vedios that helps us a lot.
You're welcome
Great video, really helpful, thank you!!
Glad it was helpful Maria
Very useful Bro...nice👍
Thanks Varun
Awesome explanation Sir...
Happy to know it helped Bhumitra
Hi Raghav ,
That was very well explained. Thanks a Lot.
Can we use Webdriver Manager for browsers under Setup Method? If so can you show how can that be used.
Hi Sireesha, you can as long as you are able to connect with the required class. I will plan a session
@@RaghavPal Thanks Rahav!!
Sir can we use pytest with POM?
Yes Harish
@@RaghavPal Thank you sir
wow,good code for beginners.. it is working perfectly. Can I add HTML runner on this code? i
Yes, you can try
@@RaghavPal I tried with import unittest and unittest.main (.......). It is showing the error, unnittest not defined
thanx, very helpful
Glad it was helpful!
Testing or developer which course is better in future
Both are good and depends on your interests and passion. If you want to go in testing consider automation testing
Hi, thank you for explaining these concepts, I only have one doubt - in unittest we use unittest.testsuite to create our testsuite, then how can we build testsuite in pytest, what is the alternative for unittest.testsuite in pytest??
Hi Vikram, this can help - docs.pytest.org/en/stable/unittest.html
@@RaghavPal Thank you for your help!
@@RaghavPal I have gone through it, but if that's the case then it would become mandatory that we must use unittest with pytest, in cases where testsuite is required and this also mean that we will have support of some pytest features with boilerplate code of unittest
Let me explore more on that Vikram and will update or create a session
hey, the login button id is not longer there on the inspect elements. what should I use instead?
Losing the login button ID in Inspect Elements can be frustrating, but don't worry, there are still ways to identify and interact with the button! Here are some options you can consider:
1. Look for alternative identifiers:
Class names: Look for unique class names associated with the button. Often, buttons have specific class names for styling or functionality that you can use for identification.
Data attributes: Many elements use custom data attributes for various purposes. Look for attributes like data-login, data-submit, or specific attributes related to the button's function.
Text content: If the button has unique text content like "Log In" or "Sign In," you can use cy.contains in Cypress to locate it.
Accessibility attributes: Elements often have accessibility attributes like aria-label or role that describe their purpose. Identifying buttons using these attributes can be a reliable approach.
2. Use relative positioning:
If the button has a consistent relationship with other elements on the page, you can use relative positioning based on those elements. For example, you could locate the button as "the next sibling of the element with class 'header-logo'".
3. Shadow DOM exploration:
Some web frameworks use Shadow DOM to encapsulate components. If you suspect the button might be hidden within Shadow DOM, you can use libraries like cypress-shadow-dom or framework-specific methods to access and interact with it.
@@RaghavPal Thanks for the suggestions.
Hi! Why I'm not able to se the prints() During the execution?
Hi Teodoro, let me know the time in the video and I will check
@@RaghavPal Oh I meant that in every single of your runs, I see a -> print("Test ended") but is not actually showing at the end of the runs/logs
. greetings
Thank you very much for your help I just Have a question if it possible Can I use my pytest for every Tab I open in my code I want to open tab in browser and call my pytest
Yes, you should be able to
@@RaghavPal Can you tell me how I make the pytest now it work perfetly but I don't know how to use it in parallel or how to work one by one
Thank you again Brother
I will plan to add a session, Check this for now - stackoverflow.com/questions/45733763/pytest-run-tests-parallel
@@RaghavPal Thank you so much brother
sir my pytest not collect the items (it's showing Collecting 0 items when i run my test)
how to fix this? plz help😕
Hi Venkatesh, will need to check details and logs
@@RaghavPal Sir my installation setup was correct (i think it's root dir fault ) How to i set correct root dir in my pycharm explain?
this can help www.jetbrains.com/help/pycharm/configuring-project-structure.html#:~:text=Create%20a%20content%20root%EF%BB%BF,to%20configure%20content%20roots%20for.&text=In%20the%20dialog%20that%20opens,desired%20directory%20and%20click%20OK.
hi, selenium python robot framework how is the market?
Hi Chandana
Selenium with Python:
Selenium is a popular open-source automation framework for web application testing, and Python is a widely used programming language in the automation testing domain. The combination of Selenium and Python provides a powerful toolset for automating web testing tasks
The market for Selenium with Python is quite strong, as many companies and organizations leverage these technologies for their web application testing needs. Python's simplicity, readability, and extensive libraries make it a preferred choice for automation testers. Therefore, learning Selenium with Python can be beneficial in terms of career opportunities and market demand.
Robot Framework:
Robot Framework is another popular open-source automation framework that offers a keyword-driven approach for test automation. It provides a simple and readable syntax that allows testers to create test cases using keywords and reusable test libraries. Robot Framework supports various test automation aspects, including web testing, API testing, and mobile testing. It has a vibrant and active community, which contributes to its continuous growth and improvement
The market for Robot Framework is also promising, with many organizations adopting it for their automation testing needs. Its keyword-driven approach, easy-to-read syntax, and extensibility make it appealing to both technical and non-technical users. The versatility of Robot Framework, allowing integration with other tools and technologies, further adds to its market value.
Which is better course selenium with java or selenium with python
Both are good and depends on needs. No of jobs with Selenium Java are more but the skills available are also huge. If you can learn Selenium with Python that will help a lot.
Selenium with python automation testing is better in future? Please reply
Hi Raveendra, yes Selenium with Python is a v good skill and is also in demand.
how write about Gmail test scripts by using pytest, and calling to into other files. Help me
Hi Vali, will need to check online for this
Can we use TestNG with Python?,is it possible? if not possible which one is better.
Hi, can check this stackoverflow.com/questions/45323248/how-to-achieve-testng-like-feature-in-python-selenium-or-add-multiple-unit-test
I liked and subscribed your channel my friend :)
thanks
Hey Raghav,
Very detailed and very illustrative.
I followed your 14 videos on selenium with Python; and was playing around with pytest.
But got stuck in a situation, where I am trying to use or call another user defined module into my python file.
Below error is always been thrown. I googled and few suggested to remove __init__.py file and then it will work. But that file is not getting deleted because some dependencies.
(venv) C:\Users\arkaj\PycharmProjects\SampleProject1\TestCases>pytest test_userlogin_TC03.py
============================test session starts =============================
platform win32 -- Python 3.7.1, pytest-3.9.3, py-1.7.0, pluggy-0.8.0
rootdir: C:\Users\arkaj\PycharmProjects\SampleProject1\TestCases, inifile:
plugins: allure-adaptor-1.7.10
collected 0 items / 1 errors
==============================ERRORS ====================================
___________________ ERROR collecting test_userlogin_TC03.py ___________________
ImportError while importing test module 'C:\Users\arkaj\PycharmProjects\SampleProject1\TestCases\test_userlogin_TC03.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test_userlogin_TC03.py:4: in
import Screenshots
E ModuleNotFoundError: No module named 'Screenshots'
Can you please help. Strange thing is that when I am importing in my code, it is getting imported but when trying to run with pytest then above error is thrown.
Please suggest.
Hi Arkajyoti,
I have shown the solution in this video from ruclips.net/video/BURK7wMcCwU/видео.html. Please check. I have the complete course on Udemy here - www.udemy.com/selenium-python-step-by-step-for-beginners/
User Coupon - DISCOUNT_UDEMY
hi sir
after installation of pytest and checking the version it is still giving me below error
C:\Users\91956>pytest
'pytest' is not recognized as an internal or external command,
operable program or batch file.
Shubham
Here are a few steps you can follow to resolve this issue:
1. Install pytest in PyCharm:
- Open PyCharm.
- Go to File > Settings > Project: \ > Python Interpreter.
- In the search bar, type "selenium" and click on the "+" button to install it².
2. Check Python Interpreter:
- Make sure that the Python interpreter you're using in PyCharm is the same one where you installed pytest.
- You can verify this by going to File > Settings > Project: \ > Python Interpreter and ensuring that the correct interpreter is selected.
3. Verify Selenium Installation:
- Sometimes, issues can arise due to missing or incorrect installations.
- Open a terminal/command prompt and run the following command to check if Selenium is installed:
```
pip show selenium
```
- If it's not installed, you can install it using:
```
pip install selenium
```
4. Restart PyCharm:
- After making any changes, restart PyCharm to ensure that the changes take effect.
5. Path Environment Variable:
- Ensure that the directory containing the pytest executable is included in your system's PATH environment variable.
- You can add the path to the directory where pytest is installed to your system's PATH.
6. Check for Typos:
- Double-check that you're running the correct command. It should be:
```
pytest
```
- Make sure there are no typos or misspellings.
--
Hi Sir, Please let me know how to integrate pycham code with jenkins.
Hi Konda, In jenkins you can add the command from your pycharm project. That will be the best and straight-forward way.
Is this video comes under UI automation please reply
Yes Neha
Am not able to load the internal web applications using pytest.Can u please tell what the issue might be.It works fine with Java selenium.
Hi Sajina, will have to see your setup and environment for that.
Hi Raghav,
Do you have any github repo from which I can get code displayed in videos?
Thanks !
Hi Mayur, can check this - github.com/Raghav-Pal/PythonAutomationFramework_1
Hello Raghav, thanks for your videos.They are very informative. Can you please also do this using eclipse as in eclipse we don't have terminal .Also when I run through command prompt , I don't get any results printed . Do I need to choose pyCharm or continue using Eclipse IDE .Kindly guide , I also want to keep using the same IDE to link my project to Jenkins and Maven.
Hi Swastika, if you have installed python on your system and added pydev in eclipse, you can continue with eclipse. Although as PyCharm is built for python projects, it may be more easier to follow. You can just install it and get started
@@RaghavPal ..Thank you for suggesting..
Thanks, Raghav for the session. Once again easy to understand, and it is really helpfully helpful. is there a session related to the Pytest, Gherkin - BDD framework. Please guide
Not yet Srikanth, but will create in some time. You can find all here - automationstepbystep.com/
Thanks Raghav!
Hi Ragav, Can we do a customised automation framework in Python ?
Hi Raghul, there is a course on Udemy on that - pls check - automationstepbystep.com/udemy-discounts/
I am facing an error while running my code. The browser opens but closes within few seconds without getting the URL of the website. How I can share my code with you?
Hi Hassan, check if you are using the same version of browser driver as the browser ver on your system, also check other related comments
Sir, one request kindly do a video for one strong frame work full on any specific website please .. For eg: Orange HRM end to end frame work please.
Sure, I will do
Is this "global" driver approach standard?
Hi Peter, You can either make it global or inherit the class (inheritance)
down vote
favorite
I installed a virtual environment and then inside installed selenium, py.test and webdriverdownloader furthermore I set up a system environment variable and added path to geckodriver
But when I executed Python test from command line it fails with error : geckodriver executable needs to be in path
what went wrong from my side?
Hi, try to provide absolute path for gecko driver
Can you help, after creating functions I get "Process finished with exit code 0" but it didn't run.
Hi Joel. pls check the following:
1. pytest was installed properly: on cmd run pip check pytest
2. ensure the name of python file has format test_*.py OR *_test.py
3. the function name has test_ in the start of the name
4. In case you are defining a class, its name should start with Test
5. On command-line you have to run it with command pytest or py.test or python -m pytest (as shown in video)
I followed step by step, could it be the path for my webdriver. Before defining the function it ran fine and smooth.
Do you get any logs for this.
Pls check the video again, just in case you have missed anything.
@@RaghavPal Thanks for your reply. No logs . Do I have to Enable pytest as Default test runner from the Settings/Tools ?
Hi Joel, if you try to run from command line with -v flag:
pytest -v
you should get some logs & information.
Pls check
Cannot open Local Terminal
Failed to start [powershell.exe] in C:/Users/Putty/PycharmProjects/pythonProject/Q45M3/program/Pytest/pytest
Error running process: CreateProcess failed. Code 2
See IDE log (Help | Show Log in Explorer) for the details.
Im observing this error when i opened terminal
I installed pytest in command prompt as shown in video
Hi Supriya, pls check this youtrack.jetbrains.com/issue/IDEA-275325
Can also try to use a diff version
Hi Raghav, very good tutorial, appreciate it.
My problem for using pytest is: I cannot import pytest, I checked my installation, everything is doing as per your video, please help on this.
Thanks
Tony
Hi Lu Tony, as per your other comment you resolved it. You can just reply to the same comment to set context, I am putting your comment here:
Hi Raghav, I just changed my project settings > project interpreter> inherit global site-packages, which solve the problem. Thanks
@@RaghavPal Thank you this navigation solved my issue. Just to add after above steps.
1. Go to 'Python Interpreter' in your project.
2. Click on Setting icon.
3. New Env will be there bydefault let it be
4.In Location path just add any character to end. It creates new folder(virtual environment) like mine was 'venv' and I changed to 'venva' added a letter.
5. Click two checkboxes below path to inherit and make available.
6.Now you'll able to see 'ok' button enabled which was earlier disabled, click and its done.
7.you' can see your new virtual Env folder in your structure..
((PS : I was getting Error "ModuleNotFoundError: No module named 'pytest' ") and it was solved
when i write this
(venv) C:\Users\khirod\PycharmProjects\orangeHM>allure serve reports/allure-reports
'allure' is not recognized as an internal or external command,
operable program or batch file.
(venv) C:\Users\khirod\PycharmProjects\orangeHM>
i am getting this message
i have installed allure-pytest
what to do
Hi, This is what has helped others. Pls check
We have to manual installation of Allure
docs.qameta.io/allure/
and set complete path of directory of test executed folder
1. Go to dl.bintray.com/qameta/generic/io/qameta/allure/allure
2. Download the zip and unzip it inside the bat folder that is in your python installation, e.g. C:\Libs\Python\bat
3. Go to edit system variable and in system section look for PATH variable and add the bin path of that allure in the path, e.g. C:\Libs\Python\bat\allure-2.7.0\bin\
4. close and open console and it should work :)
=====================================
I resolved this issue. Issue is Allure is not installed in our system that is why we facing this issue.Steps how to fix this issue fro windows 10 OS:
1. Open Power Shell and run this command : iex (new-object net.webclient).downloadstring('get.scoop.sh')
Note: if you get an error you might need to change the execution policy (i.e. enable Powershell) with Set-ExecutionPolicy RemoteSigned -scope CurrentUser
2. After installing Allure add environment variable under System Variable : C:\Users\test123\scoop\apps\allure\current\bin
3. Restart your machine and allure serve /path of file will work.
Hi sir ,am getting module 'unittest' has no attribute 'testcase'
Hi Shilpa, can you try diff ver of pytest and check. Also check this
github.com/coala/coala-bears/issues/2862
is there any course of what one QA Tester has to know in database? practice
Not a separate course yet
Hi raghav
How can I create exe for the parallel testing with pytest. I am trying to automate file download in parallel proceess for the team . I goggled and tried still no luck. Can you kindly help advise?
Hi Jalal, you want to create exe file of the project? I will like you know your scenario for this.
@@RaghavPal Yes, i want to run the parallel downloads at the users PC where python is not installed.
My code is in 2 of the .py files which i am currently running codes at my own PC and i am thinking how can i deploy this to the users .
Name of my first py file is TkintersApp.py and has the below code.
import pytest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from test_twotest import test_first
from test_twotest import test_second
def RunBoth():
#pytest.main(["-s","-v","-n 3"])
pytest.main(["test_twotest.py","-n 2"])
from tkinter import *
window = Tk()
window.configure(bg="lightblue")
window.geometry("300x150+120+120")
window.resizable(width=False, height=False)
window.title("IFW Form")
entry1 = Entry(window)
entry2 = Entry(window,show="*")
entry1.grid(row=0,column=1)
entry2.grid(row=1,column=1)
LoginButton = Button(window,text="Login", command=RunBoth, height=1,width=12)
LoginButton.grid(row=2,column=0)
window.mainloop()
Name of the second .py file is test_twotest and has the below code.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
def test_first():
driver = webdriver.Chrome("C:\\Selenium Drivers\\chromedriver.exe")
driver.get("www.facebook.com")
def test_second():
driver = webdriver.Chrome("C:\\Selenium Drivers\\chromedriver.exe")
driver.get("www.facebook.com")
You should be using Version control system for this
@@RaghavPal thanks for the response sir, can you please direct me where can I get the used case for this.
very nice
Thanks
Sir can you create a POM project using pytest ..
Yes, you can Romita.ruclips.net/p/PLhW3qG5bs-L9JjtXx-adxWdbjaxeRhi7h
El mejor :)
Gracias
Need to explain yield class some more
I will do a session
Thank You 🙂
Just done my first pytest 👍👍
most welcome
Can you in the future deal with of advice on how to interact with like a flight or hotel reservation filters in Python?
I will try to take that into consideration Joel
great, thx man
Most welcome
global drive is showing error , driver is not defined . Can you please help ?
Hi Satyanarayan, pls check if you have imported the libraries properly. Cross check with the video
Pretty cool! :)
thanks for watching
sir you have udemy course for Pytest ?
Hi Ayyaj, you can check all Udemy courses here - automationstepbystep.com/udemy-discounts/
Hi raghav could you please make a vedio on python selenium.
Hi Lukky, I have a Udemy course on it
www.udemy.com/selenium-python-step-by-step-for-beginners/
You can try coupon code - DISCOUNT_UDEMY_SE
For other courses - automationstepbystep.com/909-2/online-course
How many max chrome browser can run in parallel using pytest?
Hi Jalal it depends on your system configurations
@@RaghavPal thanks for response sir, how can I check that, can you please advise?
By system configuration, I mean your RAM, CPU capacity etc. Runing more threads in parallel will require more cpu capacity, memory etc.
@@RaghavPal ok thanks
Hi Raghav, Thank you for the video, it is really helpful.
When I created more than one module, it did not run from command line using any of the commands given in the video, i.e. pytest or python -m pytest
The error is: python cannot find related modules imported in my test file....
Thank you
Hi Ahmed, pls check this , there is some useful info here - stackoverflow.com/questions/24722212/python-cant-find-module-in-the-same-folder
Good session
Thanks Pratik
Perfect bro
Your mail ID please.. My number 9986076786
Hi Prahallad, Thanks for watching, You can put your query and messages here, I check the messages here more often than on emails
How can I express more.. Thank you Sooooo much.
You're welcome. Do share your knowledge with others
super
Thank you
Salary variance tester and developer?
Again depends, generally, we see Dev paid little more than Testers of same experience, but as I said in my earlier comment, if you have real passion for testing and you can get some really in demand skills, you can get paid higher.
when i'm trying to download pytest i'm facing issues connection to PyPi.org Timed Out
Hi Syed, are you behind corporate firewall, If yes you can try this command
pip install --proxy domain\user:password@proxyaddress:port package
github.com/pypa/pip/issues/4417
why we need to use class, when we can do it with functions.
Class will help you create objects and use Object Oriented Programming.. You can watch Python basics videos for more information - automationstepbystep.com/
Hi.
How I can import file when use pytest?
I always have a Error
prntscr.com/l6h326 - screen
Hi, will need to see your steps and error logs
Structure of my project:
RT_python:
.idea
drivers
program
Project:
POMRT:
Pages:
Home_Page.py
Tests:
test_home.py
reports
venv
I have code - prntscr.com/l6lr3q
But when I try to run in a command line my test, I receive error - prntscr.com/l6luem
I solved problem with help
"sys.path.insert(0,'../../..')"
What you can advice? Use pytest or unittest?
Glad to know that .
Use Pytest, its most commonly used for frameworks and you can use many other features.
You can also check my Udemy course on complete framework creation - www.udemy.com/selenium-python-step-by-step-for-beginners/
Use coupon - DISCOUNT_UDEMY
otp is come in mail for login->give a video for this
Try checking with your dev team, can you do that with API
@@RaghavPal OTP api workwell i require open a mail after that get a OTP
Thats what I said, see ultimately the otp must be stored somewhere, if you have an api to call and get the value, you will not have to do the email step as it will take some time and may be flaky
Hi Raghav, Thanks for the Video. I have two issues, can you help me out please?:
1. pytest module is not available to import: prntscr.com/p6gf1w
2. Global driver variable shows error : prntscr.com/p6ghnl
Hi Amir,
1. Check the required libraries are imported in the project
PyCharm (File in windows) -> Preferences (Settings on Windows) -> Project -> Project InterpreterHere you can see list of libaries
You can also click on '+' sign to add new library (python module)
2. Why do you need it global. Also check this.confluence.jetbrains.com/display/PYH/PyCharm+193.2956.40+Release+Notes
@@RaghavPal Thank you. I have liked and subscribed to your channel.
Traceback (most recent call last):
File "sample.py", line 1, in
from selenium import webdriver
ImportError: No module named selenium
I am facing this error. Can you please tell me how to resolve this issue?
Hi Arijit, I have shown the solution in this video from ruclips.net/video/BURK7wMcCwU/видео.html. Please check.
stackoverflow.com/questions/10253826/path-issue-with-pytest-importerror-no-module-named-yadayadayada
On command line go one folder up from the folder from where you have any imports in your script
For example this is your project structure:
ProjectFolder/Example/Demo/file.py
In you file.py you have your code with import statements.
Suppose one of the import is from Demo folder
So on command line goto folder Example (parent of demo folder)
and then say command
python -m unittest Demo.file .
(note do not give .py extension)
why to use pytest nose? please throw some light on this
Hi Pallavi, nose library can be used to extend the testing framework to make testing easier and efficient. I will plan to have a dedicated session on this