Page Object Model - Python Selenium with PyTest - Part 1
HTML-код
- Опубликовано: 9 фев 2025
- In this video, I have explained the design and how to create UI Automation Framework with PyTest using POM (Page Object Model) design pattern.
Technologies used:
Python 3.x
Selenium WebDriver Python Language binding
PyTest - test framework
Pytest - html report
Pytest-xsld for parallel execution
PyCharm - IDE
Was searching from a couple days for an exact video on PyTest Framework and came across this video. Its really very helpful. Now this will help me start creating a framework on my own for my project. Thank you very much Naveen :)
Hi Sharat
Can you share sample code structure based on POM.
To login , take screenshot and generate report
Using selenium python pytest and any report
tons of thanks, Naveen I was waiting for Python Selenium videos.
Thank you, you should get more appreciation for this wonderful content..
Dude this is awesome work, you da man!!! I dont care if you talk in hindi .. this is truly exceptional work!!!
Thank you Naveen. It is very insightful. And very helpful for people who don’t understand where to start to build framework.
Perfect tutorial. Waiting for the next chapters.
Thanks a lot! Part 2 is already there in the same playlist.
@@naveenautomationlabs Hi Naveen, as you have covered all the concepts in Selenium with Java playlist, Can you please create Selenium with python in a similar way. It's really very interesting to watch your videos and we gain lots of knowledge ..
Most awaited video for me
Thank you
Thanks for the video...Waiting for part2
Awesome 👍 very smoothly taught 2 good
Eagerly awaiting for next video :)
Thanks Naveen for the video series on pytest it helped me a lot for the interview, please make video on how to implement logging in pytest and how to rerun failed testcases
hi naveen sir, iam getting below error while executing the test
self.loginPage = LoginPage(self.driver)
E TypeError: LoginPage() takes no arguments
Can I know how do pytest understand self.driver at 30:47, where it comes from?
Thanks a lot Naveen. Waiting for Part 2
A big thanks for this, great
happy now? :)
@@naveenautomationlabs yes thanks a lot
@@naveenautomationlabs Naveen now we need to update fixture scope, after removing scope then it's opening new browser for each test methods, otherwise it will do in single browser
Super helpful. Thanks a lot for sharing..
Sir can you please come up with a video over jenkins with Python .I am eagerly waiting for this.
Amazing! Loved the explaination! Thank you
Hi Naveen, can i use this framework creation style for my current project, or is there any changes that i need to check?
Thanks for your efforts ❤️❤️
Hi Naveen, Nice video. I tried the same flow but getting AttributeError: 'TestLogin' object has no attribute 'driver' in test_login_page method as below. I checked the code syntax and spelling. Everything is fine.
def test_login_page(self):
> self.loginPage = LoginPage(self.driver)
E AttributeError: 'TestLogin' object has no attribute 'driver'
Tried to resolve it but not getting the right resolution to fix it.
Hi Praveen, even i'm getting the same error. Did u resolve it? can you please ping me @sumalatha1390@gmail.com
@@harishms1562 Did you find the solution for this issue, I am also facing the same
@Praven Vanahalli - Did you get the solution for this issue? I am getting the same and not getting resolved. @Naveen AutomationLabs
What was the point of base page class if config py & page class can hold all the reusable info/methods specific to the test ?
Is it best practice to create object for class LoginPage separately in each function. Is thr any other way we can do this
the site you have given is not loading with automation but when I try to do open It manually it works fine.. Is there any workaround to resolve the issue
Hi Naveen, Thanks for the video. I implemented the same thing you showed, but got an error AttributeError: 'LoginPage' object has no attribute 'driver'. Can you please help me figure out the reason for this
Try adding BasePage as the parameter in the class.
Eg. class LoginPage(BasePage):
Also don't forget to import BasePage
from Pages.BasePage import BasePage
@Shalini Nandakumar - Didi you get a solution to this issue? I am also getting the same issue. Is there any solution?
@@neurobiteshorts imported base class but still error is seen
Sir wonderfully explained, is this uploaded to GIT?
Can you please guide me to resolve this error ?
ImportError while loading conftest 'C:\Users\Asad\Desktop\Python Automation Project\SQA_POM_Project\Test\conftest.py'.
ModuleNotFoundError: No module named 'Test.conftest'
Same error I'm having now bro, did u get any solution for this issue, Please help if u found any solution.
Bro Got the solution __init__.py needs to be added each and every folders to directories
@@SLEDGE872 Hi bro i am facing the same error
Bro can u explain me the solution clearly please.
Hello, how are you? To make a connection with BDD behave or with pytest-bdd as it would be with the FW that you are building, I tried but could not. What if I could do is how far did you get with the framework
Hi Naveen, i just need to udst the way in which we can keep desired capabilities into a setup method and invoke it every time we run our automation?
Waiting for next parts
Thank you for this tutorial. I encountered this error "fixture 'init_driver not found" when I tried to execute the test cases. How can I fix it? I use a mac.
Hi SIr, I have taking the refernce of this code to automate my application , I am facing fixture 'init_driver' not found error. Can you please tell me the solution to remove this error
Nice video thank you! I just have an issue when I'm trying to navigate inside the webpage and paging to a different sub page on website the webdriver jumps back to the original URL. Can you give any advice with that? Much appreciation in advance:)
Hi Naveen sir ,I was having 6 years in manual testing . Then have a gap of 2 years . Now searching for a job. I have applied almost 200 applications for manual . Not Even get a single vendor call . In these days , automation are in demand . Can I re start my career with selenium with python or selenium with java . I don’t have programming skills . Pls suggest on this ?
Why did you override constructor in loginpage class? Because it inherits constructor from basepage
Hi Naveen,
Thanks a lot for the video. I'm looking for this session Pyest using POM
I have a doubt here how to run only failed tests in Pytest??? do we have any package to install to run only specific fail tests wherein Java, we can run by using testng-failed.xml file.
Awaiting for next video :)
Thanks Naveen. Can you please share the repostory URL to download this code.
My question might come in Part2 session. But I need the answer asap because of some urgency. Think I have two py files. File1 class will have 3 methods and File2 class file will have 2 methods. When I run the entire directory it is opening the browser two times for executing each class file. I do not want that, I want all 5 methods from both class files to run on the same browser. Any help in quick time is much appreciated.
Hello Sir, I completely followed your code but on side side it's just running one test not the remaining 2 also when i tried to run tests in parallel. why this?
Hi Sir,
trying to use webdriver manager in pytest getting error
if request.param == "chrome":
> web_driver = webdriver.Chrome(ChromeDriverManager.install())
E TypeError: install() missing 1 required positional argument: 'self'
Hi Sir, every time my web page input id/ password name changing dynamically. could you suggest any idea??
e-x:
input id ="fxd12" name= username
input id ="fxh22" name = password
after restarting my application
e-x:
input id= "fxd13" name= username
input id="fxd33" name=password
how to get a constant id and password??
Hi Naveen,
I'm new to automation and have a doubt.. Having Utility class is good or bad idea.
I know that it helps in reusability.. I have gone through few blogs they say this not to use utility class.
I've also seen your videos saying create utility classes.. I'm bit confused. Please help 🙂
Thanks Naveen
Is There Scope for Python Selenium!! I couldn't find much opening in Top MNCs
Navven, thank you for posting this video. I am attempting to put what I've learned in this video into practice and set up my folder structure similar to yours and I am using visual studio code as my IDE but I cannot get my test_LoginPage.py file to see the config.py file. How were you able to get your test files to see files in other directories?
Yes, I'm also facing the same issue. Please help me with this.
hi naveen iam getting module get not callable..... how to fix this
def get_attribute_value(self, by_locator, value):
element = WebDriverWait(self.driver, 10).until(EC.text_to_be_present_in_element_value(by_locator))
return element.get_attribute(value)
Is this correct code for get attribute value?
Can you please correct anyone?
Value should be string 'value' 👍
If elements are not visible in case there are multiple mouse hovers... If inspect elements not working on it... In that case what should we do?
ImportError while loading conftest 'D:\AutoProject\Tests\conftest.py'.
ModuleNotFoundError: No module named 'Tests.conftest'
I get the above errors, any pointers for these?
Regards
Santanu
hi can u please tell me why login page of hubspot site is not accessible ?
Did you get resolution for this ? Even I am getting same error
@@MohanKumar-ci7bg Bro Got the solution __init__.py needs to be added each and every folders to directories
Thanks Navven for the series on pytest and POM. Can you cover screenplay using the same login test?
nice
Hi could you prepare a video regarding how to automate when we have to perform drag and drop on slider which does not have any value in its properties. But we want to perform drag and drop using some defined values
Hi Naveen sir. Can I get git hub link for this code.
Hi , I did the same .But my script is not getting executed. like chrome window is not opening
Could you please do a one more session on page object model selenium with Python using pytest framework with selenium webdrivermanager
I tried but it couldn't work for me
Hello Naveen Sir, A small request, kindly show how to select values from static drop down *through page object model, reusable method* please 🙏
When will next video be released?
great video. When can we download the code?
Hi! im new with python and pytest in at moment a have this problem (fixture 'init_driver' not found). thakns for you help!
Did you solved it? I am facing the same problem now.
Hello, I am getting below error: Please let me know how to resolve it ..TIA
self.login_page = LoginPage(self.driver)
E AttributeError: 'Test_login' object has no attribute 'driver'
test_LoginPage.py:11: AttributeError
Hey, did you find the solution ? I got the same error
Hi
Is the code of your presentation available to download?
Thanks a lot
Actually I am using Visual studio, followed your video, iam getting modulenotfound error. How to resolve it, can anyone please help me out
Hi naveen request you to make Behave python framework.
Every test case app install newly (am using mobile testing on Pytest), how can i solve this , l'll try this {"noReset": True}
fixture 'init_driver' not found - showing this error when I try to execute, please help me what I really missing?
may be you missed to add the fixture on the conftest.py
ImportError while loading conftest 'C:\Users\*****\Desktop\IRCTC_Project_PYTEST\Tests\conftest.py'.
Tests\conftest.py:5: in
from Config.config import TestData
E ModuleNotFoundError: No module named 'Config'
Giving this error while running with the same folder structure. please provide solution
Where can i get the full code ?
I dont understand where does he actually uses de BASE_URL to navigate to the website
I want to skip login pages and login functionality.How can we do that ?
hi Naveen,nice content. do we have this code in github. can you pls share the link
AttributeError: 'SubRequest' object has no attribute 'params'
How I fixed this error.
Hi sir, could you please make a video on how to create a function in python to select dependant drop down values. For example select a drop down value, then based on the selection another drop down appears with values. All the dependant drop down should have same xpath but should only differ in it’s preceding value.
github please
🙏 thanks
👍
Hi Naveen I love your post always I real like it you so amazing person please i want to know where do you live second I real need you help regarding automation i have difficulties and i couldn't correct it on my automation in selenium i have this problem which is SLF4J FAILED TO LOAD CLASS ,SLF4J DEFAULTING TO NO-OPERATION where do i find dependence for some reason i couldn't find
can you share a link to the files?
Please help me to resolve this error. Thanks
C:\Users\Asad\Desktop\Python Automation Project\SQA_POM_Project>pytest C:\Users\Asad\Desktop\Python Automation Project\SQA_POM_Project\Test\Test_LoginPage.py
'pytest' is not recognized as an internal or external command,
operable program or batch file.
Dude, slow down when you speak. You talk wicked fast!
check your playback speed once.
man your accent is terrible, try to like talk slower or something. but still thank you
Thanks for your suggestion but learn how to understand indian accent if you are watching indian youtube channel.
@@naveenautomationlabs hey dude when the teacher speaks (u can use cc btw) , you listen! Awesome tutorial man!