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

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

  • @sharat86chandra
    @sharat86chandra 3 года назад +11

    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 :)

    • @mukeshavatarmadesia2043
      @mukeshavatarmadesia2043 2 года назад

      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

  • @singh07neeraj
    @singh07neeraj 4 года назад +2

    tons of thanks, Naveen I was waiting for Python Selenium videos.

  • @kankipatiramaraju4983
    @kankipatiramaraju4983 4 года назад +2

    Thank you, you should get more appreciation for this wonderful content..

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

    Dude this is awesome work, you da man!!! I dont care if you talk in hindi .. this is truly exceptional work!!!

  • @Ravi-wd1rv
    @Ravi-wd1rv 3 года назад

    Thank you Naveen. It is very insightful. And very helpful for people who don’t understand where to start to build framework.

  •  4 года назад +2

    Perfect tutorial. Waiting for the next chapters.

    • @naveenautomationlabs
      @naveenautomationlabs  4 года назад

      Thanks a lot! Part 2 is already there in the same playlist.

    • @akashmishra1598
      @akashmishra1598 2 года назад

      ​@@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 ..

  • @ayyajjamadar6387
    @ayyajjamadar6387 4 года назад +1

    Most awaited video for me
    Thank you

  • @kesavab5970
    @kesavab5970 4 года назад +1

    Thanks for the video...Waiting for part2

  • @defaulterjk
    @defaulterjk 2 года назад

    Awesome 👍 very smoothly taught 2 good

  • @singh07neeraj
    @singh07neeraj 4 года назад

    Eagerly awaiting for next video :)

  • @shailajadavangave45
    @shailajadavangave45 2 года назад

    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

  • @salmanmohamed1993
    @salmanmohamed1993 2 года назад +1

    hi naveen sir, iam getting below error while executing the test
    self.loginPage = LoginPage(self.driver)
    E TypeError: LoginPage() takes no arguments

  • @gahung206
    @gahung206 2 месяца назад

    Can I know how do pytest understand self.driver at 30:47, where it comes from?

  • @jackjack-kh2ng
    @jackjack-kh2ng 4 года назад

    Thanks a lot Naveen. Waiting for Part 2

  • @ashutoshpratapsingh6872
    @ashutoshpratapsingh6872 4 года назад +3

    A big thanks for this, great

    • @naveenautomationlabs
      @naveenautomationlabs  4 года назад +2

      happy now? :)

    • @ashutoshpratapsingh6872
      @ashutoshpratapsingh6872 4 года назад

      @@naveenautomationlabs yes thanks a lot

    • @ashutoshpratapsingh6872
      @ashutoshpratapsingh6872 4 года назад

      @@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

  • @dushananuradha1098
    @dushananuradha1098 2 года назад

    Super helpful. Thanks a lot for sharing..

  • @rakeshpatra1955
    @rakeshpatra1955 4 года назад +5

    Sir can you please come up with a video over jenkins with Python .I am eagerly waiting for this.

  • @hajirasharieff9121
    @hajirasharieff9121 3 года назад

    Amazing! Loved the explaination! Thank you

  • @Shanky12
    @Shanky12 5 месяцев назад

    Hi Naveen, can i use this framework creation style for my current project, or is there any changes that i need to check?

  • @nileshgadekar668
    @nileshgadekar668 4 года назад +1

    Thanks for your efforts ❤️❤️

  • @praveenvanahalli3353
    @praveenvanahalli3353 4 года назад +4

    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.

    • @harishms1562
      @harishms1562 4 года назад +1

      Hi Praveen, even i'm getting the same error. Did u resolve it? can you please ping me @sumalatha1390@gmail.com

    • @SatyabrataNayak91
      @SatyabrataNayak91 3 года назад

      @@harishms1562 Did you find the solution for this issue, I am also facing the same

    • @sunilkumarr4257
      @sunilkumarr4257 2 года назад

      @Praven Vanahalli - Did you get the solution for this issue? I am getting the same and not getting resolved. @Naveen AutomationLabs

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

    What was the point of base page class if config py & page class can hold all the reusable info/methods specific to the test ?

  • @silppas1577
    @silppas1577 2 года назад

    Is it best practice to create object for class LoginPage separately in each function. Is thr any other way we can do this

  • @smarty420ful
    @smarty420ful 3 года назад

    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

  • @shalininandakumar7162
    @shalininandakumar7162 4 года назад +2

    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

    • @neurobiteshorts
      @neurobiteshorts 4 года назад

      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

    • @sunilkumarr4257
      @sunilkumarr4257 2 года назад

      @Shalini Nandakumar - Didi you get a solution to this issue? I am also getting the same issue. Is there any solution?

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

      ​​@@neurobiteshorts imported base class but still error is seen

  • @indusaptarshi
    @indusaptarshi 3 года назад +1

    Sir wonderfully explained, is this uploaded to GIT?

  • @muhammadasadtahir284
    @muhammadasadtahir284 2 года назад +1

    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'

    • @SLEDGE872
      @SLEDGE872 2 года назад

      Same error I'm having now bro, did u get any solution for this issue, Please help if u found any solution.

    • @SLEDGE872
      @SLEDGE872 2 года назад +1

      Bro Got the solution __init__.py needs to be added each and every folders to directories

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

      ​​@@SLEDGE872 Hi bro i am facing the same error

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

      Bro can u explain me the solution clearly please.

  • @rorymer
    @rorymer 4 года назад

    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

  • @logeshv7685
    @logeshv7685 4 года назад

    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?

  • @rajanipagadala3081
    @rajanipagadala3081 4 года назад

    Waiting for next parts

  • @CristianoistheGOAT-g3b
    @CristianoistheGOAT-g3b 3 года назад

    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.

  • @apekshapradhan5996
    @apekshapradhan5996 3 года назад

    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

  • @arpadszilvesztervarga4113
    @arpadszilvesztervarga4113 3 года назад

    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:)

  • @kirthikarajendran7627
    @kirthikarajendran7627 4 года назад

    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 ?

  • @hotgorshok1357
    @hotgorshok1357 3 года назад

    Why did you override constructor in loginpage class? Because it inherits constructor from basepage

  • @maheshbabukandukuri1989
    @maheshbabukandukuri1989 4 года назад

    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 :)

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

    Thanks Naveen. Can you please share the repostory URL to download this code.

  • @chaitanyashirodkar8069
    @chaitanyashirodkar8069 4 года назад

    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.

  • @wardaliaqat4093
    @wardaliaqat4093 4 года назад

    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?

  • @ethishrooney764
    @ethishrooney764 3 года назад

    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'

  • @yuvarajyuvaraj5606
    @yuvarajyuvaraj5606 3 года назад

    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??

  • @manikantareddy7283
    @manikantareddy7283 4 года назад

    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 🙂

  • @sudhanshukansal7169
    @sudhanshukansal7169 4 года назад +1

    Thanks Naveen

  • @srinikesh.M
    @srinikesh.M 3 года назад

    Is There Scope for Python Selenium!! I couldn't find much opening in Top MNCs

  • @matthewanderson2959
    @matthewanderson2959 2 года назад

    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?

    • @satheeshkumarn722
      @satheeshkumarn722 2 года назад

      Yes, I'm also facing the same issue. Please help me with this.

  • @KarthikVicky-e3l
    @KarthikVicky-e3l 11 месяцев назад

    hi naveen iam getting module get not callable..... how to fix this

  • @prasannakumarthallapally416
    @prasannakumarthallapally416 3 года назад +2

    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?

  • @snsnsnsnsnnsnsnsnsnsnsnsnj7478
    @snsnsnsnsnnsnsnsnsnsnsnsnj7478 4 года назад

    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?

  • @santanusaha5615
    @santanusaha5615 3 года назад

    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

    • @ashishsahu8065
      @ashishsahu8065 3 года назад

      hi can u please tell me why login page of hubspot site is not accessible ?

    • @MohanKumar-ci7bg
      @MohanKumar-ci7bg 2 года назад

      Did you get resolution for this ? Even I am getting same error

    • @SLEDGE872
      @SLEDGE872 2 года назад

      @@MohanKumar-ci7bg Bro Got the solution __init__.py needs to be added each and every folders to directories

  • @Vsksharma
    @Vsksharma 3 года назад

    Thanks Navven for the series on pytest and POM. Can you cover screenplay using the same login test?

  • @mudaseer21
    @mudaseer21 4 года назад +2

    nice

  • @mandeeparora2875
    @mandeeparora2875 4 года назад

    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

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

    Hi Naveen sir. Can I get git hub link for this code.

  • @shankarmeenakshi-sundaram2959
    @shankarmeenakshi-sundaram2959 2 года назад

    Hi , I did the same .But my script is not getting executed. like chrome window is not opening

  • @sriharich28
    @sriharich28 3 года назад

    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

  • @the_kavita_cafeteria
    @the_kavita_cafeteria 4 года назад

    Hello Naveen Sir, A small request, kindly show how to select values from static drop down *through page object model, reusable method* please 🙏

  • @MubeenAli-pz5vs
    @MubeenAli-pz5vs 4 года назад

    When will next video be released?

  • @danipeer4699
    @danipeer4699 2 года назад

    great video. When can we download the code?

  • @bayronalexisorozcogranja8914
    @bayronalexisorozcogranja8914 3 года назад

    Hi! im new with python and pytest in at moment a have this problem (fixture 'init_driver' not found). thakns for you help!

    • @shawonshariff7469
      @shawonshariff7469 3 года назад

      Did you solved it? I am facing the same problem now.

  • @anshuljain8136
    @anshuljain8136 3 года назад

    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

    • @testtest-pb8hv
      @testtest-pb8hv 2 года назад

      Hey, did you find the solution ? I got the same error

  • @jarosawtrykowski5589
    @jarosawtrykowski5589 3 года назад

    Hi
    Is the code of your presentation available to download?

  • @ArturBerkut
    @ArturBerkut 4 года назад +1

    Thanks a lot

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

    Actually I am using Visual studio, followed your video, iam getting modulenotfound error. How to resolve it, can anyone please help me out

  • @ParasJoshiPj
    @ParasJoshiPj 6 месяцев назад

    Hi naveen request you to make Behave python framework.

  • @krish.s8601
    @krish.s8601 4 года назад

    Every test case app install newly (am using mobile testing on Pytest), how can i solve this , l'll try this {"noReset": True}

  • @RajeshKumar-eg3uz
    @RajeshKumar-eg3uz 4 года назад

    fixture 'init_driver' not found - showing this error when I try to execute, please help me what I really missing?

    • @smarty420ful
      @smarty420ful 3 года назад

      may be you missed to add the fixture on the conftest.py

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

    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

  • @praji1202
    @praji1202 2 года назад

    Where can i get the full code ?

  • @bautistagaggiotti116
    @bautistagaggiotti116 3 года назад

    I dont understand where does he actually uses de BASE_URL to navigate to the website

  • @varunm0608
    @varunm0608 3 года назад

    I want to skip login pages and login functionality.How can we do that ?

  • @sharatchandra2045
    @sharatchandra2045 3 года назад

    hi Naveen,nice content. do we have this code in github. can you pls share the link

  • @learnpythontogether4490
    @learnpythontogether4490 3 года назад

    AttributeError: 'SubRequest' object has no attribute 'params'
    How I fixed this error.

  • @prabhumishra3323
    @prabhumishra3323 4 года назад

    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.

  • @Desiderio_space
    @Desiderio_space 4 года назад +2

    github please

  • @ManpreetKaur-cs5zx
    @ManpreetKaur-cs5zx 4 года назад +1

    🙏 thanks

  • @chiranjibisahu8092
    @chiranjibisahu8092 4 года назад +2

    👍

  • @Mayadani1945
    @Mayadani1945 4 года назад

    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

  • @xsoft7
    @xsoft7 4 года назад

    can you share a link to the files?

  • @muhammadasadtahir284
    @muhammadasadtahir284 2 года назад

    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.

  • @gasauer6995
    @gasauer6995 2 года назад

    Dude, slow down when you speak. You talk wicked fast!

  • @duckboymiro3533
    @duckboymiro3533 3 года назад

    man your accent is terrible, try to like talk slower or something. but still thank you

    • @naveenautomationlabs
      @naveenautomationlabs  3 года назад +4

      Thanks for your suggestion but learn how to understand indian accent if you are watching indian youtube channel.

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

      @@naveenautomationlabs hey dude when the teacher speaks (u can use cc btw) , you listen! Awesome tutorial man!