I tried this code in eclipse , didn't work---> ''' Created on 07-Jan-2019 @author: Prasad ''' from selenium import webdriver import unittest class Logintest(unittest.TestCase):
One point to note here is that unit tests in python recognize test cases only if prefixed with test_. Example: test_login_valid. If you don't prefix test then no error is thrown but tests run as Run 0 test in 0.00s
Hello Raghav Da, Thanks for this amazing tutorial. I could follow most of it without any problem but facing a bit of issue when calling the loginpage class in my logintest. So when ever I am creating an object of that class it is throwing error because of the parameters called. Its says the parameter is unrecognized. When looking for the suggestions I am getting the parameter as "driver=". I am not sure what should be the value of the driver, what should I put after equals sign.. when calling it in the test class, can you please help? Thank you so much. Binita
Binita When working with the Page Object Model (POM) in Selenium Python, you need to pass the WebDriver instance (the browser driver) to your page classes. Let’s address this issue: 1. Passing WebDriver to Page Classes: - In POM, each page class should have a `WebDriver` object as a class member. This allows you to interact with web elements on that page. - You can pass the `WebDriver` instance as a parameter to the constructor of your page class. 2. Example Implementation: - Suppose you have a `LoginPage` class. Here's how you can pass the `driver` to it: ```python from selenium import webdriver class LoginPage: def __init__(self, driver): self.driver = driver # Other page elements and methods go here # Usage in your test class: driver = webdriver.Chrome() # Initialize your WebDriver (e.g., Chrome, Firefox, etc.) login_page = LoginPage(driver) # Create an instance of LoginPage ``` 3. Page Factory (Optional): - If you're using Page Factory (a part of POM), you can simplify this further: ```python from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC class LoginPage: def __init__(self, driver): self.driver = driver # Initialize page elements using @FindBy annotations # Usage in your test class: driver = webdriver.Chrome() login_page = LoginPage(driver) ``` Remember to adjust the class name (`LoginPage` in this example) to match your actual page class --
Hi there, I had a question. In what scenarios will running the tests from command line be helpful ? Doing that seems like more work when we can just run it from the IDE 😅
Jele Let's break down the scenarios where running Selenium tests from the command line can be helpful: I am added all details. it can be long but i hope will help everyone in future... Scenario 1: Automation and CI/CD Pipelines When you're working on a large project, you might want to automate the testing process as part of your Continuous Integration and Continuous Deployment (CI/CD) pipeline. Running tests from the command line allows you to integrate your tests with tools like Jenkins, Travis CI, CircleCI, or GitHub Actions. This way, your tests can run automatically whenever code changes are pushed to your repository, ensuring that your code is tested thoroughly before deployment. Scenario 2: Multi-Environment Testing Imagine you need to test your application on different environments, such as different browsers, operating systems, or mobile devices. Running tests from the command line allows you to easily switch between environments by modifying the command-line arguments or environment variables. This can be more efficient than constantly changing settings within your IDE. Scenario 3: Distributed Testing When you have a large test suite, running tests in parallel can significantly reduce the overall testing time. Command-line execution enables you to distribute your tests across multiple machines or containers, making it easier to scale your testing efforts. Scenario 4: Headless Testing Sometimes, you might want to run your tests in a headless mode, without displaying the browser UI. Command-line execution makes it easy to run tests in headless mode, which can be useful for testing in environments where a display is not available or when you want to reduce the resource usage. Scenario 5: Scheduled Testing You might want to schedule your tests to run at specific times or intervals, such as nightly or weekly. Command-line execution allows you to use tools like cron jobs (on Linux/macOS) or Task Scheduler (on Windows) to automate the testing process. Scenario 6: Remote Testing When working in a team, you might want to run tests on a remote machine or a cloud-based infrastructure. Command-line execution enables you to run tests remotely, making it easier to collaborate with team members or use cloud-based testing services. Scenario 7: Debugging and Troubleshooting When debugging issues, running tests from the command line can provide more detailed output and error messages, making it easier to identify and troubleshoot problems. While it's true that running tests from the IDE can be more convenient, there are scenarios where running tests from the command line provides more flexibility, scalability, and automation capabilities -
Hi Raghav, I see that you have used HtmlTestRunnerfor generating the reports but this does not seem to work with python 3.0+ is there any other alternative?
I have one general question regarding writing test cases. Suppose if we are testing a form and if it has 2 inputs (login and password) then should we write all the test cases for it? 1) Valid Login name, Valid Password 2) Valid login name, Invalid Password 3) Invalid Login name, Valid Password 4) Invalid Login name, Invalid Password
Hi Nandish, yes you can cover all possible scenarios. A data driven test will be better here where you can get the data drom a external file like excel
@@RaghavPal thanks. But suppose if there are 16 input items in the form then i think there will be thousands of test cases if we follow the same approach.. So how to write test cases in that scenario?
Sorry for late reply Nandish, I believe the test is same and the data varies, In that case data-driven test OR getting data from an external file is the best option.
Hello, Raghav! This video is very useful for me. I'm a newbie in Selenium, and here are my questions: 1) 50:59 - We should write "message = driver.find_element_by_xpath("//span[@id='spanMessage']").text" instead of "message = driver.find_element_by_xpath("").text". Am I right? 2) 50:31 - We don't call the function "check_invalid_username_message" anywhere. Is it ok? When should it be called?
Hi , I see a lot of people have blocked on unresloved error problem for import: ImportError: No module named SampleProjectPOM.POMDemo.Pages.LoginPage but it seems that there is no solution posted yet :( could some one help ? (for info, even when marked the floder as sources ROOT it doesn't work) thank you in advance :)
Hi Saber, I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.html. Please check. Start your command with python -m pytest Please check this:stackoverflow.com/questions/10253826/path-issue-with-pytest-importerror-no-module-named-yadayadayadagithub.com/pytest-dev/pytest/issues/2287
Hi Raghav, Thank you so much for the tutorial.But when I try to import HTMltest runner in pycharm which is already installed via cmd, shows not installed and when I try to install the package in Pycharm, getting following error. Collecting HtmlTestRunner Could not find a version that satisfies the requirement HtmlTestRunner (from versions: ) No matching distribution found for HtmlTestRunner Please help.
Hi Raghav, Thanks to put this selenium framework using POM| Unit test| HTML reports. It was really helpful video for a beginner like me who are keen to learn about developing a sustainable framework. This video is really well structured and organized that can help anyone who does not have any prior knowledge in framework development. Coming to my query, I have imported HtmlTestRunner module and even added the report path in unittest.main(). But, when i am trying to run the script in cmd, it shows the following error : Traceback (most recent call last): File "C:\Python38-32\lib unpy.py", line 185, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "C:\Python38-32\lib unpy.py", line 111, in _get_module_details __import__(pkg_name) File "C:\Users\Anjali\PycharmProjects\Selenium-Framework\DemoProject\POMProjectDemo\Tests\login.py", line 5, in import HtmlTestRunner ModuleNotFoundError: No module named 'HtmlTestRunner' Can, You tell me where i am making mistake. Thank you in advance : )
Solution for error message on running the invalid test on 53:00 : Needed to give parameters as so : message = driver.find_element_by_xpath(login.invalidUserName_msg_xpath).text instead of : message = driver.find_element_by_xpath("").text In the login.py file :P
Getting issue in HtmlTestRunner PFB error I tried upgrading my python to latest version after this error still didn't solve for me could any one please help. "Could not find a version that satisfies the requirement HtmltestRunner (from versions: none)"
Hi Bhupendra, could not find any specific solution online. In the documentation page - pypi.org/project/html-testRunner/ it says can work with Python 3.5
Hello sir, Could you please make a video on selecting dependant drop down values in an array which is for example if you select one drop down value then another drop down should appear in the UI so that I can select the next drop down value. Currently I am facing problem in automating this in python
Hi Raghav, Thank you very much for your tutorial. I want to capture screenshot when the test case fails and i want to add same screenshot to the html report. Is this possible in selenium-python? if yes, please help me how can I do that.
Hi Amaresh, you can use PyTest. This will help - www.automationtesting.co.in/2017/02/pytest-with-selenium-html-report-with.html?m4dc=1 stackoverflow.com/questions/50534623/how-do-i-include-screenshot-in-python-pytest-html-report
Hi Sir, For following code I am getting error as : 'Config' object has no attribute '_metadata' def pytest_configure(config): config._metadata['Project Name'] = 'Vyrill' config._metadata['Module Name'] = 'Admin Dashboard' config._metadata['Tester'] = 'Rahul' Could you please give me a solution on this? I am using python: 3.6.8 pytest: 4.6.11 Thanks!
Hi Raghav, i tried to generate html report, but after running on mac os, this report can't generate? testRunner=HtmlTestRunner.HTMLTestRunner(output='/Users/fawzi/PycharmProjects/pythonProject1/reports', report_name="Login Report", report_title="Login Report", add_timestamp=True)) this is correct?
im getting below error File "C:\Users\arumugam001\PycharmProjects\SeleniumDemo\RW\Test\login.py", line 21, in test_login driver = self.driver AttributeError: 'LoginTest' object has no attribute 'driver'
Hi Raghav, Facing below error :- ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
Hi Nitesh, There can be multiple reason behind this error: Presence of anti-virus softwares. Firewall blocking the ports. Network Configuration. Problem can be caused by CORS. Due to enabling of HTTP keep-alive connections this can help - stackoverflow.com/questions/51562067/connectionabortederror-winerror-10053-an-established-connection-was-aborted-b
Raghav, i'm geting an error msg while executing the tests with Pytest: FAILED Test_duck.py::TestDuck::test_search - AttributeError: 'TestDuck' object has no attribute 'driver' what's the problem with the driver? Thx
Hi Federico, some issue where you created driver instance, can check this sqa.stackexchange.com/questions/46901/attributeerror-testone-object-has-no-attribute-driver
Hello Raghav, thank you for this video, it's the best I've come across on the topic. I've followed your video and keep getting the "ModuleNotFoundError" when I try and run the tests :( I have the tests and page objects in different folders and import the page objects class into the tests, I've also looked online for a solution, tried all I could. Still getting that error. Could you advise please? Many thanks!
from POMProjectDemo.Pages.loginPage import LoginPage ModuleNotFoundError: No module named 'POMProjectDemo' in vs code kindly why we get plz provide solution 35:39
Hi Ram, I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.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 sir, I had import error on implement POM Please give me a solution. SampleProject.POMProjectDemo.Page.loginPage import LoginPage ImportError: No module named SampleProject.POMProjectDemo.Page.loginPage
Hi Pooja, I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.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 Raghav, I was able to debug this error. I ran my test script via pycharm terminal and it successfully ran and generated HTML report. But i still wants to know why it was throwing error when i tried to run from cmd. Please, give your valuable input and resolve my query. : )
Hi Raghav , thanks for sharing . In my opinion I would prefer : visibility_of_element_located rather than presence_of_element_located coz I first wait for the visibility of the object and then yes I interact with that element.
Hi Raghav 👋 .I am trying to apply the page object pattern. My problem is that I do not get an autosuggestion when typing self.driver. After the . I should see suggestions, but I am not; however if I were to run the program it run without any problem. Any solution
i can somehow call out method from another file but the code isn't running saying that it doesn't find the module despite the fact that I've changed directory of module package either by import sys ... edit enviroment in windowds or run launch.json and settings.json. I'm kinda hopeless at this point. I rly want to finish this project but i cannot go past this problem in VS code.
What if I create like in Java a "base_class.py" with the selenium driver instance and the set up methods in it? I got this question because the way you're teaching, we will need to code in every test class driver = webdriver... driver.implicity.... and I have learned that when we are repeating code, there is something not planned. What is your point?
Hi Ragav. I have 1 queries. Curently I am using pyautogui for screenshot. It's taking screenshot for the browser window where the script is running. But while execution if I minimise the browser window and open any other application then execution still run but it capture the other app window as screenshot Can you suggest how I can take the screenshot even if I minimise the browser. I mean if execution run in background in that case how to take that screenshot
Hi Neelambika, you may try some other libraries for screenshots. Check this pythonbasics.org/selenium-screenshot/ www.geeksforgeeks.org/how-to-take-screenshot-using-selenium-in-python/ stackoverflow.com/questions/41721734/take-screenshot-of-full-page-with-selenium-python-with-chromedriver
I have a small question. Around @11:39 in the video you have used find by link text. Now if I have multiple links of same text (like a click here text but at multiple places in a same page table), but dont have any identifier like id or class is there anyway to access one particular link?
In Python, there isn't a direct equivalent to pom.xml. However, alternatives like requirements.txt, setup.py, and pyproject.toml serve similar purposes. These files specify dependencies, metadata, and build settings for Python projects
Hi Raghav, I have one doubt-if i am running my test script from command line reports are generating but if i am trying to run from Pycharm i m not getting the reports (not generating).. You can find my code @ github.com/anand032111/google_selenium/blob/master/UnitTest.py Please help me in this
Hello, Awesome video I'm using Pycharm, and I did "pip install Selenium" and I have Anaconda Python - trying to automate Testcases using these tools, getting a 'Unresolved reference' error when I import Selenium webdriver. Am I missing any step here...pls could you give your input. Thanks
Hi Ambika, You can check the library is added in the project or interpreter. 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)
Great tutorial. Completely understood. The only thing is that ,for me in loginpage, homepage class if i do self.driver. ,then no option for find elements was showing, i have done it manually and its working fine. This is strange.
Every video I have watched teaches POM in a half baked manner. Its like info here is not wrong but its incomplete and thus steers people the wrong way because once they learn this - its hard to unlearn and do it right (that's assuming they even will continue try to improve their skills in page objects, most will just assume this is the only way).
Hi Pradeep, constructor is called whenever we create a object of the class. We make use of this property to force user to provide some parameters while creating objects
Amazing quality, eventhough is old version of selenium if you know how to set up new on this will give you a complete Idea how to work with each topic, If you a have some projects we can practice this topic please let me know.
Hi Keisha, for build tool you can use PyBuilder - pybuilder.github.io/ Also check this - packaging.python.org/guides/tool-recommendations/ For CI Jenkins is good
I exactly followed this for my project but while login test am getting attribute error, it is not allowing me to have a 'driver' as an attribute. Can someone help me.
hi Raghav had a query , can we able to add all locators in a different file under the project and able to import to the current file? rather than giving locators straight away as pointed in the above video?
Very nice video. what is the use of unittest here if I don't use unittest can't I use selenium with classes? in production unittest should be used ? please clarify my doubts thank you.
One problem i see here that we are not getting auto suggestions for the driver object for its method in POM structure any solution or reason for this? if the project is big where we need to write lot of wrappers and different selenium methods its very difficult to manage without auto suggest
Hi Mr Raghav, in my HTML report i see unwanted values displayed along with result status. How to remove those? something like these (function() { var ws = new WebSocket('ws://' + window.location.host + '/jb-server-page?reloadMode=RELOAD_ON_SAVE&'+ 'referrer=' + encodeURIComponent(window.location.pathname)); ws.onmessage = function (msg) { if (msg.data === 'reload') { window.location.reload(); } if (msg.data.startsWith('update-css ')) { var messageId = msg.data.substring(11); var links = document.getElementsByTagName('link'); for (var i = 0; i < links.length; i++) { var link = links[i]; if (link.rel !== 'stylesheet') continue; var clonedLink = link.cloneNode(true); var newHref = link.href.replace(/(&|\?)jbUpdateLinksId=\d+/, "$1jbUpdateLinksId=" + messageId); if (newHref !== link.href) { clonedLink.href = newHref; } else { var indexOfQuest = newHref.indexOf('?'); if (indexOfQuest >= 0) { // to support ?foo#hash clonedLink.href = newHref.substring(0, indexOfQuest + 1) + 'jbUpdateLinksId=' + messageId + '&' + newHref.substring(indexOfQuest + 1); } else { clonedLink.href += '?' + 'jbUpdateLinksId=' + messageId; } } link.replaceWith(clonedLink); } } }; })();
Hi Ragav, I follow up on this sample project creation, but I'm getting an error. please help me to resolve this I changed the edit configuration to run as unit test after a run through the unit test, I'm unable to execute the code Launching unittests with arguments python -m unittest C:/Users/PremataS/PycharmProjects/pythonProject/Sample_Project/POM_Demo/Tests/Create_Account.py in C:\Users\PremataS\PycharmProjects\pythonProject\Sample_Project\POM_Demo\Tests Ran 0 tests in 0.000s OK Process finished with exit code 0 Empty suite Empty suite
Hi Shehani, while using pytest, pls check your file, class and function names. File name - test_*.py or *_test.py Class name - prefixed with Test Function name - prefixed with test Can do the setup again and check
there is no function self.browser.find_element_by_id in Python 4 and there's self.browser.find_element(By.ID, "btnLogin") instead. How should I change self.browser.find_element_by_id(self.username_textbox_id)?
HI Lilia, I will check for Python 4 and add new sessions, For now, if you need to use Python 4, check the latest Selenium Python 4 documentation www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/
After using the command in Windows 10 CMD(Command Prompt) C:\Users\my.name\PycharmProjects\PROJECTNAME\Tests>python -m unittest login.py I got an error: ImportError: Failed to import test module: login Traceback (most recent call last): File "C:\Users\my.name\AppData\Local\Programs\Python\Python37-32\lib\unittest\loader.py", line 154, in loadTestsFromName module = __import__(module_name) File "C:\Users\my.name\PycharmProjects\PROJECTNAME\Tests\login.py", line 4, in from Pages.loginPage import LoginPage ModuleNotFoundError: No module named 'Pages' How to solve that?
Hi Arunas, I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.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)
When I try to run POM project on Windows 10 using Google Chrome v76.0 (64-bit). I am getting error below message: selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome version must be between 70 and 73 (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 10.0.18362 x86_64) Is anyone run into this issue before? So to continue with this lesson I have decided to use Firefox v69.0 (64-bit) and the same project is running fine.
When I try to run LoginTest using Firefox v69.0 (64-bit) using 'import HtmlTestRunner'. I am getting following error message: ImportError: Failed to import test module: login import HtmlTestRunner ModuleNotFoundError: No module named 'HtmlTestRunner' I have also verified thru command prompt that my machine contains html-testRunner v1.2.1, selenium v3.141.0, py v1.8.0, pip v19.2.3. Can someone please help me to resolve this issue?
Hi, 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)
@@RaghavPal Thank you Raghav for your reply. After inserting html-testRunner package to PyCharm I am now able to run my script. Thanks again for your help.
Hi Raghav, I was facing issues in understanding the concept of POM in selenium Python, your tutorial above has cleared all my doubts and implementation of POM in selenium Python Raghav, thx a ton for helping us out with such useful videos on testing stack, Raghav, the above POM what ever has been explained in the video is without using Page Factory ryt?? correct me if i'm wrong.. Can u kindly explain the same above example and concept by also using page factory and POM as well in selenium python.. It would be really useful for us ... Thanks in Advance, Siddhee :)
@@RaghavPal Thanks a ton Raghav :), will be waiting for your tutorial on Page factory model in selenium python, kindly do let me wen u upload it.. and also i have to admit whenever ppl have doubts/questions u always took that extra initiative in replying to each and everyone whoever has doubts and commented..that virtual help is much needed and thanx a ton again Raghavv :) Thanks in Advance, Siddhee :)
I may not have specific video, but you can follow this and add pytest..but these steps will help you: 1. Set Up Your Environment: - Install Python: Make sure you have Python installed on your system. You can download it from the official Python website. - Install PyCharm (or any other preferred IDE): PyCharm is a popular IDE for Python development. 2. Create a New Python Project: - Open PyCharm and create a new Python project. - Set up a virtual environment for your project. 3. Install Required Packages: - Install the necessary packages using pip: ``` pip install selenium pytest ``` 4. Create Page Classes: - Create a package (folder) named `pages` within your project. - Inside the `pages` package, create a Python file for each webpage you want to automate. These files will serve as your Page Classes. - In each Page Class, define the web elements (locators) and methods to interact with those elements. For example: ```python # Example Page Class for a login page class LoginPage: def __init__(self, driver): self.driver = driver self.username_input = "username_locator" self.password_input = "password_locator" self.login_button = "login_button_locator" def enter_credentials(self, username, password): self.driver.find_element_by_id(self.username_input).send_keys(username) self.driver.find_element_by_id(self.password_input).send_keys(password) def click_login_button(self): self.driver.find_element_by_id(self.login_button).click() ``` 5. Write Test Cases: - Create a package (folder) named `tests` within your project. - Inside the `tests` package, create Python files for your test cases. - In each test case, instantiate the Page Classes and use their methods to perform actions on the webpages. 6. Write PyTest Test Functions: - In your test files, write PyTest test functions. - Use the `@pytest.fixture` decorator to set up and tear down the WebDriver instance. - Example: ```python import pytest from selenium import webdriver from pages.login_page import LoginPage @pytest.fixture def setup(): driver = webdriver.Chrome(executable_path="path/to/chromedriver") yield driver driver.quit() def test_login(setup): driver = setup login_page = LoginPage(driver) login_page.enter_credentials("your_username", "your_password") login_page.click_login_button() # Add assertions to verify successful login ``` 7. Run Your Tests: - Open the terminal in PyCharm and run your tests using the following command: ``` pytest ``` 8. Review Reports: - PyTest generates HTML reports with test results. You can find them in the `reports` folder (create this folder if it doesn't exist). Remember to replace the example locators and test data with your actual application's details.
This video is very Helpfull, I tried the same using Locater model and successfully wrote a Page object model for entering the data into a website, But I am facing some difficulties in Web scraping syntax. Could you please help me with the syntax I am using this def getPrice(self): return self.driver.find_element_by_xpath(loc.Price).text Please help me with this!
@@RaghavPal Thank you so much for the timely reply, I just figured out the Syntax, def getPrice(self): return self.driver.find_element_by_xpath(loc.Price).text we have to call this in the script as page.getPrice()
Hi, Raghav. I am stuck at "Selenium Python Small Sample Project | Page Object Model POM" at 43:05. My Command Prompt still saying "No module named 'SampleProjects''". I have tried all of the options and none of them worked. Please, help. Thank you.
Hi Muslima, I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.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)
Hello, Raghav. Thank you for a great tutorial. I have a problem with importing class. //from Selenium.POMProjectDemo.Pages.LoginPage import loginPage -- gives me an error that No module named 'Selenium'.
Hi Namik, I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.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)
@@RaghavPal Thank you very much, I find the solution from your video description)). import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), "D:\python\Selenium\POMProjectDemo\Tests", "D:\python\Selenium\POMProjectDemo\Pages")) It is working.
Thanks Raghav, it is really awesome lesson. I can get "find_element_by_??" in the loginPage.py. How to access "find_elements_by_??" methods in loginPage.py. I can get "find_elements_by_??" in test class only. Please provide guideline Thanks Javed
Hi Javed, you can extend test class in loginPage (Inheritance). Pls check a example of inheritance here - www.w3schools.com/python/python_inheritance.asp
This video is so lucid. Thank you! one doubt- reports are not generating for me. I am running script from IDE. Is it necessary to execute script using command prompt in order to get the report generated? Please answer.
Hi Sweta, thanks for watching, there are some reporting lib that work from cmd line I must have shown some examples may be in later videos on how to generate reports from IDE
It is opening new tab with existing chrome session and not opening new Chrome browser for me. also not feeding the URL and throwing error as "selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed" could you please help? Windows 10 - sony vaio Package Version --------------- ------- behave 1.2.6 cx-Oracle 7.1.3 html-testRunner 1.2 Jinja2 2.9.5 MarkupSafe 1.1.1 parse 1.12.0 parse-type 0.4.2 pip 19.0.3 selenium 3.141.0 setuptools 40.8.0 six 1.12.0 urllib3 1.25.2
Hey, good Tutorial! But I have one problem. Sometimes, when I inspect an element, it has no ID or name. How can I still define it for my program? Thanks
Hi sir, I am not able generate HTML report even after using "import HTMLTestRunner". In command prompt it says the requirement is satisfied. Please help
Wonderful tutorial! Btw I got this problem. Everything ran just fine in PyCharm but when I tried to run the test in cmd, I got ModuleNotFoundError and it indicated that when importing HomePage, it can't find module "SampleProject" (from what I have imported: from SampleProject.POM.Pages.home_page import HomePage). I hope you see my comment and maybe give me some recommendations. Many thanks Raghav !
Hi Tai The ModuleNotFoundError typically occurs when the Python interpreter cannot find the module you are trying to import. This issue can arise due to different factors, such as incorrect module structure, incorrect module name, or incorrect PYTHONPATH configuration. Here are some steps you can take to resolve the ModuleNotFoundError issue: Verify the module structure: Double-check the directory structure of your project, specifically the location of the SampleProject module. Ensure that the module is located in the correct directory and that its name is spelled correctly. Check import statement: Verify that the import statement is correct and matches the module structure. Ensure that the module name (SampleProject) matches the actual module name and that the file (home_page.py) exists within the module. PYTHONPATH configuration: Check the PYTHONPATH environment variable to ensure it includes the directory where your SampleProject module is located. The PYTHONPATH variable tells the Python interpreter where to search for modules. You can set it as an environment variable or within your script using sys.path.append(). Run the script from the correct directory: Make sure you are running the script from the correct working directory. If your script relies on relative imports or assumes a specific directory structure, running it from a different location can cause import errors. Check Python interpreter: Ensure that the Python interpreter used in PyCharm is the same as the one used in the command prompt. If you are using a virtual environment in PyCharm, make sure the same virtual environment is activated in the command prompt as well. Install dependencies: If the SampleProject module relies on any external dependencies, ensure that those dependencies are installed in the Python environment you are using in the command prompt. You can use pip install to install any missing dependencies. By following these steps, you should be able to resolve the ModuleNotFoundError issue and successfully run your Selenium Python project in the command prompt.
@@RaghavPal Hi Raghav, thank you so much for your advice, I fixed it! However, I got a new problem. Whenever I tried to run the whole file, the 1st test case ran well but it cannot run the next test case and cause error: selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id. I think there are something wrong with the tearDown method cause if I comment the cls.driver.close() and cls.driver.quit(), all the test case ran fine. But yes, if the tearDown has nothing in it, it's not a good practice for selenium. So do you have any ideas? Tysm again
The "invalid session id" error typically occurs when the WebDriver session is closed or terminated before attempting to execute another test case. This can happen if you explicitly close or quit the WebDriver session in the tearDown method. To resolve this issue, you can modify your tearDown method to handle the WebDriver session appropriately. Here are a few suggestions: Separate the tearDown method for each test case: Instead of having a common tearDown method for all test cases, create a separate tearDown method for each test case. This way, the WebDriver session will be closed after each test case, ensuring a fresh session for each test. Use the tearDownClass method: Instead of using the tearDown method, you can use the tearDownClass method, which is called once after all the test cases in the test class are executed. This way, the WebDriver session will be closed after all the test cases are completed. Handle exceptions in the tearDown method: If you want to continue executing the remaining test cases even if an exception occurs in a specific test case, you can catch the exception in the tearDown method and handle it gracefully. This way, the WebDriver session will still be closed properly, allowing the subsequent test cases to run. Here's an example of how you can modify your code: import unittest from selenium import webdriver class MyTestClass(unittest.TestCase): @classmethod def setUpClass(cls): cls.driver = webdriver.Chrome() cls.driver.maximize_window() def test_case1(self): # Test case 1 code def test_case2(self): # Test case 2 code @classmethod def tearDownClass(cls): cls.driver.close() cls.driver.quit() if __name__ == '__main__': unittest.main() Make sure to adapt the code to fit your specific test case structure. By properly managing the WebDriver session in the tearDown or tearDownClass methods, you should be able to avoid the "invalid session id" error and execute multiple test cases successfully
@@RaghavPal Hey Thanks for quick reply, i was running the old configuration in pycharm, hence the __main__ section wasnt getting executed, I ran from terminal, and was able to generate the reports. This tutorial was very informative, Thanks a lot Could you please share if you have any training on writing feature test cases with Selenium in Python using POM
This is a great tutorial, helped me to build a framework on my own. Thank you. I do have a question. How do I read text on a button on a page? I tried using find_element_by_name but it don't work.
Satheesh Kumar Thankyou for your help. In my case there was no id on the button so I finally used the combination of name and value as it is unique and it worked.
@@RaghavPal @Satish I got the other issue working however now I am facing another big issue. How do I check for the existence of a modal/dialog. It is not an alert so I cannot use switch_to alert method. The html element I am speaking of has following arguments: role=dialog aria-labelledby=label aria-describedby=description. Any hints wold be highly appreciated. Thank you.
Hi Neha, is this site accessible publicly? You can check this stackoverflow.com/questions/19003003/check-if-any-alert-exists-using-selenium-with-python huddle.eurostarsoftwaretesting.com/selenium-interact-modal-windows/sqa.stackexchange.com/questions/26130/java-selenium-check-if-modal-popup-present
Online courses - automationstepbystep.com/
I tried this code in eclipse , didn't work--->
'''
Created on 07-Jan-2019
@author: Prasad
'''
from selenium import webdriver
import unittest
class Logintest(unittest.TestCase):
@classmethod
def setup (cls):
cls.driver = webdriver.Chrome(executable_path="C:/GoogleChromeDriver/chromedriver.exe")
cls.driver.implicitly_wait(10)
cls.driver.maximize_window()
def test_login_valid(self):
#self.driver = webdriver.Chrome(executable_path="C:/GoogleChromeDriver/chromedriver.exe")
self.driver.get("phptravels.org/clientarea.php")
self.user_name=self.driver.find_element_by_name("username")
self.user_name.send_keys("Dont want to share here")
self.password=self.driver.find_element_by_name("password")
self.password.send_keys("Dont want to share here")
self.password=self.driver.find_element_by_name("password")
self.driver.find_element_by_id("login").click()
@classmethod
def tear_down(cls):
cls.driver.close()
cls.driver.quit()
print("Test completed..")
# def login (self,username,password):
----------> Getting below error :
FFinding files... done.
Importing test modules ... done.
======================================================================
ERROR: test_login_valid (Login.Logintest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:/SeleniumProject/Python_Selenium/CRM_Application/com_actionables\Login.py", line 21, in test_login_valid
self.driver.get("phptravels.org/clientarea.php")
AttributeError: 'Logintest' object has no attribute 'driver'
----------------------------------------------------------------------
Ran 1 test in 0.004s
FAILED (errors=1)
but still I am enjoying it
Hi Prasad, looks like you missed some step. Request you to refer the video again carefully
where are the notes ?
@@prasadsardesai Facing the same issue "AttributeError: type object "LoginTest' has no attribute 'driver'". have you got the solution for this ?
this tutorial should get more recognition.....clearly explained. keep up the good work man,Cheers!!
So happy to read your message Ahmed
One point to note here is that unit tests in python recognize test cases only if prefixed with test_. Example: test_login_valid. If you don't prefix test then no error is thrown but tests run as Run 0 test in 0.00s
correct. you're right. And that is why he used to prefix test
Hello Raghav Da, Thanks for this amazing tutorial. I could follow most of it without any problem but facing a bit of issue when calling the loginpage class in my logintest. So when ever I am creating an object of that class it is throwing error because of the parameters called. Its says the parameter is unrecognized. When looking for the suggestions I am getting the parameter as "driver=".
I am not sure what should be the value of the driver, what should I put after equals sign.. when calling it in the test class, can you please help?
Thank you so much.
Binita
Binita
When working with the Page Object Model (POM) in Selenium Python, you need to pass the WebDriver instance (the browser driver) to your page classes. Let’s address this issue:
1. Passing WebDriver to Page Classes:
- In POM, each page class should have a `WebDriver` object as a class member. This allows you to interact with web elements on that page.
- You can pass the `WebDriver` instance as a parameter to the constructor of your page class.
2. Example Implementation:
- Suppose you have a `LoginPage` class. Here's how you can pass the `driver` to it:
```python
from selenium import webdriver
class LoginPage:
def __init__(self, driver):
self.driver = driver
# Other page elements and methods go here
# Usage in your test class:
driver = webdriver.Chrome() # Initialize your WebDriver (e.g., Chrome, Firefox, etc.)
login_page = LoginPage(driver) # Create an instance of LoginPage
```
3. Page Factory (Optional):
- If you're using Page Factory (a part of POM), you can simplify this further:
```python
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class LoginPage:
def __init__(self, driver):
self.driver = driver
# Initialize page elements using @FindBy annotations
# Usage in your test class:
driver = webdriver.Chrome()
login_page = LoginPage(driver)
```
Remember to adjust the class name (`LoginPage` in this example) to match your actual page class
--
This is exactly what I needed, thank you very much for such a clear explanation!
Most welcome Jose Luis
Hi there, I had a question. In what scenarios will running the tests from command line be helpful ? Doing that seems like more work when we can just run it from the IDE 😅
Jele
Let's break down the scenarios where running Selenium tests from the command line can be helpful:
I am added all details. it can be long but i hope will help everyone in future...
Scenario 1: Automation and CI/CD Pipelines
When you're working on a large project, you might want to automate the testing process as part of your Continuous Integration and Continuous Deployment (CI/CD) pipeline. Running tests from the command line allows you to integrate your tests with tools like Jenkins, Travis CI, CircleCI, or GitHub Actions. This way, your tests can run automatically whenever code changes are pushed to your repository, ensuring that your code is tested thoroughly before deployment.
Scenario 2: Multi-Environment Testing
Imagine you need to test your application on different environments, such as different browsers, operating systems, or mobile devices. Running tests from the command line allows you to easily switch between environments by modifying the command-line arguments or environment variables. This can be more efficient than constantly changing settings within your IDE.
Scenario 3: Distributed Testing
When you have a large test suite, running tests in parallel can significantly reduce the overall testing time. Command-line execution enables you to distribute your tests across multiple machines or containers, making it easier to scale your testing efforts.
Scenario 4: Headless Testing
Sometimes, you might want to run your tests in a headless mode, without displaying the browser UI. Command-line execution makes it easy to run tests in headless mode, which can be useful for testing in environments where a display is not available or when you want to reduce the resource usage.
Scenario 5: Scheduled Testing
You might want to schedule your tests to run at specific times or intervals, such as nightly or weekly. Command-line execution allows you to use tools like cron jobs (on Linux/macOS) or Task Scheduler (on Windows) to automate the testing process.
Scenario 6: Remote Testing
When working in a team, you might want to run tests on a remote machine or a cloud-based infrastructure. Command-line execution enables you to run tests remotely, making it easier to collaborate with team members or use cloud-based testing services.
Scenario 7: Debugging and Troubleshooting
When debugging issues, running tests from the command line can provide more detailed output and error messages, making it easier to identify and troubleshoot problems.
While it's true that running tests from the IDE can be more convenient, there are scenarios where running tests from the command line provides more flexibility, scalability, and automation capabilities
-
How can I solve this error?
TypeError: LoginPage () takes no arguments
at login = LoginPage (driver)
Hi Tavo, pls check your LoginPage class and its constructor. Most probably, you have not taken any arguments in the constructor
Hi Raghav, I see that you have used HtmlTestRunnerfor generating the reports but this does not seem to work with python 3.0+ is there any other alternative?
Hi Vishal, can check the ver that works with Python3, pypi.org/project/HTMLTestRunner-Python3/
I have one general question regarding writing test cases. Suppose if we are testing a form and if it has 2 inputs (login and password) then should we write all the test cases for it?
1) Valid Login name, Valid Password
2) Valid login name, Invalid Password
3) Invalid Login name, Valid Password
4) Invalid Login name, Invalid Password
Hi Nandish, yes you can cover all possible scenarios. A data driven test will be better here where you can get the data drom a external file like excel
@@RaghavPal thanks. But suppose if there are 16 input items in the form then i think there will be thousands of test cases if we follow the same approach.. So how to write test cases in that scenario?
Sorry for late reply Nandish, I believe the test is same and the data varies, In that case data-driven test OR getting data from an external file is the best option.
how to open the orangehrm site with english text, it is opening for me in chines language?
Hi Srinivasa, its from the backend, you can use these to practice
opensource-demo.orangehrmlive.com/
trytestingthis.netlify.app/
I really liked the quality and patience with which he teaches. Please, if you could continue with more advanced cases. Greetings from Peru!
Hi Fraven, sure I will
Excellent video. Neat & Clear. You are good in teaching. Best video to learn Page Object Model for Python Selenium
Glad & humbled to know this Dinesh
Hello, Raghav!
This video is very useful for me.
I'm a newbie in Selenium, and here are my questions:
1) 50:59 - We should write "message = driver.find_element_by_xpath("//span[@id='spanMessage']").text" instead of "message = driver.find_element_by_xpath("").text". Am I right?
2) 50:31 - We don't call the function "check_invalid_username_message" anywhere. Is it ok? When should it be called?
1) Yes right
2) You can call it wherever you need in your test. In case you do not need do not call
Hi , I see a lot of people have blocked on unresloved error problem for import: ImportError: No module named SampleProjectPOM.POMDemo.Pages.LoginPage
but it seems that there is no solution posted yet :(
could some one help ? (for info, even when marked the floder as sources ROOT it doesn't work)
thank you in advance :)
Hi Saber, I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.html. Please check.
Start your command with python -m pytest
Please check this:stackoverflow.com/questions/10253826/path-issue-with-pytest-importerror-no-module-named-yadayadayadagithub.com/pytest-dev/pytest/issues/2287
Hi Raghav, Thank you so much for the tutorial.But when I try to import HTMltest runner in pycharm which is already installed via cmd, shows not installed and when I try to install the package in Pycharm, getting following error.
Collecting HtmlTestRunner
Could not find a version that satisfies the requirement HtmlTestRunner (from versions: )
No matching distribution found for HtmlTestRunner
Please help.
Hi Shilpa, can you check the documentation for HTML runner and see the supported python versions.
Hi Raghav,
Thanks to put this selenium framework using POM| Unit test| HTML reports. It was really helpful video for a beginner like me who are keen to learn about developing a sustainable framework.
This video is really well structured and organized that can help anyone who does not have any prior knowledge in framework development.
Coming to my query, I have imported HtmlTestRunner module and even added the report path in unittest.main().
But, when i am trying to run the script in cmd, it shows the following error :
Traceback (most recent call last):
File "C:\Python38-32\lib
unpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Python38-32\lib
unpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "C:\Users\Anjali\PycharmProjects\Selenium-Framework\DemoProject\POMProjectDemo\Tests\login.py", line 5, in
import HtmlTestRunner
ModuleNotFoundError: No module named 'HtmlTestRunner'
Can, You tell me where i am making mistake.
Thank you in advance : )
Hi Anjali, so happy to know this. Keep learning and also help others
Solution for error message on running the invalid test on 53:00 :
Needed to give parameters as so :
message = driver.find_element_by_xpath(login.invalidUserName_msg_xpath).text
instead of :
message = driver.find_element_by_xpath("").text
In the login.py file :P
Thanks for adding Gilad
@@RaghavPal Thanks for making awesome content!
Getting issue in HtmlTestRunner PFB error
I tried upgrading my python to latest version after this error still didn't solve for me could any one please help.
"Could not find a version that satisfies the requirement HtmltestRunner (from versions: none)"
Hi Bhupendra, could not find any specific solution online. In the documentation page - pypi.org/project/html-testRunner/ it says can work with Python 3.5
Hello sir, Could you please make a video on selecting dependant drop down values in an array which is for example if you select one drop down value then another drop down should appear in the UI so that I can select the next drop down value. Currently I am facing problem in automating this in python
Hi Prabhu, I will plan to have a session on this, In case you have some demo website, can send me the link
nice 1, waiting for the video of reading test input like username, password from the CSV file.
will do i† soon
Automation Step by Step - Raghav Pal thank you so much :)
Hi Raghav, Thank you very much for your tutorial. I want to capture screenshot when the test case fails and i want to add same screenshot to the html report. Is this possible in selenium-python? if yes, please help me how can I do that.
Hi Raghav, Any luck on this?
Hi Amaresh, you can use PyTest. This will help - www.automationtesting.co.in/2017/02/pytest-with-selenium-html-report-with.html?m4dc=1
stackoverflow.com/questions/50534623/how-do-i-include-screenshot-in-python-pytest-html-report
Have Enjoyed your session and learned lot sir. There is small mistake in xpath that you didn't call the function "check_invalid_username_message ".
I will check Kamalnath. Thanks for watching
Thanks a lot bro, Your videos are always Excellent. Please make videos on Serverless AWS.
Can i get full paylist link?
Sure, pls check here - automationstepbystep.com/
Raghav, can you please make a video on how to explain our framework with respect to OOPS concepts.
Sure Akshat, you may find some tutorials on programming and OOPs here - automationstepbystep.com/
Hi Sir,
For following code I am getting error as : 'Config' object has no attribute '_metadata'
def pytest_configure(config):
config._metadata['Project Name'] = 'Vyrill'
config._metadata['Module Name'] = 'Admin Dashboard'
config._metadata['Tester'] = 'Rahul'
Could you please give me a solution on this? I am using
python: 3.6.8
pytest: 4.6.11
Thanks!
Hi, can check this github.com/conda/conda-build/issues/3093
Hi Raghav, i tried to generate html report, but after running on mac os, this report can't generate?
testRunner=HtmlTestRunner.HTMLTestRunner(output='/Users/fawzi/PycharmProjects/pythonProject1/reports', report_name="Login Report", report_title="Login Report", add_timestamp=True))
this is correct?
Hi Fawzi, will need to see the logs and error report, meanwhile compare your syntax and path
im getting below error
File "C:\Users\arumugam001\PycharmProjects\SeleniumDemo\RW\Test\login.py", line 21, in test_login
driver = self.driver
AttributeError: 'LoginTest' object has no attribute 'driver'
Hi Siva, pls check again, you may be missing some import
Hi Raghav,
Facing below error :-
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
Hi Nitesh, There can be multiple reason behind this error:
Presence of anti-virus softwares.
Firewall blocking the ports.
Network Configuration.
Problem can be caused by CORS.
Due to enabling of HTTP keep-alive connections
this can help - stackoverflow.com/questions/51562067/connectionabortederror-winerror-10053-an-established-connection-was-aborted-b
Raghav, i'm geting an error msg while executing the tests with Pytest: FAILED Test_duck.py::TestDuck::test_search - AttributeError: 'TestDuck' object has no attribute 'driver'
what's the problem with the driver? Thx
Hi Federico, some issue where you created driver instance, can check this sqa.stackexchange.com/questions/46901/attributeerror-testone-object-has-no-attribute-driver
Hello Raghav, thank you for this video, it's the best I've come across on the topic. I've followed your video and keep getting the "ModuleNotFoundError" when I try and run the tests :(
I have the tests and page objects in different folders and import the page objects class into the tests, I've also looked online for a solution, tried all I could. Still getting that error.
Could you advise please?
Many thanks!
Hi, I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.html.
from POMProjectDemo.Pages.loginPage import LoginPage
ModuleNotFoundError: No module named 'POMProjectDemo' in vs code kindly why we get plz provide solution 35:39
Hi Ram,
I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.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 sir, I had import error on implement POM Please give me a solution.
SampleProject.POMProjectDemo.Page.loginPage import LoginPage
ImportError: No module named SampleProject.POMProjectDemo.Page.loginPage
Hi Pooja, I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.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 Raghav,
I was able to debug this error. I ran my test script via pycharm terminal and it successfully ran and generated HTML report.
But i still wants to know why it was throwing error when i tried to run from cmd.
Please, give your valuable input and resolve my query. : )
Hi Anjali, is this referred to some previous comment. You can reply on the same comment thread, so I can get the context.
Hi Raghav , thanks for sharing . In my opinion I would prefer : visibility_of_element_located rather than presence_of_element_located coz I first wait for the visibility of the object and then yes I interact with that element.
ok, sure can go with what is best for your needs and project requirements El
Hi Raghav 👋 .I am trying to apply the page object pattern. My problem is that I do not get an autosuggestion when typing self.driver. After the . I should see suggestions, but I am not; however if I were to run the program it run without any problem. Any solution
Hi, you can try to restart Pycharm and check again
i can somehow call out method from another file but the code isn't running saying that it doesn't find the module despite the fact that I've changed directory of module package either by import sys ... edit enviroment in windowds or run launch.json and settings.json. I'm kinda hopeless at this point. I rly want to finish this project but i cannot go past this problem in VS code.
Hi Łukasz, pls check this github.com/microsoft/vscode/issues/10391
What if I create like in Java a "base_class.py" with the selenium driver instance and the set up methods in it? I got this question because the way you're teaching, we will need to code in every test class driver = webdriver... driver.implicity.... and I have learned that when we are repeating code, there is something not planned. What is your point?
Hi Danilo, yes you can create a base class where web driver is instantiated, i will cover this in some future video.
@@RaghavPal Cool! Great videos by the way!!!
Hi Ragav. I have 1 queries. Curently I am using pyautogui for screenshot. It's taking screenshot for the browser window where the script is running. But while execution if I minimise the browser window and open any other application then execution still run but it capture the other app window as screenshot
Can you suggest how I can take the screenshot even if I minimise the browser. I mean if execution run in background in that case how to take that screenshot
Hi Neelambika, you may try some other libraries for screenshots. Check this
pythonbasics.org/selenium-screenshot/
www.geeksforgeeks.org/how-to-take-screenshot-using-selenium-in-python/
stackoverflow.com/questions/41721734/take-screenshot-of-full-page-with-selenium-python-with-chromedriver
I have a small question. Around @11:39 in the video you have used find by link text. Now if I have multiple links of same text (like a click here text but at multiple places in a same page table), but dont have any identifier like id or class is there anyway to access one particular link?
Hi Loga, in that case you can use index value
thank you for amazing video! is there an equivalent of pom.xml in java for python?
In Python, there isn't a direct equivalent to pom.xml. However, alternatives like requirements.txt, setup.py, and pyproject.toml serve similar purposes. These files specify dependencies, metadata, and build settings for Python projects
Hi Raghav,
I have one doubt-if i am running my test script from command line reports are generating but if i am trying to run from Pycharm i m not getting the reports (not generating)..
You can find my code @ github.com/anand032111/google_selenium/blob/master/UnitTest.py
Please help me in this
Hi Anand for the specific way shown, this generates from command line pytest command only. You can find other ways and libraries for report generation
Hello, Awesome video I'm using Pycharm, and I did "pip install Selenium" and I have Anaconda Python - trying to automate Testcases using these tools, getting a 'Unresolved reference' error when I import Selenium webdriver. Am I missing any step here...pls could you give your input. Thanks
Hi Ambika, You can check the library is added in the project or interpreter.
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)
@@RaghavPal I tried the above steps getting a SSL certificate error....Thanks
Hi Ambika, pls try to see some online solutions for this
Great tutorial. Completely understood. The only thing is that ,for me in loginpage, homepage class if i do self.driver. ,then no option for find elements was showing, i have done it manually and its working fine. This is strange.
Hi Tapas, you might have imported the class with all properties
Every video I have watched teaches POM in a half baked manner. Its like info here is not wrong but its incomplete and thus steers people the wrong way because once they learn this - its hard to unlearn and do it right (that's assuming they even will continue try to improve their skills in page objects, most will just assume this is the only way).
Hi Artur, you can provide more details. It will help all
Excellent Tutorial Raghav, Could you please tell me why we use constructor here?
Hi Pradeep, constructor is called whenever we create a object of the class. We make use of this property to force user to provide some parameters while creating objects
Amazing quality, eventhough is old version of selenium if you know how to set up new on this will give you a complete Idea how to work with each topic, If you a have some projects we can practice this topic please let me know.
Sure, will check on that
Could please suggest me Build tools for Python selenium
And for Ci tool
Hi Keisha, for build tool you can use PyBuilder - pybuilder.github.io/
Also check this - packaging.python.org/guides/tool-recommendations/
For CI Jenkins is good
I exactly followed this for my project but while login test am getting attribute error, it is not allowing me to have a 'driver' as an attribute. Can someone help me.
Hi Ajith, looks like some setup or syntax issue, check the code again with the example, can try some online examples as well
hi Raghav
had a query , can we able to add all locators in a different file under the project and able to import to the current file?
rather than giving locators straight away as pointed in the above video?
Hi, yes, that's how we do Page Object Model, you may find it in some of my videos automationstepbystep.com/
I haven't seen that much crystal clear concept explanation... l'm fascinated by your teaching style and content provided by you... Thanks alott Sir👍
You're very welcome Sandip
Very nice video. what is the use of unittest here if I don't use unittest can't I use selenium with classes? in production unittest should be used ? please clarify my doubts thank you.
Hi, you can use any testing framework as per your needs
One problem i see here that we are not getting auto suggestions for the driver object for its method in POM structure any solution or reason for this? if the project is big where we need to write lot of wrappers and different selenium methods its very difficult to manage without auto suggest
Hi Pritesh, just check all lib are added and try to restart pycharm.
Thank you so much for doing fantastic job, I am watching your all automation related videos and learned a lot.
So happy and humbled to know this Manish.. keep learning
Thanks for your video! i am already watching this video 10 times!! this is very useful video!
So happy to know
Hello Raghav ....i have implement this code in pycharm but it didn't work it and the url is not open in browser also can you please help me
Hi Komal, will need to see error details and logs to troubleshoot
Hi Mr Raghav, in my HTML report i see unwanted values displayed along with result status. How to remove those?
something like these
(function() { var ws = new WebSocket('ws://' + window.location.host + '/jb-server-page?reloadMode=RELOAD_ON_SAVE&'+ 'referrer=' + encodeURIComponent(window.location.pathname)); ws.onmessage = function (msg) { if (msg.data === 'reload') { window.location.reload(); } if (msg.data.startsWith('update-css ')) { var messageId = msg.data.substring(11); var links = document.getElementsByTagName('link'); for (var i = 0; i < links.length; i++) { var link = links[i]; if (link.rel !== 'stylesheet') continue; var clonedLink = link.cloneNode(true); var newHref = link.href.replace(/(&|\?)jbUpdateLinksId=\d+/, "$1jbUpdateLinksId=" + messageId); if (newHref !== link.href) { clonedLink.href = newHref; } else { var indexOfQuest = newHref.indexOf('?'); if (indexOfQuest >= 0) { // to support ?foo#hash clonedLink.href = newHref.substring(0, indexOfQuest + 1) + 'jbUpdateLinksId=' + messageId + '&' + newHref.substring(indexOfQuest + 1); } else { clonedLink.href += '?' + 'jbUpdateLinksId=' + messageId; } } link.replaceWith(clonedLink); } } }; })();
Will need to check the setup Sudharshan, Can also try using a diff version
This video is very very helpful for me I learned from here about POM and how to define class in main file , Thank you
Great to know this. All the best
TypeError: LoginPage() takes no arguments
all code is ok but sitll eror
plz guide me
Hi Agha, will need to check the setup and details
Excellent. Kudos For your Hardwork Man...
Thanks Ahmed
Awesome! Thanks a lot for this very interesting and clear course. I've recommended collegues and friends to watch these videos.
Awesome, thank you! Find more here - automationstepbystep.com/
Hi Ragav,
I follow up on this sample project creation, but I'm getting an error. please help me to resolve this
I changed the edit configuration to run as unit test after a run through the unit test, I'm unable to execute the code
Launching unittests with arguments python -m unittest C:/Users/PremataS/PycharmProjects/pythonProject/Sample_Project/POM_Demo/Tests/Create_Account.py in
C:\Users\PremataS\PycharmProjects\pythonProject\Sample_Project\POM_Demo\Tests
Ran 0 tests in 0.000s
OK
Process finished with exit code 0
Empty suite
Empty suite
Hi Shehani, while using pytest, pls check your file, class and function names.
File name - test_*.py or *_test.py
Class name - prefixed with Test
Function name - prefixed with test
Can do the setup again and check
@@RaghavPal Thanks for the instruction Ragav. It is working fine now.
there is no function self.browser.find_element_by_id in Python 4 and there's self.browser.find_element(By.ID, "btnLogin") instead. How should I change self.browser.find_element_by_id(self.username_textbox_id)?
HI Lilia, I will check for Python 4 and add new sessions, For now, if you need to use Python 4, check the latest Selenium Python 4 documentation
www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/
@@RaghavPal thank you so much. Do you have GitHub with all the lesson’s codes by any chance?
Can check there Lilia - automationstepbystep.com/
After using the command in Windows 10 CMD(Command Prompt) C:\Users\my.name\PycharmProjects\PROJECTNAME\Tests>python -m unittest login.py
I got an error:
ImportError: Failed to import test module: login
Traceback (most recent call last):
File "C:\Users\my.name\AppData\Local\Programs\Python\Python37-32\lib\unittest\loader.py", line 154, in loadTestsFromName
module = __import__(module_name)
File "C:\Users\my.name\PycharmProjects\PROJECTNAME\Tests\login.py", line 4, in
from Pages.loginPage import LoginPage
ModuleNotFoundError: No module named 'Pages'
How to solve that?
Hi Arunas,
I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.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)
@@RaghavPal Oh My God! God bless You. Thank you!
Could you please explain how to integrate build management tool like maven with python selenium?
I will plan on this Rishav
what if the classes have same name when web scrapping using selenium python. kindly reply.
Hi Ashwini, not sure on scrapping, will have to take online help
When I try to run POM project on Windows 10 using Google Chrome v76.0 (64-bit). I am getting error below message:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome version must be between 70 and 73
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 10.0.18362 x86_64)
Is anyone run into this issue before?
So to continue with this lesson I have decided to use Firefox v69.0 (64-bit) and the same project is running fine.
Hi, this is issue with chrome ver. Try to use a diff ver of chromedriver.exe
@@RaghavPal Thanks Raghav.
When I try to run LoginTest using Firefox v69.0 (64-bit) using 'import HtmlTestRunner'. I am getting following error message:
ImportError: Failed to import test module: login
import HtmlTestRunner
ModuleNotFoundError: No module named 'HtmlTestRunner'
I have also verified thru command prompt that my machine contains html-testRunner v1.2.1, selenium v3.141.0, py v1.8.0, pip v19.2.3.
Can someone please help me to resolve this issue?
Hi, 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)
@@RaghavPal Thank you Raghav for your reply. After inserting html-testRunner package to PyCharm I am now able to run my script. Thanks again for your help.
Hi Raghav,
I was facing issues in understanding the concept of POM in selenium Python, your tutorial above has cleared all my doubts and implementation of POM in selenium Python Raghav, thx a ton for helping us out with such useful videos on testing stack, Raghav, the above POM what ever has been explained in the video is without using Page Factory ryt?? correct me if i'm wrong.. Can u kindly explain the same above example and concept by also using page factory and POM as well in selenium python.. It would be really useful for us ...
Thanks in Advance,
Siddhee :)
Happy to know this Siddhee, will do a session on Page Factory too
@@RaghavPal Thanks a ton Raghav :), will be waiting for your tutorial on Page factory model in selenium python, kindly do let me wen u upload it.. and also i have to admit whenever ppl have doubts/questions u always took that extra initiative in replying to each and everyone whoever has doubts and commented..that virtual help is much needed and thanx a ton again Raghavv :)
Thanks in Advance,
Siddhee :)
Hello sir, i want to implement POM with pytest. is there any video available?
I may not have specific video, but you can follow this and add pytest..but these steps will help you:
1. Set Up Your Environment:
- Install Python: Make sure you have Python installed on your system. You can download it from the official Python website.
- Install PyCharm (or any other preferred IDE): PyCharm is a popular IDE for Python development.
2. Create a New Python Project:
- Open PyCharm and create a new Python project.
- Set up a virtual environment for your project.
3. Install Required Packages:
- Install the necessary packages using pip:
```
pip install selenium pytest
```
4. Create Page Classes:
- Create a package (folder) named `pages` within your project.
- Inside the `pages` package, create a Python file for each webpage you want to automate. These files will serve as your Page Classes.
- In each Page Class, define the web elements (locators) and methods to interact with those elements. For example:
```python
# Example Page Class for a login page
class LoginPage:
def __init__(self, driver):
self.driver = driver
self.username_input = "username_locator"
self.password_input = "password_locator"
self.login_button = "login_button_locator"
def enter_credentials(self, username, password):
self.driver.find_element_by_id(self.username_input).send_keys(username)
self.driver.find_element_by_id(self.password_input).send_keys(password)
def click_login_button(self):
self.driver.find_element_by_id(self.login_button).click()
```
5. Write Test Cases:
- Create a package (folder) named `tests` within your project.
- Inside the `tests` package, create Python files for your test cases.
- In each test case, instantiate the Page Classes and use their methods to perform actions on the webpages.
6. Write PyTest Test Functions:
- In your test files, write PyTest test functions.
- Use the `@pytest.fixture` decorator to set up and tear down the WebDriver instance.
- Example:
```python
import pytest
from selenium import webdriver
from pages.login_page import LoginPage
@pytest.fixture
def setup():
driver = webdriver.Chrome(executable_path="path/to/chromedriver")
yield driver
driver.quit()
def test_login(setup):
driver = setup
login_page = LoginPage(driver)
login_page.enter_credentials("your_username", "your_password")
login_page.click_login_button()
# Add assertions to verify successful login
```
7. Run Your Tests:
- Open the terminal in PyCharm and run your tests using the following command:
```
pytest
```
8. Review Reports:
- PyTest generates HTML reports with test results. You can find them in the `reports` folder (create this folder if it doesn't exist).
Remember to replace the example locators and test data with your actual application's details.
Thank you for this great tutorial. Do you have any tutorial about Appium?
Hi Sam, thanks for watching Appium will be coming soon
This video is very Helpfull, I tried the same using Locater model and successfully wrote a Page object model for entering the data into a website, But I am facing some difficulties in Web scraping syntax. Could you please help me with the syntax
I am using this
def getPrice(self):
return self.driver.find_element_by_xpath(loc.Price).text
Please help me with this!
Hi Gowtham, I will have to check and prepare for this. Will try but can take some time
@@RaghavPal Thank you so much for the timely reply, I just figured out the Syntax,
def getPrice(self):
return self.driver.find_element_by_xpath(loc.Price).text
we have to call this in the script as
page.getPrice()
Hi! Login page gives message "invalid credentials". Can you fix it?
Can try a different app
can you help with data provider - how to run with different data parameters in python selenium
I will plan for a session Akash
Hi, Raghav. I am stuck at "Selenium Python Small Sample Project | Page Object Model POM" at 43:05. My Command Prompt still saying "No module named 'SampleProjects''". I have tried all of the options and none of them worked. Please, help. Thank you.
Hi Muslima,
I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.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)
@@RaghavPal Thank you so much.
Do you have an example of how get the size of Table and dynamically create a path.
Hi Jeffrey, not as of now
Hello, Raghav. Thank you for a great tutorial. I have a problem with importing class. //from Selenium.POMProjectDemo.Pages.LoginPage import loginPage -- gives me an error that No module named 'Selenium'.
Hi Namik, I have shown the solution in this video from ua-cam.com/video/BURK7wMcCwU/v-deo.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)
@@RaghavPal Thank you very much, I find the solution from your video description)). import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "D:\python\Selenium\POMProjectDemo\Tests", "D:\python\Selenium\POMProjectDemo\Pages"))
It is working.
is tab spacing not required as we discussed in one of the previous sessions?
can you please clarify
Hi, it will be needed
Thanks Raghav, it is really awesome lesson. I can get "find_element_by_??" in the loginPage.py. How to access "find_elements_by_??" methods in loginPage.py. I can get "find_elements_by_??" in test class only. Please provide guideline Thanks Javed
Hi Javed, you can extend test class in loginPage (Inheritance). Pls check a example of inheritance here - www.w3schools.com/python/python_inheritance.asp
@Raghav Pal I am facing the same problem
@@RaghavPal but you didn't any inheritence there
No, but it can be done
Very good tutorial , any video how to create a web from basic by sampling
Hi Awaluddin, what exactly are you looking for, Can check the tutorials here - automationstepbystep.com/
Excellent tutorial!!! Thank you very much!!!
Most welcome Andres
Great video. Could you please add on to this video by showing how to implement Behave into a framework like this? Thank you!
Hi Tim, sure I will work on this in some time
This video is so lucid. Thank you! one doubt- reports are not generating for me. I am running script from IDE. Is it necessary to execute script using command prompt in order to get the report generated? Please answer.
Hi Sweta, thanks for watching, there are some reporting lib that work from cmd line I must have shown some examples may be in later videos on how to generate reports from IDE
@@RaghavPal thanks a lot, Raghav. I generated default report from the console. That also helped me. 😊
Excellent
Thanks RK
HI Raghav I want to learn Selenium step by step can you contact me
Hi Ankit, you can check the training here - automationstepbystep.com/
Yes Sir, it is really helpful.
Thank you very much 😊
Most welcome
It is opening new tab with existing chrome session and not opening new Chrome browser for me. also not feeding the URL and throwing error as "selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed" could you please help?
Windows 10 - sony vaio
Package Version
--------------- -------
behave 1.2.6
cx-Oracle 7.1.3
html-testRunner 1.2
Jinja2 2.9.5
MarkupSafe 1.1.1
parse 1.12.0
parse-type 0.4.2
pip 19.0.3
selenium 3.141.0
setuptools 40.8.0
six 1.12.0
urllib3 1.25.2
Hi Mani, try using a diff ver of chrome driver
Hey, good Tutorial!
But I have one problem. Sometimes, when I inspect an element, it has no ID or name. How can I still define it for my program?
Thanks
You can generate an xpath for it. Watch this video - ua-cam.com/video/8V74PsFupis/v-deo.html
Great! Thank you so much!
Hi sir, I am not able generate HTML report even after using "import HTMLTestRunner". In command prompt it says the requirement is satisfied. Please help
Hi Prabhu, pls check if you installed the library using -g argument, this is for global
Can try to reinstall and check
@@RaghavPal Thanks for the reply. It's working now
please mentioned that install pycharm and please also start from new so we can understand it
Sure Keya
Hello Sir and all... i have a question - how to run same unit test for two different IP address or URL?? how can iterate the code by passing two URLs
Hi Mahesh, you can do a data driven test and loop for the rows of data
@@RaghavPal thank you so much Raghav. I am new to selenium. But it helped me alot.
Raghav, how to do same unit test set up in VSCODE IDE ?
I will check and plan a session for that, For now can check some examples online
Wonderful tutorial! Btw I got this problem. Everything ran just fine in PyCharm but when I tried to run the test in cmd, I got ModuleNotFoundError and it indicated that when importing HomePage, it can't find module "SampleProject" (from what I have imported: from SampleProject.POM.Pages.home_page import HomePage). I hope you see my comment and maybe give me some recommendations. Many thanks Raghav !
Hi Tai
The ModuleNotFoundError typically occurs when the Python interpreter cannot find the module you are trying to import. This issue can arise due to different factors, such as incorrect module structure, incorrect module name, or incorrect PYTHONPATH configuration.
Here are some steps you can take to resolve the ModuleNotFoundError issue:
Verify the module structure: Double-check the directory structure of your project, specifically the location of the SampleProject module. Ensure that the module is located in the correct directory and that its name is spelled correctly.
Check import statement: Verify that the import statement is correct and matches the module structure. Ensure that the module name (SampleProject) matches the actual module name and that the file (home_page.py) exists within the module.
PYTHONPATH configuration: Check the PYTHONPATH environment variable to ensure it includes the directory where your SampleProject module is located. The PYTHONPATH variable tells the Python interpreter where to search for modules. You can set it as an environment variable or within your script using sys.path.append().
Run the script from the correct directory: Make sure you are running the script from the correct working directory. If your script relies on relative imports or assumes a specific directory structure, running it from a different location can cause import errors.
Check Python interpreter: Ensure that the Python interpreter used in PyCharm is the same as the one used in the command prompt. If you are using a virtual environment in PyCharm, make sure the same virtual environment is activated in the command prompt as well.
Install dependencies: If the SampleProject module relies on any external dependencies, ensure that those dependencies are installed in the Python environment you are using in the command prompt. You can use pip install to install any missing dependencies.
By following these steps, you should be able to resolve the ModuleNotFoundError issue and successfully run your Selenium Python project in the command prompt.
@@RaghavPal Hi Raghav, thank you so much for your advice, I fixed it! However, I got a new problem. Whenever I tried to run the whole file, the 1st test case ran well but it cannot run the next test case and cause error: selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id. I think there are something wrong with the tearDown method cause if I comment the cls.driver.close() and cls.driver.quit(), all the test case ran fine. But yes, if the tearDown has nothing in it, it's not a good practice for selenium. So do you have any ideas? Tysm again
The "invalid session id" error typically occurs when the WebDriver session is closed or terminated before attempting to execute another test case. This can happen if you explicitly close or quit the WebDriver session in the tearDown method.
To resolve this issue, you can modify your tearDown method to handle the WebDriver session appropriately. Here are a few suggestions:
Separate the tearDown method for each test case: Instead of having a common tearDown method for all test cases, create a separate tearDown method for each test case. This way, the WebDriver session will be closed after each test case, ensuring a fresh session for each test.
Use the tearDownClass method: Instead of using the tearDown method, you can use the tearDownClass method, which is called once after all the test cases in the test class are executed. This way, the WebDriver session will be closed after all the test cases are completed.
Handle exceptions in the tearDown method: If you want to continue executing the remaining test cases even if an exception occurs in a specific test case, you can catch the exception in the tearDown method and handle it gracefully. This way, the WebDriver session will still be closed properly, allowing the subsequent test cases to run.
Here's an example of how you can modify your code:
import unittest
from selenium import webdriver
class MyTestClass(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Chrome()
cls.driver.maximize_window()
def test_case1(self):
# Test case 1 code
def test_case2(self):
# Test case 2 code
@classmethod
def tearDownClass(cls):
cls.driver.close()
cls.driver.quit()
if __name__ == '__main__':
unittest.main()
Make sure to adapt the code to fit your specific test case structure. By properly managing the WebDriver session in the tearDown or tearDownClass methods, you should be able to avoid the "invalid session id" error and execute multiple test cases successfully
Thank You Raghav it's Informative
Thanks and welcome Naga
Everything works fine except Html reports, followed exact same steps, but reports are not getting generated (MAC os)
Hi Biplab, what is the error. Also check again with the video, if any step was missed
@@RaghavPal Hey Thanks for quick reply, i was running the old configuration in pycharm, hence the __main__ section wasnt getting executed, I ran from terminal, and was able to generate the reports. This tutorial was very informative, Thanks a lot
Could you please share if you have any training on writing feature test cases with Selenium in Python using POM
Can you please tell this framework name?
Hi Sathish, it is a modular POM framework
Hi, can I ask why the orangeHRM demo page is not in English? Is it only me? The webpage is in Spanish or something. How can I change this?
Hi Heather, try this - opensource-demo.orangehrmlive.com/. It is a public demo website, so cannot control it.
Automation Step by Step - Raghav Pal
Raghav is there a way you can show in Bdd with pageobject
wonderful video, thankyou veryyy much
You're welcome
This is a great tutorial, helped me to build a framework on my own. Thank you. I do have a question. How do I read text on a button on a page? I tried using find_element_by_name but it don't work.
Use this..
Element = driver.find_element_by_id("some name")
Print(Element.text)
Hope dis will help you...
Thanks for your inputs Satheesh. Neha, hope this is useful
Satheesh Kumar Thankyou for your help. In my case there was no id on the button so I finally used the combination of name and value as it is unique and it worked.
@@RaghavPal @Satish I got the other issue working however now I am facing another big issue. How do I check for the existence of a modal/dialog. It is not an alert so I cannot use switch_to alert method. The html element I am speaking of has following arguments: role=dialog aria-labelledby=label aria-describedby=description. Any hints wold be highly appreciated. Thank you.
Hi Neha, is this site accessible publicly? You can check this
stackoverflow.com/questions/19003003/check-if-any-alert-exists-using-selenium-with-python
huddle.eurostarsoftwaretesting.com/selenium-interact-modal-windows/sqa.stackexchange.com/questions/26130/java-selenium-check-if-modal-popup-present
how can i read data in send keys from excel again and again?? could you please explain
Hi Ataullah, This will help - allselenium.info/read-data-from-excel-in-python-scripts/
@@RaghavPal Hi Raghav Thank you for your reply, can i have a personal coaching for selenium python?
if you can i would be grateful to you
Hi Ataullah, I will plan to take personal classes in some time. As of now you can refer the tutorials here automationstepbystep.com/