6 | Page Object Model | Selenium Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ย. 2024

ความคิดเห็น • 104

  • @shwethabolar7468
    @shwethabolar7468 19 วันที่ผ่านมา +1

    Done and dusted. Have gone through all 6 videos with hands on Raghav. I am very grateful to you for sharing these videos. I am new to Python. Watched your python videos first and then started with this. Completed successfully. 🙏

    • @RaghavPal
      @RaghavPal  17 วันที่ผ่านมา

      So nice of you Shwetha

  • @saumyaari3442
    @saumyaari3442 7 หลายเดือนก่อน +1

    Hi Raghav,
    I'm getting error for ,
    self.password_textbox = (By.ID, "password")
    self.driver.find_element(self.password_textbox).send_keys(password)
    but if I change into below it works fine.
    self.password_textbox = "password"
    self.driver.find_element(By.ID, self.password_textbox).send_keys(password)
    can you please help me understand why. Thanks

    • @RaghavPal
      @RaghavPal  7 หลายเดือนก่อน +1

      Saumya
      Let's break down the issue and understand why the second approach works while the first one doesn't.
      1. First Approach:
      ```python
      self.password_textbox = (By.ID, "password")
      self.driver.find_element(self.password_textbox).send_keys(password)
      ```
      - In this approach, you are creating a tuple with `(By.ID, "password")` and assigning it to `self.password_textbox`.
      - The `find_element()` method expects a locator strategy (such as `By.ID`, `By.NAME`, etc.) followed by the actual value (e.g., `"password"`).
      - Since you're passing a tuple, it doesn't match the expected format, resulting in an error.
      2. Second Approach:
      ```python
      self.password_textbox = "password"
      self.driver.find_element(By.ID, self.password_textbox).send_keys(password)
      ```
      - Here, you directly assign the string `"password"` to `self.password_textbox`.
      - When you use `self.driver.find_element(By.ID, self.password_textbox)`, it correctly matches the expected format for locating an element by its ID.
      3. Solution:
      - To fix the first approach, you should pass the locator strategy (`By.ID`) and the actual value (`"password"`) separately:
      ```python
      self.password_textbox = (By.ID, "password")
      self.driver.find_element(*self.password_textbox).send_keys(password)
      ```
      - The `*` before `self.password_textbox` unpacks the tuple, allowing it to be used as separate arguments.
      Remember that when using `find_element()`, you need to provide the locator strategy and the value separately. The second approach works because it follows this pattern directly.
      ..

    • @saumyaari3442
      @saumyaari3442 7 หลายเดือนก่อน

      Appreciate your prompt reply and taking time to give this detailed explanation. I understand the issue now. Thanks to your videos I'm learning a lot. Keep up the good work@@RaghavPal

  • @elmariscal5394
    @elmariscal5394 ปีที่แล้ว +2

    Hi Raghav , that is great . Another wrapper method could be created where you can call the 3 existing independent methods eg:
    Login (user,pass):
    enter_username(user)
    enter_password(pass)
    click_login() . So, from your tests you can call a single: login wrapper method instead of calling 3 independent methods .

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      thanks for adding El

  • @satishreddybojanpally9824
    @satishreddybojanpally9824 ปีที่แล้ว +1

    Sir please start java from beginning to end sir with examples

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Okay, will plan Satish

  • @Namelessaccount-x1x
    @Namelessaccount-x1x 11 หลายเดือนก่อน +1

    Hii Raghav,is this course good for begineers in automation. I have knowledge of python but no knowledge of testing/automation. Will this course be good to start with?

    • @RaghavPal
      @RaghavPal  11 หลายเดือนก่อน

      Yes, definitely, must follow with hands-on

  • @Zywl
    @Zywl 5 หลายเดือนก่อน

    what is the benefit of passing the URL of the login page as a parameter of the navigate function? Isn't the URL a inherent attribute of the LoginPage Class instead?

    • @RaghavPal
      @RaghavPal  5 หลายเดือนก่อน +1

      Passing the URL of the login page as a parameter to the navigate function in Selenium Python can offer several benefits:
      1. Flexibility: By passing the URL as a parameter, you can easily change the URL without modifying the class code, making your tests more adaptable to different environments (like staging, production, etc.).
      2. Reusability: If you have multiple pages that require navigation, you can reuse the same navigation function for different URLs, which promotes code reusability.
      3. Maintainability: It's easier to maintain and manage the URLs from a central configuration file or environment variables rather than hardcoding them into the classes.
      4. Testing Different Scenarios: You might want to test how your application behaves with different base URLs, such as international versions of the site or feature-specific URLs.
      While it's true that the URL can be an attribute of the LoginPage class, passing it as a parameter provides a level of abstraction that can make your testing framework more robust and easier to maintain. It's a common practice to separate the data (like URLs) from the logic (like navigation functions) to allow for greater flexibility and easier updates.

    • @Zywl
      @Zywl 5 หลายเดือนก่อน

      @@RaghavPal I see, thank you very much for your response!! I really appreciate the quality of your tutorials and clearing up my doubts. Love your content

  • @MySmallbigworld
    @MySmallbigworld ปีที่แล้ว +1

    Thank you Raghav ji for the wonderful set for python automation.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      You are most welcome Hrudhya

  • @ashishajwani2910
    @ashishajwani2910 19 วันที่ผ่านมา

    @raghavpal Hi there I understand the POM model here but one question can we use this when working on behave with python like I want to keep locator separate but not in step definition. Can you help me ple

    • @RaghavPal
      @RaghavPal  19 วันที่ผ่านมา

      Ashish
      Short Answer: Yes, you can use the Page Object Model (POM) with Behave and Python. In fact, it's a great way to separate locators from step definitions and make your tests more maintainable.
      Detailed Explanation:
      In traditional Selenium tests, the POM is used to separate the page elements (locators) from the test logic. This approach makes it easier to maintain and update tests when the UI changes.
      When working with Behave, you can apply a similar approach. Instead of defining locators within step definitions, you can create a separate module or class that contains the page objects. This way, you can keep the locators separate from the step definitions.
      -

    • @ashishajwani2910
      @ashishajwani2910 19 วันที่ผ่านมา

      @@RaghavPal thanks for your reply.
      I was working on it today and doing the same. But somehow the Locator module which i created is not accepted when i run the feature file. I get
      ModuleNotFoundError: No module named 'Locators'
      Even though i have used
      from Locators.Locators import Lp

    • @RaghavPal
      @RaghavPal  17 วันที่ผ่านมา

      From the error message ModuleNotFoundError: No module named 'Locators', it seems that Python is unable to find the Locators module when running your feature file. This is despite you having imported it correctly using from Locators.Locators import Lp.
      Possible Causes
      Here are a few potential reasons for this issue:
      Incorrect module structure: Make sure that your Locators module is correctly structured and located in the correct directory
      Import path issues: Double-check that the import path from Locators.Locators import Lp is correct and matches the actual directory structure of your project
      PyCharm configuration: Ensure that PyCharm is configured to use the correct Python interpreter and that the Locators module is included in the project's Python path
      Troubleshooting Steps
      To help resolve the issue, please try the following steps:
      Verify module structure: Check that your Locators module is a valid Python package with an __init__.py file. The directory structure should be something like:
      project_root/
      Locators/
      __init__.py
      Locators.py
      ...
      Check import path: Ensure that the import path from Locators.Locators import Lp matches the actual directory structure of your project
      Check PyCharm configuration: Go to File > Settings > Project: [your_project_name] > Project Interpreter and ensure that the correct Python interpreter is selected
      Also, check that the Locators module is included in the project's Python path
      -

  • @reviewkiemtiencucde825
    @reviewkiemtiencucde825 4 หลายเดือนก่อน

    Hello, how to read excel to selenium python

    • @RaghavPal
      @RaghavPal  4 หลายเดือนก่อน

      Sure, here's a basic example of how you can read data from an Excel file using Selenium WebDriver in Python:
      ```python
      import openpyxl
      # Load the workbook with its path
      bk = openpyxl.load_workbook("C:\\Path\\To\\Your\\ExcelFile.xlsx")
      # Identify the active worksheet
      s = bk.active
      # Identify the cell
      c = s.cell(row=3, column=1)
      # Retrieve the cell value and print
      print(c.value)
      ```
      In this code:
      - `openpyxl.load_workbook("C:\\Path\\To\\Your\\ExcelFile.xlsx")` is used to load the workbook from the specified path.
      - `bk.active` is used to get the active worksheet.
      - `s.cell(row=3, column=1)` is used to get the cell at row 3 and column 1.
      - `print(c.value)` is used to print the value of the cell⁴.
      Please replace `"C:\\Path\\To\\Your\\ExcelFile.xlsx"` with the path to your Excel file, and adjust the row and column numbers as per your needs. Also, ensure that the `openpyxl` library is installed in your Python environment. If it's not, you can install it using pip: `pip install openpyxl`.
      This is a simple example and real-world scenarios might require more complex operations such as reading multiple cells, handling different data types, etc
      --

  • @emmanuelalder9052
    @emmanuelalder9052 ปีที่แล้ว +1

    Hi Raghav, great videos. They are really easy to follow and implement. Do you have any courses or material on Pytest-BDD? I'm trying to understand it and how to implement it with Page Object Model. Any help would be great thank you.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Thanks Emmanuel
      Not exactly, Can check in the video library here - automationstepbystep.com/

    • @emmanuelalder9052
      @emmanuelalder9052 ปีที่แล้ว

      @@RaghavPal thanks for replying. I had a look at your website, and I couldn't see anything on Pytest-bdd. Is this a video or course on Udemey you could potentially create? It would really help me advance my knowledge for the current roles I'm looking into. Especially using the POM within the Pytest-bdd framework. Thank you.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Then I may not have created a separate video on this. I will plan

    • @emmanuelalder9052
      @emmanuelalder9052 ปีที่แล้ว

      @@RaghavPal Thank you in advance. It will really help me on my journey. I've used behave but prefer to learn pytest-bdd properly and how to use it with POM. Thanks. I can't wait for it.

  • @MeatyWhack
    @MeatyWhack 5 หลายเดือนก่อน +1

    I separated the driver logic into a separate class - I wasn't convinced of the merits of the driver logic being included as part of the test logic. Otherwise, really great video!

    • @RaghavPal
      @RaghavPal  5 หลายเดือนก่อน

      Thanks for sharing

  • @_manasikara
    @_manasikara 7 หลายเดือนก่อน

    The title is misleading. You're using Pytest not Selenium.

    • @RaghavPal
      @RaghavPal  7 หลายเดือนก่อน

      I will check this Manasikāra

  • @bencipherx
    @bencipherx ปีที่แล้ว +1

    Lovely. I’ll watch and follow

  • @shettyschalawadi6998
    @shettyschalawadi6998 6 หลายเดือนก่อน

    Hello brother Please don't copy and paste from here and there, that is very confusing for beginners...

    • @RaghavPal
      @RaghavPal  6 หลายเดือนก่อน

      Sure.. please let me know which part or section did you face issue with.. so i can improve on that

    • @shettyschalawadi6998
      @shettyschalawadi6998 6 หลายเดือนก่อน

      @@RaghavPal Thanks so much for the response bro, while explaining the step 2 (6.29min) copied the code from other page and explained, btw i did not got chance to watch your previous session so got stuck over there.

    • @RaghavPal
      @RaghavPal  6 หลายเดือนก่อน

      hope its fine now.. else send me more details with steps and logs

    • @shettyschalawadi6998
      @shettyschalawadi6998 6 หลายเดือนก่อน

      @@RaghavPal cleared bro thanks again🤗

  • @khirankumar11
    @khirankumar11 3 หลายเดือนก่อน

    Being a complete beginner this course was really useful.Thanks @raghavpal

    • @RaghavPal
      @RaghavPal  3 หลายเดือนก่อน

      Glad to hear that Khiran

  • @rahulraj-je2bo
    @rahulraj-je2bo ปีที่แล้ว

    Hi Raghav…I know java selenium using cucumber …which is better in market today??…selenium with java or the python???
    Is it so necessary to learn python again or java is sufficient?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Hi Rahul
      Both Selenium with Java and Selenium with Python are popular choices for automation testing. There are pros and cons to each language, so it really depends on your specific needs and preferences.
      **Selenium with Java**
      * Java is a robust and mature language with a large community of developers.
      * There are many libraries and frameworks available for Selenium with Java, which can make it easy to get started.
      * Java is a compiled language, which means that it is generally faster than Python.
      **Selenium with Python**
      * Python is a popular and easy-to-learn language.
      * Python is a dynamically typed language, which can make it more concise than Java.
      * Python is generally faster than Java for small scripts.
      If you are already familiar with Java, then it is not necessary to learn Python again. However, if you are interested in learning a new language, then Python is a good choice for automation testing. Python is a popular and easy-to-learn language, and it has a large community of developers. There are also many libraries and frameworks available for Selenium with Python, which can make it easy to get started.

  • @darkmode132
    @darkmode132 4 หลายเดือนก่อน

    Thank you so much, Raghav. I’m so thankful for these free videos you shared with us. I have tried to watch other tutorials, but your videos by far is the easiest to follow and understand. You’re assuring words helped too. I finished these 6 videos and I felt really great. I would be happy to learn more about automation with other tools from your guidance through TH-cam and your site. Thank you again! I hope you’re having the best time of your life for being very generous with us with your knowledge! Please keep sharing! Thank you, Raghav!

    • @RaghavPal
      @RaghavPal  4 หลายเดือนก่อน

      Great to know this helped and thanks for the kind words

  • @online_business_pokhara
    @online_business_pokhara ปีที่แล้ว

    Make video on selenium4. 11.2. Regarding chrome 115 and chrome for testing

  • @dreamsapcat
    @dreamsapcat 10 หลายเดือนก่อน

    Hi Raghav ,I am getting continue erroe AttributeError: 'WebElement' no attribute send my test is getting fail when i am trying to use in 5th youtube vedio

    • @RaghavPal
      @RaghavPal  10 หลายเดือนก่อน

      Sapna
      There are a few reasons why you might be getting an `AttributeError: 'WebElement' no attribute 'send'` error when using Selenium Python.
      One possibility is that you are using an outdated version of Selenium Python. The `send()` attribute was deprecated in Selenium 4 and later, so you should upgrade to the latest version of Selenium Python.
      Another possibility is that you are using the wrong method to send text to an element. The `send()` method is used to send keyboard events to an element, such as pressing keys or typing text. To send text to an element, you should use the `send_keys()` method.
      Finally, it is possible that you are trying to send text to an element that is not enabled or that does not accept text input. If you are not sure whether an element is enabled or accepts text input, you can use the `is_enabled()` and `is_displayed()` methods to check.
      Here is an example of how to send text to an element using the `send_keys()` method:
      ```python
      from selenium import webdriver
      driver = webdriver.Chrome()
      driver.get('example.com/')
      element = driver.find_element_by_id('my-element')
      # Send text to the element.
      element.send_keys('This is some text.')
      # Close the browser.
      driver.quit()
      ```

  • @parthipanp-id5wo
    @parthipanp-id5wo ปีที่แล้ว

    Hi Raghav, playwright or webdriverio which tool is suitable for angular and react frameworks? Please clarify

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Parthipan
      Both Playwright and WebdriverIO are suitable for Angular and React frameworks. However, there are some key differences between the two tools that may make one more suitable for your needs than the other.
      The best tool for you will depend on your specific needs and preferences. If you are looking for a tool that is easy to use and has excellent support for modern web features, then Playwright is a good choice. If you are looking for a tool that is more powerful and has a wider range of features, then WebdriverIO is a good choice.
      Here are some additional things to consider when choosing between Playwright and WebdriverIO:
      * **Your team's skill level.** If your team is new to automation, then Playwright may be a better choice because it is easier to use. However, if your team is more experienced, then WebdriverIO may be a better choice because it offers more features and flexibility.
      * **The size of your project.** If you are working on a large project with a lot of complex web pages, then WebdriverIO may be a better choice because it has better support for multi-threading and parallel execution.
      * **Your budget.** Playwright is a commercial tool, while WebdriverIO is open source. If you are on a budget, then WebdriverIO may be a better choice

  • @KavitaRawatWorld
    @KavitaRawatWorld ปีที่แล้ว

    Hi Raghav, First of thanks so much you are my silent mentor in automation.
    I am 7 years of exp in Manual and API Automation. Web automation i did very less.
    i did it 2 years back in last company for 6 months(Selenium), I forgot a lot now my new company wants to do it in Selenium So the company demand it to me to complete one project -(Atelaset minimum I have to Write maximum 50 test cases till the September first week)..
    I dnt know how can i start a new project ?
    For me its completely new how your videos can give me some help and how can I start Project automation? It's so urgent ..there are many channels on TH-cam but i was always comforted with your teaching skills.
    So can you guide me how can start my project automation step by step (Selenium+Java)with the learning in parallel i did half course in udemy but it was so complex and explained so lengthy so could not complete as there are lots of things..
    Till now i did installation etc now i am stuck how a project can be started?
    Hope you will leave me with some satisfaction and some guidelines as well .Thanks in Advance.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +2

      Hi Kavita
      Here are some steps on how to start a new Selenium project:
      1. **Choose a programming language.** Selenium can be used with a variety of programming languages, including Java, Python, C#, and Ruby. Choose a language that you are comfortable with and that is supported by your team.
      2. **Install the Selenium WebDriver.** The Selenium WebDriver is a library that allows you to control a web browser from your code. You can install the Selenium WebDriver for your chosen programming language from the Selenium website.
      3. **Create a new project.** You can use an IDE like Eclipse or IntelliJ IDEA to create a new project for your Selenium automation.
      4. **Write your test cases.** Your test cases should be written in a way that is easy to understand and maintain. You can use a variety of frameworks to help you write your test cases, such as TestNG or JUnit.
      5. **Run your test cases.** Once you have written your test cases, you can run them to see if they pass. You can run your test cases from the command line or from within your IDE.
      6. **Debug your test cases.** If your test cases fail, you will need to debug them to find the errors. You can use a debugger to step through your code and see where the errors are occurring.
      7. **Refactor your code.** Once your test cases are working, you may want to refactor your code to make it more readable and maintainable. You can use a linter to help you find potential errors in your code.
      8. **Deploy your test cases.** Once your test cases are finished, you will need to deploy them to a server so that they can be run automatically. You can use a continuous integration (CI) server like Jenkins or Travis CI to deploy your test cases.
      Here are some additional tips for starting a new Selenium project:
      * Start small. Don't try to automate your entire website in one go. Start with a small section of the website and gradually add more tests as you go.
      * Use a framework. A framework can help you write your test cases more easily and efficiently. There are a variety of frameworks available, so choose one that is right for your project.
      * Document your code. Document your code so that other developers can understand it. This will make it easier to maintain your code in the future.
      * Test your code. Test your code regularly to make sure that it is working correctly. You can use a unit testing framework like JUnit to test your code.
      * Get feedback. Get feedback from other developers on your code. This will help you to improve your code and find potential errors.
      I hope this helps

    • @KavitaRawatWorld
      @KavitaRawatWorld ปีที่แล้ว +1

      @@RaghavPal Thank you so much for reading and answering with so much details. This will surely helping me & I will try to apply all in my project. Thanks for your patience .

  • @flirtuall78
    @flirtuall78 3 หลายเดือนก่อน

    Thank you.

    • @RaghavPal
      @RaghavPal  3 หลายเดือนก่อน

      Most welcome

  • @yazz-m
    @yazz-m 11 หลายเดือนก่อน

    Hi Raghav.. Your videos have helped me a lot to learn how to automate, thank you very much for sharing them.
    I have a question. Please, could you help me?.. What method can I use so that in the Login window, the username and password are not inserted until the page is completely loaded?

    • @RaghavPal
      @RaghavPal  11 หลายเดือนก่อน +1

      Yazmin
      There are two methods that you can use to wait for a page to load completely before entering the username and password in the login window in Selenium with Python:
      1. *Use the `WebDriverWait` class.* The `WebDriverWait` class allows you to wait for a specific condition to be met before continuing with your test case. To use the `WebDriverWait` class to wait for a page to load completely, you can use the following code:
      ```python
      from selenium import webdriver
      from selenium.webdriver.common.by import By
      from selenium.webdriver.support.ui import WebDriverWait
      driver = webdriver.Chrome()
      driver.get("www.example.com/login")
      # Wait for the page to load completely
      wait = WebDriverWait(driver, 10)
      element = wait.until(EC.presence_of_element_located((By.ID, "username")))
      # Enter the username and password
      username_field = driver.find_element_by_id("username")
      username_field.send_keys("username")
      password_field = driver.find_element_by_id("password")
      password_field.send_keys("password")
      # Click the login button
      login_button = driver.find_element_by_id("login_button")
      login_button.click()
      ```
      The `EC.presence_of_element_located()` expected condition will wait until the element with the ID `username` is present on the page. Once the element is present, the `WebDriverWait` class will return the element and your test case will continue.
      2. *Use the `execute_script()` method.* The `execute_script()` method allows you to execute JavaScript code in the browser. To use the `execute_script()` method to wait for a page to load completely, you can use the following code:
      ```python
      from selenium import webdriver
      from selenium.webdriver.common.by import By
      driver = webdriver.Chrome()
      driver.get("www.example.com/login")
      # Wait for the page to load completely
      driver.execute_script("return document.readyState === 'complete';")
      # Enter the username and password
      username_field = driver.find_element_by_id("username")
      username_field.send_keys("username")
      password_field = driver.find_element_by_id("password")
      password_field.send_keys("password")
      # Click the login button
      login_button = driver.find_element_by_id("login_button")
      login_button.click()
      ```
      The `document.readyState` property will return the current state of the document. If the document is completely loaded, the `document.readyState` property will return the value `complete`. The `execute_script()` method will wait until the `document.readyState` property returns the value `complete` before continuing with your test case.
      Which method you use depends on your personal preference. The `WebDriverWait` class is a more robust way to wait for a page to load completely, but the `execute_script()` method is more flexible.

    • @yazz-m
      @yazz-m 11 หลายเดือนก่อน

      @@RaghavPal Thank you very much, both methods worked for me

  • @TravelltheGlobe
    @TravelltheGlobe ปีที่แล้ว

    Hey Raghav, Thank you for the great session on Selenium Python.
    One issue that I'm facing here is whenever I'm adding locators for elements under constructor function, it is giving me error: InvalidArgumentException: Message: invalid argument: 'using' must be a string.
    However, if I'm defining the locators within the action functions, it is running fine. Still figuring out the reason, but if you could help me with the reason for this, it will be helpful. Also, is this a good practice to define the locators in the action function itself?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Hi Garima
      The error message "InvalidArgumentException: Message: invalid argument: 'using' must be a string" means that you are trying to pass a value that is not a string to the `using` keyword in the Selenium Python constructor. The `using` keyword is used to specify the type of locator that will be used to find an element. The valid values for the `using` keyword are `id`, `name`, `xpath`, and `css selector`.
      The reason why you are getting this error when you define the locators in the constructor is because the constructor is trying to find the element before it has been initialized. The locators are not defined yet, so the constructor cannot find the element.
      To fix this error, you need to define the locators after the constructor has been initialized. You can do this by creating a new function and defining the locators in that function. For example, the following code will work:
      ```python
      def find_element(self, locator_type, locator_value):
      """Finds an element using the specified locator type and value."""
      return self.driver.find_element(by=locator_type, value=locator_value)
      def test_find_element(self):
      """Tests the find_element function."""
      element = self.find_element(locator_type="id", locator_value="my_id")
      assert element is not None
      ```
      This code defines a function called `find_element` that takes two arguments: the locator type and the locator value. The `find_element` function uses the Selenium Python `find_element` method to find the element. The `test_find_element` function tests the `find_element` function by calling it with the id locator "my_id".
      Is it a good practice to define the locators in the action function itself?
      It is not a good practice to define the locators in the action function itself. This is because the locators may change, and if you define them in the action function, you will have to update the code every time the locators change. It is better to define the locators in a separate file or function, and then import them into the action function. This way, you can update the locators in one place, and the action function will automatically use the updated locators.
      I hope this helps

    • @TravelltheGlobe
      @TravelltheGlobe ปีที่แล้ว

      @@RaghavPal Thanks for the detailed answer.

  • @TanzeelRabbani-s3k
    @TanzeelRabbani-s3k ปีที่แล้ว

    Hi Raghav, in this video while you were importing from pages you got an error so you moved the pages in test. but can you please tell me the actual solution so that the purpose POM can be successfully delivered.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +2

      Tanzeel
      I believe it was due to the path and location issues. If you have both folders under the main folder, should be fine. Can check some online examples

    • @TanzeelRabbani-s3k
      @TanzeelRabbani-s3k ปีที่แล้ว

      @@RaghavPal thank you Raghav, your tutorials and videos provided me with the best training and learning.
      Keep up the good work.

  • @yuzara777
    @yuzara777 4 หลายเดือนก่อน

    Very good video! I understood everything, tysm

    • @RaghavPal
      @RaghavPal  4 หลายเดือนก่อน

      Glad it helped

  • @Teja_Rao
    @Teja_Rao ปีที่แล้ว

    Hi Raghav bro, ur videos are very nice and easy to learn quickly. But my one suggestion you are posted selenium with python 2023 course only six videos, Please make sure you post the further videos also and we get more information.
    Thank you ❤

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      I will do as I get some time Teja, you can also check other Selenium Python lectures here - automationstepbystep.com/

    • @Teja_Rao
      @Teja_Rao ปีที่แล้ว

      Ok, Thank you..
      Which is most demanding courses either Selenium with Python or else Selenium with Java..??

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Both, these days Python is getting more attention

  • @emmanuelalder9052
    @emmanuelalder9052 ปีที่แล้ว

    Hi @Raghav, Thanks for these videos. I just have a question on assertions. Is it best to use the try and except? Also is it best practice to stop the test as soon as we hit an error, or should we let the test continue running to the end? Thanks

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Emmanuel
      Assertions are used to check if a condition is met. If the condition is not met, an AssertionError exception is raised. The try and except statement is used to handle exceptions. If an exception is raised in the try block, the code in the except block is executed.
      In Selenium Python, it is best to use assertions to check for expected conditions. For example, you can use an assertion to check if a web element is present on the page. If the web element is not present, an AssertionError exception will be raised. This will help you to identify errors in your test code early on.
      It is not recommended to use try and except to handle assertions. This is because it can mask errors in your test code. If an assertion fails, the code in the except block will be executed, but the error will not be logged. This can make it difficult to track down the source of the error.
      As for whether to stop the test as soon as we hit an error, or should we let the test continue running to the end, it depends on the specific test case. In some cases, it may be helpful to let the test continue running to the end so that you can see all of the errors that are generated. However, in other cases, it may be better to stop the test as soon as an error is found so that you can focus on fixing that error.
      Here are some general guidelines for using assertions in Selenium Python:
      * Use assertions to check for expected conditions.
      * Do not use try and except to handle assertions.
      * Stop the test as soon as an error is found, unless you have a specific reason to continue running the test.
      I hope this helps

    • @emmanuelalder9052
      @emmanuelalder9052 ปีที่แล้ว

      @@RaghavPal thank you for such a detailed breakdown, this helps a lot. I really do appreciate your knowledge. I can't wait for any other complete courses on Python-Selenium you might release. The ones you have done have been a massive help.
      I just came across SeleniumBase, It's a wrapper around Selenium webdriver and it's supposed to simplify the code, is it worth learning or should I just stick with Selenium webdriver? I would really value your opinion on this. Thanks

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      I am yet to explore SeleniumBase in detail. You can try and check if it meets your requirments

  • @emmanuelalder9052
    @emmanuelalder9052 ปีที่แล้ว

    Hi Raghav, I ran into the same problem as you when I tried to run the code. I had to use the splat operator. I've never had to do this before, can you explain what this is and why we have to use it? Thanks

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Tell me the timestamp Emmanuel

    • @emmanuelalder9052
      @emmanuelalder9052 ปีที่แล้ว

      @@RaghavPal the time stamp is 27:16. Thank you

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      The splat operator (*) in Python is used for unpacking iterable objects (like lists, tuples, strings, etc.) into separate elements. It's also commonly referred to as the "unpacking operator." The splat operator allows you to pass multiple arguments to a function or construct iterables like lists or tuples more easily.
      POM encourages you to create classes that represent web pages. These classes typically include the web elements on that page and methods to interact with those elements.
      e.g.:
      def enter_credentials(self, username, password):
      self.driver.find_element(*self.username_field).send_keys(username) self.driver.find_element(*self.password_field).send_keys(password)
      In this example, the *self.username_field and *self.password_field use the splat operator to unpack the tuple representing the locator into separate arguments, which is a common practice in Selenium to locate elements using methods like find_element()
      The splat operator is not a fundamental part of the POM itself. Instead, it's a general Python syntax feature that can be used to simplify function calls or unpack values when needed.

    • @emmanuelalder9052
      @emmanuelalder9052 ปีที่แล้ว

      @@RaghavPal Got it, thank you for the breakdown. Great course and great tutor

  • @irabor18
    @irabor18 ปีที่แล้ว

    still getting import errors in python at 26:20, havent been able to resolve this issue. Is there a conflict with the other test folder in pytest. the file structrue seems to be the issue.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      I will need more details on this
      There are a few possible reasons why you might be getting import errors in your Selenium Python framework when using Pytest:
      * **Conflicting imports:** If you have multiple test folders in your project, it is possible that there are conflicting imports between them. This can happen if two test folders are trying to import the same module, but with different versions.
      * **Incorrect file structure:** If your file structure is not correct, Pytest may not be able to find the modules that you are trying to import.
      * **Incorrect imports:** It is also possible that you are making incorrect imports in your test code.
      To troubleshoot the import errors that you are getting, you can try the following:
      1. **Check for conflicting imports:** Use a tool like PyLint to check for conflicting imports in your project.
      2. **Check your file structure:** Make sure that your file structure is correct and that Pytest can find the modules that you are trying to import.
      3. **Check your imports:** Make sure that you are making correct imports in your test code.
      Here are some specific tips for troubleshooting import errors in Selenium Python frameworks using Pytest:
      * **Use relative imports:** When importing modules in your test code, use relative imports instead of absolute imports. This will help to prevent conflicts between imports from different test folders.
      * **Use the `PYTHONPATH` environment variable:** You can use the `PYTHONPATH` environment variable to specify additional directories where Pytest should look for modules. This can be useful if your test code depends on modules that are not installed in the standard Python library.
      * **Use Pytest fixtures:** Pytest fixtures can be used to import modules into your test code in a controlled way. This can help to prevent conflicts between imports from different test folders.
      If you are still having trouble resolving the import errors that you are getting, you can post your code on a forum or mailing list for help.
      Here is an example of a Pytest fixture that can be used to import modules into your test code in a controlled way:
      ```python
      import pytest
      @pytest.fixture
      def import_module(request):
      module_name = request.param
      module = importlib.import_module(module_name)
      return module
      ```
      To use this fixture, you would pass the name of the module that you want to import to the `request.param` parameter. For example, the following code would import the `selenium` module:
      ```python
      import pytest
      @pytest.fixture
      def import_module(request):
      module_name = 'selenium'
      module = importlib.import_module(module_name)
      return module
      def test_something(import_module):
      webdriver = import_module.webdriver.Chrome()
      webdriver.get('www.google.com')
      ```
      By using Pytest fixtures, you can prevent conflicts between imports from different test folders and ensure that your test code is using the correct versions of the modules that it needs.

    • @irabor18
      @irabor18 ปีที่แล้ว

      I was able to solve the issue by removing the POMDemo folder structure. and leaving both files in the root directory. thanks for getting back to me, great content!@@RaghavPal

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Great

  • @mohsenbou
    @mohsenbou ปีที่แล้ว

    thank you so much

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      You're welcome Mohsen

  • @sakalabhaktulaharika9381
    @sakalabhaktulaharika9381 ปีที่แล้ว

    What laptop ur using?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      This is a remote machine (windows)

    • @sakalabhaktulaharika9381
      @sakalabhaktulaharika9381 ปีที่แล้ว

      @@RaghavPal ok .. I want to buy laptop to practice automation . Could you please tell me Hp i3 11th gen 8gb will be fine?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Yes, should be find, If you can get 16 GB will be good

  • @Muheeth-wh3sz
    @Muheeth-wh3sz ปีที่แล้ว

    Hi Raghav,superb explaination.
    Iam getting error as no such method error while using webdriver wait :void org.openga.selenium.support.ui.webdriverwait.(org.openga.webdriver,java.time.duration).
    Can u pls give the sol.for it

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Muheeth
      The error message you are getting is because the `WebDriverWait` class in Selenium Python has been deprecated. You should use the `WebDriverWait` class from the `selenium.webdriver.support.ui` module instead.
      To fix the error, you need to update your code to use the `WebDriverWait` class from the `selenium.webdriver.support.ui` module. You can do this by replacing the following line:
      ```
      from selenium.webdriver.support import expected_conditions as EC
      from selenium.webdriver.support.ui import WebDriverWait
      ```
      with the following line:
      ```
      from selenium.webdriver.support.ui import WebDriverWait
      ```
      Once you have made this change, you should be able to use the `WebDriverWait` class without any errors.
      Here are some additional things to keep in mind:
      * The `WebDriverWait` class from the `selenium.webdriver.support.ui` module has the same methods as the `WebDriverWait` class from the `selenium.webdriver.support` module.
      * You can also use the `ExpectedConditions` class from the `selenium.webdriver.support` module to specify the conditions that the `WebDriverWait` class should wait for.
      I hope this helps

    • @Muheeth-wh3sz
      @Muheeth-wh3sz ปีที่แล้ว

      Tqs for ur response can u pls share the import file what should i replace.
      I have import files like
      Import org.openga.selenium.support.ui.WebDriverWait;
      Import.org.openga.selenium.support.ui.ExceptedCondtions;
      If you dont mind pls help me to what should i replace from these...

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Did you try:
      from selenium import webdriver
      from selenium.webdriver.support.ui import WebDriverWait
      Also check some examples online

    • @Muheeth-wh3sz
      @Muheeth-wh3sz ปีที่แล้ว

      @@RaghavPal yes tried but its showing error in import file..

    • @Muheeth-wh3sz
      @Muheeth-wh3sz ปีที่แล้ว

      @@RaghavPal can pls share ur insta id