1 | Getting Started | Project Setup | Selenium Python
00:00 - Introduction
00:28 - Step 1 - Check Python: already installed python --version pip --version
02:00 - Step 2 - Install Python: download Python from www.python.org | Run the installer
11:57 - Step 3 - Install PyCharm: goto www.jetbrains.... download the Community Edition
18:53 - Step 4 - Create New Project: Open PyCharm > File > create new project
26:04 - Step 5 - Add Selenium: PyCharm: File > Settings ("Preferences" on macOS) > Project > Project Interpreter
Click ‘+’ to add new package (can also add globally from command line)
Install selenium and webdriver_manager
32:48 - Step 6 - Create 1st Test: Right-click on the project folder and select New > Python File
Add code for selenium test
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
import time
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
driver.get("google.com")
time.sleep(2)
driver.close()
driver.quit()
40:18 - Step 7 - Run and Check
Python virtual env - • Try this way to create...
All Free Tutorials - AutomationStep...
▬▬▬▬ USEFUL LINKS ▬▬▬▬
Ask Raghav - bit.ly/2CoJGWf
Shorts Eng - bit.ly/3H9bifV
Shorts Hindi - bit.ly/3XY7XqN
GitHub Repositories - github.com/Rag...
Udemy - automationstep...
Stories - automationstep...
▬▬ CI | CD | DEVOPS ▬▬
Jenkins Beginner - bit.ly/2MIn8EC
Jenkins Tips & Trick - bit.ly/2LRt6xC
Docker - bit.ly/2MInnzx
Jenkinsfile - bit.ly/3JSMSZ7
Kubernetes - bit.ly/2MJIlMK
Vagrant - bit.ly/3MVKdBt
Ansible - bit.ly/3MUsY3h
▬▬ UI TESTING ▬▬
Selenium Beginners - bit.ly/2MGRS8K
Selenium Java Framework from Scratch - bit.ly/2N9xvR6
Selenium Python - bit.ly/2oyMp5x
Selenium 4 - bit.ly/3AiJOlP
Selenium Tips - bit.ly/2owxc50
Selenium Builder - bit.ly/2MKNtlq
Katalon Studio - bit.ly/2wARFdi
Robot Framework with RIDE- bit.ly/2Px6Ue9
Robot Framework with Eclipse - bit.ly/2N8DZxb
Protractor - bit.ly/2KtqVkU
AccelQ - bit.ly/3PlsAsh
Test Project - bit.ly/2DRNJYE
Cucumber BDD - bit.ly/3Cnno4z
Cypress - bit.ly/3PpEukM
Playwright - bit.ly/3iuPByJ
WebdriverIO - bit.ly/3IJyofA
XPath & Web Locators - bit.ly/3PpEvoQ
▬▬ API TESTING ▬▬
Web Services (API) - bit.ly/2MGafL7
SoapUI - bit.ly/2MGahmd
Postman - bit.ly/2wz8LrW
Postman 2022 - bit.ly/3JWm4qX
Rest Assured - bit.ly/3zUdhRD
Karate API Testing - bit.ly/3w3H5Ku
▬▬ MOBILE TESTING ▬▬
Appium - bit.ly/2ZHFSGX
Mobile Playlist - bit.ly/2PxpeUv
▬▬ PERFORMANCE TESTING ▬▬
JMeter Beginner - bit.ly/2oBbtIU
Gatling - bit.ly/3QrWfkV
▬▬ SOURCE CODE MANAGEMENT ▬▬
Git & GitHub - bit.ly/2Q1pagY
GITLAB - bit.ly/2kQPGyQ
▬▬ IDE ▬▬
Eclipse - bit.ly/3AnRhQP
IntelliJ IDEA - bit.ly/3AnyDZ8
Visual Studio Code - bit.ly/2V15yvt
▬▬ PROGRAMMING ▬▬
Java Beginners - bit.ly/2PVUcXs
Java Tips & Tricks - bit.ly/2CdcDnJ
Groovy - bit.ly/2FvWV5C
JavaScript - bit.ly/2KJDZ8o
Sunday Special - bit.ly/2wB23BO
Every Like & Subscription gives me great motivation to keep working for you
You can support my mission for education by sharing this knowledge and helping as many people as you can
If my work has helped you, consider helping any animal near you, in any way you can
Never Stop Learning
Raghav Pal
-
Пікірлер: 144
Thank You Sir! As for your slogan: "Never Stop Learning" I am 71 years old and I am here to learn. Great tutorial! I know you have put in a lot of time and effect to make this tutorial for us. Truly grateful for your kindness.
@RaghavPal
7 ай бұрын
You are now motivating me to "Never Stop Working".. Thanks If i can run, I will run If i cannot run, I will walk If I cannot walk, I will crawl But I will never stop
I've watched about 8 such videos to get the setup working correctly, and this one is by far the most comprehensive and easy to follow and understand.
@RaghavPal
Ай бұрын
Happy n humbled to know this
Thank you very much! I was struggling with the webdriver, and I had been searching for a solution for more than one hour until I find this video.
@RaghavPal
2 ай бұрын
So happy to know this helped Pablo
Simplicity at its best. That's all I can say about all your videos. Thank you for sharing.
@RaghavPal
2 ай бұрын
Most welcome Harsh
I'm grateful, @Raghavpal sir. This lecture is really well described. I've seen a number of videos on using Python with Selenium, but I had a lot of trouble installing and using WebDriver because most of the videos were out of date. Now that you've cleaned up all of my doubts, I feel much more confident. You've addressed every issue that a beginner would have.
@RaghavPal
6 ай бұрын
You are most welcome Madhav
Thanks alot man 😍, i was running for some series of issues because of deprecated tutorials. Sending love from Brazil!
@RaghavPal
Жыл бұрын
Glad I could help
Thank you!! I was struggling for 2 days with running my last selenium setup on colab which didn't work anymore following the webdriver support break.
@RaghavPal
Жыл бұрын
Glad it helped Julien
thank u so much Raghav sir ..eagerly waiting for python selenium series..great sir.
@RaghavPal
Жыл бұрын
So nice of you Mallikarjuna
Thank you! so comprehensive and detailed and professional! Love your vid and it helped me a lot!
@RaghavPal
10 ай бұрын
Great to know this.. Most welcome 🤗
Hi Raghav, Thank you so much for this video. from today i am starting Automation testing with python.
@RaghavPal
7 ай бұрын
Glad it was helpful Hemlata
Thinking of it and here it come. Thanks Raghav.
@RaghavPal
Жыл бұрын
Most welcome Yousuf
It's the first good video about selenium! Thanks
@RaghavPal
10 ай бұрын
You're welcome!
Thank you so much Raghav for detail explanation.
@RaghavPal
Жыл бұрын
Most welcome Surya
Thank you very much for this tutorial! We will wait new tutorials!
@RaghavPal
6 ай бұрын
You are welcome
Thank you very much for this tutorial. You explained easy understandable manner!
@RaghavPal
8 ай бұрын
You're very welcome Prasad
Great video, nice and clean! Keep it up 🔥
@RaghavPal
Жыл бұрын
Thanks
Raghav Pal I always like your explain stile and again this one is also super. Many thanks
@RaghavPal
11 ай бұрын
Always welcome Zahid
It was very very Useful....Thank you so much Raghav Sir :)
@RaghavPal
Жыл бұрын
Most welcome Venkat
Great work Raghav, thanks a lot!
@RaghavPal
7 ай бұрын
Most welcome Rafael
Thanks Raghav for initiating for this series 😊👍
@RaghavPal
Жыл бұрын
My pleasure Sarang
Very Helpful Vedio . Thank you so much
@RaghavPal
11 ай бұрын
Most welcome
Hi Raghav, I was searching for selenium with python course and found ur videos and they are simply understandable. Please clarify me that if I go through the 6 videos in the playlist will it cover everything? Actually I’m beginner
@RaghavPal
8 ай бұрын
Yamini Yes, it will get you started and you can work on any Selenium Python project, Can also check more here - automationstepbystep.com/
Ot dushi rahmat, jigar
@RaghavPal
11 ай бұрын
Най-добре дошли
thanks mate
@RaghavPal
9 ай бұрын
You're welcome!
Thanks Raghav, waiting for next learning Things in same series 🎉
@RaghavPal
Жыл бұрын
Coming soon Prasanna
Hi Raghav, First of all i learn a lot from you. i always think how you are passionate about new things :) I just checked this not went deeply so i have a question whats the need combination of Selenium+Python? if i have not experience on python so will this cover python?
@RaghavPal
Жыл бұрын
Hi Kavita Selenium is used to automate browser actions (testing) and it can be used with multiple programming languages like Java, Python, C#, Ruby etc. Selenium with Python is a very good combination and skill set. It's used widely in projects too. I will cover Python for Beginners here - kzread.info/head/PLhW3qG5bs-L9Nu0MBqLs0bIdKOLjDAyjQ
Excellent
@RaghavPal
Жыл бұрын
Thanks Deepak
Thanks!!!!
@RaghavPal
11 ай бұрын
Most welcome
Great
@RaghavPal
Жыл бұрын
Thanks
Very Clear!! Thank you!!
@RaghavPal
Жыл бұрын
Glad it was helpful!
@khaliqbero1179
Жыл бұрын
@@RaghavPal sir, please make a vid of web scraping using selenium python. It would be appreciated :)
@RaghavPal
Жыл бұрын
Sure
Awesome video
@RaghavPal
11 ай бұрын
Glad you enjoyed it 😊
Hello Raghav, could you please make a series for this tutorial?
@RaghavPal
8 ай бұрын
I will plan Nitin, you can check more Selenium Python here - automationstepbystep.com/
@nitinjawale1624
8 ай бұрын
@@RaghavPal can you suggest to me any course for crashes in the mobile application testing. I need more help for that point. How to test the mobile app crashes
@RaghavPal
8 ай бұрын
Can check: Mobile App Testing Crash Course on Udemy: Mobile App Crash Testing with Appium on Pluralsight How to Test for Crashes in Mobile Apps on edX
@nitinjawale1624
8 ай бұрын
Thanks@@RaghavPal
Thanks for this Sir, I've been waiting for this video a long time :)
@RaghavPal
Жыл бұрын
So nice of you Paul
@testingforyou848
Жыл бұрын
@@RaghavPal keep uploading videos Sir :)
Hello, can I use the Selenium Python code in the Katalon Studio?
@RaghavPal
7 ай бұрын
While Katalon Studio doesn't natively support direct execution of Python code, here are alternative approaches to incorporate Selenium Python capabilities: 1. Custom Keywords: - Create Groovy Keywords: Develop custom keywords in Katalon Studio using Groovy, its native scripting language. - Integrate Selenium Actions: Within these keywords, leverage Katalon Studio's built-in Selenium integration to perform browser interactions. - Call Keywords from Tests: Easily call these custom keywords from your test cases, effectively reusing Selenium actions in a structured way. 2. External Python Libraries: - Package Python Code: Structure your Selenium Python code as a reusable library or module. - Import Library: Use Katalon Studio's Groovy scripting capabilities to import and execute functions from your Python library. - Invoke Python Code: This approach allows interaction with Python code from within Katalon Studio's test cases. 3. Hybrid Approach: - Combine Strengths: For complex scenarios, consider a combination of Groovy keywords for test structure and Python code for specific Selenium actions. - Flexibility and Leverage: This strategy offers flexibility in choosing the most suitable language for different test components. Key Considerations: - Groovy Proficiency: Creating custom keywords or importing Python libraries requires knowledge of Groovy syntax. - Maintainability: Ensure proper maintenance of both Katalon Studio scripts and external Python code. - Alternative Tools: If extensive Python usage is essential, using a tool like Robot Framework with its Python support might be more suitable. Recommendations: - Evaluate Complexity: Assess the complexity of your Selenium Python code and the level of integration required with Katalon Studio features. - Consider Expertise: Factor in your team's familiarity with Groovy and Python for maintainability. - Explore Alternatives: If extensive Python usage is crucial, consider tools like Robot Framework that directly support Python.
Thanks
@RaghavPal
Жыл бұрын
Welcome Ndema
Hi Raghav, Which is the best way to write test cases in excel or word document or any other best recommended tools that is very much useful?
@RaghavPal
Жыл бұрын
Hi Srirama There is no one "best" way to write test cases, as the best method will vary depending on the specific project and team. However, some of the most common methods include: * Using a spreadsheet tool like Excel.* This is a simple and straightforward way to create and store test cases, and it is easy to share and collaborate on spreadsheets. However, spreadsheets can be difficult to manage as the number of test cases grows, and they may not be as scalable as other tools. * Using a word processing tool like Word.* This is another simple and straightforward option, and it allows you to format your test cases in a more readable way than a spreadsheet. However, word processing documents can be difficult to manage and track, and they may not be as secure as other tools. * Using a dedicated test case management tool.* These tools are designed specifically for managing test cases, and they offer a number of features that can make it easier to create, track, and manage test cases. Some of the features that dedicated test case management tools offer include: * The ability to create and store test cases in a central repository.* This makes it easy to share and collaborate on test cases, and it also makes it easier to keep track of changes to test cases. * The ability to automate test case execution.* This can save time and resources, and it can also help to improve the accuracy and consistency of test results. * The ability to generate reports on test case execution.* This can help you to track the progress of your testing, identify areas where more testing is needed, and identify potential defects. If you are working on a small project with a limited number of test cases, then using a spreadsheet or word processing document may be sufficient. However, if you are working on a larger project with a large number of test cases, then using a dedicated test case management tool may be a better option. Here are some of the most recommended tools for test case management: * TestRail* is a popular and feature-rich test case management tool. It offers a wide range of features, including the ability to create and store test cases in a central repository, automate test case execution, and generate reports on test case execution. [Image of TestRail logo] * TestLink* is another popular test case management tool. It offers a similar range of features to TestRail, but it is open source and can be self-hosted. [Image of TestLink logo] * Zephyr* is a test case management tool that is integrated with Jira. This makes it a good option for teams that are already using Jira for project management. [Image of Zephyr logo] * TestFairy* is a cloud-based test case management tool that is designed for mobile apps. It offers a number of features that are specifically tailored to mobile app testing, such as the ability to record and playback user sessions. [Image of TestFairy logo] Ultimately, the best tool for you will depend on your specific needs and requirements. If you are not sure which tool to choose, then you can consult with a test automation expert or do some research online to read reviews and compare features
Hello from Vietnam, your video is very informative. Thank you very much. Can I use Pycharm and Python to control and interact with Excel??
@RaghavPal
10 ай бұрын
Yes, you can Phuong
Can any one help me, I am getting this error. driver= webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'module' object is not callable
@RaghavPal
9 ай бұрын
Aayan The error message `TypeError: 'module' object is not callable` indicates that you are trying to call the `ChromeDriverManager` module as if it were a function. However, the `ChromeDriverManager` module is a class, not a function. To resolve this error, you need to instantiate the `ChromeDriverManager` class and then call the `install()` method on the instance. Here is the corrected code: ```python from webdriver_manager.chrome import ChromeDriverManager driver = webdriver.Chrome(service=ChromeDriverManager().install()) ``` This code will instantiate the `ChromeDriverManager` class and then call the `install()` method on the instance. The `install()` method will download and install the ChromeDriver executable. Once the ChromeDriver executable is installed, you can create a new instance of the `Chrome` driver and use it to interact with the Chrome browser. I hope this helps
@user-jb5kw6pc5t
5 ай бұрын
No module named webdriver_manger error
Hello Raghav sir, Facing this error: The process started from chrome location
@RaghavPal
10 ай бұрын
Sudhir The error message "The process started from chrome location
@RaghavPal, I am not getting community version as shown below
@RaghavPal
Жыл бұрын
Krushith Check here - www.jetbrains.com/products/compare/?product=pycharm&product=pycharm-ce
Hey I got it... Thank you.
@RaghavPal
Жыл бұрын
Most welcome
Hi Raghav Sir, the browser is getting closed post successful run, though I am not giving driver.quit or driver.close, how to overcome this, pls assist
@RaghavPal
Жыл бұрын
Venkat There are a few possible reasons why the browser is closing automatically after a successful run in Selenium Python, even if you are not calling `driver.quit()` or `driver.close()`. * **The browser is configured to close automatically after a certain period of inactivity.** This can be configured in the browser's settings. * **The Selenium WebDriver is not configured properly.** This can happen if the WebDriver executable is not in the correct path, or if the WebDriver version is not compatible with the browser version. * **There is an issue with the Selenium code.** This could be a typo, or a problem with the way the code is structured. To troubleshoot this issue, you can try the following steps: 1. Check the browser's settings to make sure that it is not configured to close automatically after a certain period of inactivity. 2. Verify that the Selenium WebDriver is configured properly. You can do this by checking the WebDriver executable path and the WebDriver version. 3. Debug the Selenium code to find any errors. You can use a debugger to step through the code line by line and see where the issue is occurring. If you have tried all of these steps and the browser is still closing automatically, you may need to contact the Selenium support team for help. Here are some additional tips to help you avoid this issue in the future: * Always call `driver.quit()` or `driver.close()` at the end of your Selenium script, even if the browser is closing automatically. This will ensure that the browser is closed properly and that any resources are released. * Use a debugger to step through your Selenium code line by line and make sure that there are no errors. * Keep your Selenium WebDriver and browser versions up to date. * Configure the browser to not close automatically after a certain period of inactivity. I hope this helps
I did same thing but showing error i don't know how to resolve
@RaghavPal
11 ай бұрын
Deeksha will need more details and reference
Hi Raghav, I'm getting error driver = webdriver.chrome(service=ChromeService(ChromeDriverManager().install())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'module' object is not callable Please help me
@RaghavPal
Жыл бұрын
Shamsheer The error message you are getting is because you are trying to call the `ChromeService()` module as a function. The `ChromeService()` module is not a function, it is a module that contains the code for the ChromeDriver service. To fix this error, you need to call the `start()` method on the `ChromeService()` object. The `start()` method will start the ChromeDriver service. Here is the corrected code: ``` from selenium import webdriver from selenium.webdriver.chrome.service import ChromeService chrome_service = ChromeService() chrome_service.start() driver = webdriver.Chrome(service=chrome_service) ``` This code will start the ChromeDriver service and then create a new ChromeDriver instance. The `driver` variable will be an instance of the `webdriver.Chrome` class. Here are some additional things to keep in mind: * You need to install the ChromeDriver binary before you can use the `ChromeService()` module. You can download the ChromeDriver binary from the ChromeDriver website: chromedriver.chromium.org/downloads. * You need to specify the path to the ChromeDriver binary when you create the `ChromeService()` object. You can get the path to the ChromeDriver binary by running the following command: ``` which chromedriver ``` * You need to call the `stop()` method on the `ChromeService()` object when you are finished using it. The `stop()` method will stop the ChromeDriver service. I hope this helps
while clicking on the + icon i am not able to see anything. Can you please help me how to reslove this ?
@RaghavPal
Жыл бұрын
where exactly Rajesh. Please point the time in the video, Can also try to restart IDE
Hi Raghav Sir, Happy Ugadi. I have to know how we can implement deep links in mobile automation using WebDriver IO, Appium with typescript. I came to know that deep links are used to navigate to a specific page of mobile application with a specific status (e.g. shopping cart page with added products) to speed up the tests and reduce flaky tests. Could you please guide me in implementing these in WebDriver IO, Appium with typescript project?
@RaghavPal
4 ай бұрын
Raj Happy Ugadi to you too Implementing deep links in mobile automation using WebDriverIO, Appium, and TypeScript can streamline your testing process by allowing you to navigate directly to specific app pages. Here's a guide to help you implement deep links: 1. Configure Deep Links: Ensure that your mobile application is configured to handle deep links. This typically involves setting up URL schemes and intents in your app's manifest file. 2. Create a Deep Link Function: In your WebDriverIO project with TypeScript, create a function that can open a deep link. This function will use Appium's `driver.url()` method to navigate to the deep link URL. ```typescript async function openDeepLink(url: string) { await driver.url(url); } ``` 3. Use the Function in Tests: Call the `openDeepLink` function in your tests, passing the specific deep link URL you want to navigate to. ```typescript describe('Deep Link Test', () => { it('should open the shopping cart via deep link', async () => { await openDeepLink('yourapp://shopping-cart'); // Add assertions to verify the shopping cart page with added products }); }); ``` 4. Handle Context Switching: If your app opens the deep link in a web view, you may need to switch contexts using Appium's context handling APIs. 5. Run Your Tests: Execute your tests using the configured WebDriverIO setup. The tests should now navigate directly to the specified pages using deep links. Remember to replace `'yourapp://shopping-cart'` with the actual deep link that corresponds to your application's configuration. For more detailed guidance and examples, you can refer to resources and tutorials that discuss mobile automation with Appium and WebDriverIO using TypeScript
@rajkumaraadepu3951
4 ай бұрын
@@RaghavPal I want to open a specific page in mobile native app. I don't want it to be opened in mobile browser. Could you please help me with a short video tutorial please..
@RaghavPal
4 ай бұрын
I will need to check on this with details.. are you doing this with Selenium Python
@rajkumaraadepu3951
4 ай бұрын
@@RaghavPal No, I am working with WebDriver IO, Appium with Typescript....
@RaghavPal
4 ай бұрын
Ok, To open a specific page in a mobile native app using WebDriver IO, Appium, and TypeScript, you'll need to set up your Appium capabilities to specify the app and activity you want to launch. Here's a step-by-step guide: 1. Set Up Appium Capabilities: You'll need to define the `appPackage` and `appActivity` for the specific page you want to open. These are unique identifiers for Android apps that tell Appium which app and screen to launch. 2. Write Your Test Script: Use the capabilities to initiate a session with Appium and navigate to the desired page within your native app. 3. Run Your Test: Execute the test script, and Appium will open the specified page in the native app on your mobile device or emulator. Here's an example of how you might set up your capabilities and test script in TypeScript: ```typescript import { remote } from 'webdriverio'; // Define the Appium capabilities const capabilities = { platformName: 'Android', 'appium:deviceName': 'YourDeviceName', 'appium:platformVersion': 'YourAndroidVersion', 'appium:automationName': 'UiAutomator2', 'appium:appPackage': 'com.example.yourapp', // Replace with your app's package 'appium:appActivity': 'com.example.yourapp.YourActivity', // Replace with the activity you want to launch }; // Initialize the Appium session with the capabilities const driver = await remote({ capabilities }); // Your test code to interact with the app goes here // End the session await driver.deleteSession(); ``` Replace `'com.example.yourapp'` and `'com.example.yourapp.YourActivity'` with the actual `appPackage` and `appActivity` of the page you want to open. Unfortunately, I can't provide a video tutorial, but you can find detailed guides and examples online that can help you further. For instance, the [LambdaTest website](^2^) offers a comprehensive tutorial on getting started with WebDriverIO and Appium, which includes examples and explanations that can be very useful for your case.
Will webdriver manager work with robotframework? Can u paste a example code of implementation?
@RaghavPal
Жыл бұрын
Yes Archana webdriver manager can work with Robot Framework. It is a Python library that can be used to download and manage WebDriver binaries. This can be useful when you are using Robot Framework to automate tests that interact with a web browser. Here is an example code of how to use webdriver manager with Robot Framework: ```python from robotframework import webdriver from webdrivermanager import webdrivermanager def setup(): webdrivermanager.install('chrome') driver = webdriver.Chrome() return driver def teardown(driver): driver.quit() def test_open_google(driver): driver.get('www.google.com') assert 'Google' in driver.title if __name__ == '__main__': driver = setup() test_open_google(driver) teardown(driver) ``` This code will first install the Chrome WebDriver binary using webdriver manager. Then, it will create a new Chrome driver and open the Google website. Finally, it will assert that the title of the page contains the word "Google". To run this code, you will need to have the Robot Framework and webdriver manager libraries installed. You can install them using the following commands: ``` pip install robotframework pip install webdrivermanager ``` Once you have installed the libraries, you can run the code by saving it as a Python file and then running the following command: ``` robot test.robot ``` This will run the test and print the results to the console
Raise valueerror(f there is no such driver by url) how to solve this
@RaghavPal
Жыл бұрын
The error message `ValueError: There is no such driver by URL` is raised in Selenium Python when you try to create a WebDriver object for a driver that does not exist. For example, if you try to create a WebDriver object for the `chromedriver` driver, but the `chromedriver` executable is not installed on your system, you will get this error. To solve this problem, you need to make sure that the driver that you are trying to create is installed on your system. You can do this by following these steps: 1. Check the documentation for the driver that you are trying to create. The documentation will typically tell you where to download the driver and how to install it. 2. Once you have downloaded the driver, you need to make sure that it is in the same directory as your Selenium Python script. 3. Once the driver is installed, you should be able to create a WebDriver object for the driver without any errors. Here is an example of how to create a WebDriver object for the `chromedriver` driver: ```python from selenium import webdriver driver = webdriver.Chrome() ``` If the `chromedriver` executable is not installed on your system, you will get the error `ValueError: There is no such driver by URL`. I hope this helps!
Hi Raghav sir, thanks a lot for this video, I have this error: ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Accès refusé: 'c:\\program files\\python38\\Lib\\site-packages\\certifi' Consider using the `--user` option or check the permissions. WARNING: You are using pip version 19.2.3, however version 23.3.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.
@RaghavPal
9 ай бұрын
Soukaina The error message `Could not install packages due to an EnvironmentError: [WinError 5] Accès refusé: 'c:\\program files\\python38\\Lib\\site-packages\\certifi'` indicates that you do not have permission to install packages to the Python system directory. This is because Python is installed in a protected directory on Windows. To fix this error, you can use the `--user` option when installing packages. This will install packages to your user directory, where you have permission to write. For example, the following command will install the `certifi` package to your user directory: ``` pip install --user certifi ``` You can also check the permissions on the Python system directory to see if you have permission to write to it. If you do not have permission, you can try changing the permissions or running pip as an administrator. To run pip as an administrator, open a command prompt window as an administrator and then run the following command: ``` pip install certifi ``` If you are still having problems installing packages, you can try installing Python to a different directory, such as your user directory. **To upgrade pip, run the following command:** ``` python -m pip install --upgrade pip ``` I hope this helps
Sir i am unable to install selenium pip, even I try with d/w from different ways.. Can you please help me
@RaghavPal
Жыл бұрын
Hi Nidhi Here are some things you can try if you are unable to install Selenium pip: * **Make sure that you have the latest version of Python installed.** You can check the version of Python that you have installed by running the following command in your terminal: ``` python --version ``` If you don't have the latest version of Python installed, you can download it from the Python website: www.python.org/downloads/. * **Make sure that you have pip installed.** Pip is a package manager that is used to install Python packages. You can check if pip is installed by running the following command in your terminal: ``` pip --version ``` If pip is not installed, you can install it by running the following command: ``` python -m pip install --user pip ``` * **Try installing Selenium pip in a virtual environment.** A virtual environment is a way to isolate Python packages from your system Python packages. This can be helpful if you are having trouble installing Selenium pip because it will prevent it from conflicting with other Python packages that you have installed. To create a virtual environment, you can run the following command in your terminal: ``` python -m venv venv ``` Once you have created a virtual environment, you can activate it by running the following command: ``` source venv/bin/activate ``` Now, you can try installing Selenium pip by running the following command: ``` pip install selenium ``` * **Check for errors.** If you are still having trouble installing Selenium pip, you can check for errors by running the following command: ``` pip install selenium --verbose ``` This will show you the output of the pip install command, including any errors that were encountered. I hope this helps
It opens in Edge, not Chrome, why is that?
@RaghavPal
9 ай бұрын
Magdoulin There are a few reasons why your Selenium Python project might be opening in Edge instead of Chrome. Here are a few possibilities: 1. **Default browser setting:** Check your default browser settings. If Edge is set as your default browser, Selenium might be using it instead of Chrome even if you specify Chrome in your code. 2. **Driver path:** Make sure you have the correct driver path for Chrome. If the driver path is incorrect, Selenium might not be able to find the Chrome browser and might default to Edge. 3. **Browser options:** If you are using browser options, make sure you have the correct options set for Chrome. For example, if you are specifying the wrong headless mode option, Selenium might not be able to launch Chrome and might default to Edge. 4. **External programs:** Check if any external programs are interfering with Selenium's ability to launch Chrome. For example, some antivirus programs might block Chrome from launching, causing Selenium to use Edge instead. Here are some steps you can take to troubleshoot the issue: 1. **Verify your default browser:** Check your system's default browser settings. If Edge is set as your default browser, change it to Chrome. 2. **Confirm the driver path:** Download the ChromeDriver executable if you haven't already. Make sure the ChromeDriver executable is in a directory that is accessible to your Python script. 3. **Check browser options:** Review your browser options code to ensure you are using the correct options for Chrome. For example, the correct options for headless mode are: ```python options = webdriver.ChromeOptions() options.add_argument("--headless") ``` 4. **Disable conflicting programs:** If you suspect any external programs might be interfering, try temporarily disabling them and rerunning your Selenium script. 5. **Update Selenium and ChromeDriver:** Make sure you are using the latest versions of Selenium and ChromeDriver. Outdated versions can sometimes cause compatibility issues. 6. **Try explicit browser selection:** Instead of relying on the default browser, explicitly specify the Chrome browser in your code using the `webdriver.Chrome()` constructor: ```python driver = webdriver.Chrome(executable_path="/path/to/chromedriver") ```
Hi, very helpful video. I followed all the steps and getting error, what's the best way to share the error with you? :)
@RaghavPal
Жыл бұрын
Hi Ammar, you can let me know in the video comments
latest robot framework it's available for web applications.
@RaghavPal
10 ай бұрын
I will check
Hii sir, I am getting TypeError:__init__() got an unexpected keyword argument 'service', Why it is coming?sir plz help me to resolve the issue.
@RaghavPal
Жыл бұрын
Hi Keshari The error message `TypeError:__init__() got an unexpected keyword argument 'service'` means that the `service` keyword argument is unexpected or invalid. This error can occur if you are using an outdated version of Selenium. To resolve the issue, you can try updating your version of Selenium. You can also try removing the `service` keyword argument from your code. Here is an example of how to fix the error: ```python from selenium import webdriver def main(): browser = webdriver.Chrome() browser.get("www.example.com") # This line will cause the error # browser = webdriver.Chrome(service=True) # This line will fix the error browser = webdriver.Chrome() if __name__ == "__main__": main() ``` This code will fix the error and launch Chrome without the `service` keyword argument. I hope this helps
@kesharikeshari1038
Жыл бұрын
@@RaghavPal Thank you so much sir.
Please provide a complete python selenium series with framework
@RaghavPal
Жыл бұрын
Sure, I will do Piyush
Hi Raghav, my chrome browser is closing after execution automatically how to overcome it and chrome driver version and chrome browser version are different as i dont find the latest driver
@RaghavPal
Жыл бұрын
Hi Penchal There are a few reasons why your Chrome browser might be closing automatically after execution in Selenium Python. One possibility is that you are not calling the `driver.quit()` or `driver.close()` method at the end of your script. This will tell the browser to close itself after the script has finished running. Another possibility is that you are using a different version of Chrome than the version of the ChromeDriver that you are using. If the versions are not compatible, the browser may close itself automatically. You can check the versions of Chrome and ChromeDriver by running the following commands in a terminal: ``` chrome --version chromedriver --version ``` If the versions are different, you can download the latest version of ChromeDriver from the Selenium website: chromedriver.chromium.org/downloads. Finally, it is also possible that there is a problem with your Chrome profile or extensions. You can try uninstalling and reinstalling Chrome to see if that fixes the problem. To keep the browser session alive in Selenium Python, you can use the `ChromeOptions` and `Capabilities` classes. The `Capabilities` class can get the capabilities of the browser by using the method `getCapabilities()`. You can then pass these capabilities to the `ChromeOptions` class when you create a new instance of the `webdriver.Chrome()` object. To do this, you can add the following code to your script: ```python from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_experimental_option("detach", True) driver = webdriver.Chrome(options=options) driver.get("www.google.com") print(driver.title) driver.quit() ``` The `detach` option tells the browser to not close itself automatically after the script has finished running. If you are still having problems with your Chrome browser closing automatically, you can search for more solutions on the Selenium documentation website: www.selenium.dev/documentation/.
@penchalreddy2620
Жыл бұрын
Now its working i followed the chrome options method thank you
do you need to download the drivers first? or do i not need any drivers ?
@RaghavPal
11 ай бұрын
No, just follow the steps as shown
Can I test this on a shared hosting? And do I need a chrome browser installed machine to run this?
@RaghavPal
6 ай бұрын
• Testing on shared hosting often restricted: Check with your provider about Selenium support. • Local machine ideal: Install Chrome and ChromeDriver for direct execution. • Cloud services like BrowserStack/Sauce Labs offer reliable testing environments. • CI/CD pipelines integrate tests for efficient execution. • Chrome needed for ChromeDriver, but Selenium supports other browsers with relevant drivers. • Start locally, explore cloud options for scalability and reliability.
@Osegbuvalentine
6 ай бұрын
@@RaghavPal alright, thanks, do have any idea whether or not playwright would work on shared hosting, that one seems light weight.
@RaghavPal
6 ай бұрын
Whether Playwright will work on shared hosting depends on several factors: Resource limitations: * Shared hosting environments often have limited resources like CPU, memory, and disk space. Playwright, especially during test execution, can be resource-intensive due to launching multiple browser instances and interacting with web pages. While Playwright itself is lightweight, the tests you write might not be. * Check your shared hosting provider's resource limits and compare them to your expected test scenarios. If your tests involve complex interactions or require many browser instances simultaneously, shared hosting might not be sufficient. Software availability: * Playwright requires specific software like Node.js and potentially browsers like Chromium or Firefox. Some shared hosting providers offer limited software support or require manual setups. Check with your provider if they allow installing required software and configurations. Security restrictions: * Shared hosting environments often have security restrictions to protect other users. Running processes like browser automation might be prohibited by your provider's terms of service. Carefully review your hosting agreement and contact the provider if unsure. Alternatives: * If limitations are too restrictive, consider alternatives: * Cloud providers: Services like AWS or Google Cloud offer more control and scalable resources. Explore options like Amazon Lambda or Google Cloud Functions for serverless test execution. * Local testing: Run your tests locally on your machine for basic functionality checks. * Continuous integration/continuous delivery (CI/CD): Integrate Playwright tests into your CI/CD pipeline and run them on dedicated build servers with adequate resources. So: Playwright itself can potentially run on shared hosting, but resource limitations, software availability, and security restrictions might create obstacles. Carefully evaluate your provider's capabilities and your test requirements before deciding. Consider alternative solutions if shared hosting proves unsuitable.
sir how to do it in VSCode
@RaghavPal
8 ай бұрын
Adarsh Setting up a Selenium Python project in VS Code involves installing the necessary extensions, creating a project structure, and writing your test scripts. Here's a step-by-step guide: **Step 1: Install VS Code Extensions** 1. Install the Python extension from the VS Code Marketplace. This extension provides support for Python syntax highlighting, code completion, and debugging. 2. Install the Selenium WebDriver extension from the VS Code Marketplace. This extension provides integration with Selenium and simplifies the process of interacting with web browsers. **Step 2: Create a Project Structure** 1. Create a project directory for your Selenium tests. 2. Inside the project directory, create a subdirectory named "tests" to store your test scripts. 3. Create a Python file (e.g., test_example.py) within the "tests" directory to start writing your test scripts. **Step 3: Install Selenium Python Library** 1. Open the Command Palette in VS Code (Ctrl+Shift+P or Cmd+Shift+P). 2. Type "Python: Select Interpreter" and select a Python interpreter that has Selenium installed. 3. If Selenium is not installed, type "Python: Install Package" and search for "selenium". Follow the prompts to install the Selenium library. **Step 4: Write Test Scripts** 1. Import the necessary modules, including unittest and Selenium WebDriver. 2. Create a test class that extends unittest.TestCase. 3. Define test methods within the test class, using the @unittest.skipIf decorator to skip tests that require specific conditions. 4. Use Selenium WebDriver methods to interact with web elements, such as finding elements, clicking buttons, and entering text. 5. Use assertions to verify the expected behavior of the web application. **Example Test Script** ```python import unittest from selenium import webdriver class TestExample(unittest.TestCase): def test_title(self): driver = webdriver.Chrome() driver.get("www.example.com") title = driver.title self.assertEqual(title, "Example Website") driver.quit() if __name__ == "__main__": unittest.main() ``` **Running Test Scripts** 1. Save your test scripts. 2. Open the Command Palette in VS Code. 3. Type "Python: Discover Tests" to discover your test scripts. 4. Type "Python: Run Tests" to run all discovered tests. 5. View the test results in the VS Code Test panel. This basic setup will allow you to start writing and running Selenium Python tests in VS Code. You can further enhance your test scripts by using data-driven testing, page object models, and advanced Selenium techniques.
So you're telling me I could watch your video and have python up and running with useful packages installed properly... for free? and it only takes less than an hour?? Wow, no thanks! I'd much rather spend a year and a half quietly suffering in frustration and back pain. Nice try though! (Great vid)
@RaghavPal
3 ай бұрын
Nicholas It was just a small attempt to help beginners getting started.
@nicholasgrubinger968
3 ай бұрын
@@RaghavPal I fear my playful tone did not translate well to text. You made a truly comprehensive and concise video and I wish I found your content sooner as it truly is step-by-step, whereas a lot of tutorial content for python skims over quite a bit of information that is needed for new users. I apologize for not being straightforward. Thank you for your videos!
@RaghavPal
3 ай бұрын
Thanks for the kind words, Nicholas.. humbled
vs code can?
@RaghavPal
11 ай бұрын
You can use VS Code too here, let me know if you have specific ques Yoman
i am not able to set-up python
@RaghavPal
Жыл бұрын
Hi Satendra, will need to know the details of the error and message
Hi Raghav, Thank you very much for showing this. Trust me, I have been scared of trying selenium python haven known selenium java. You just helped me to break ice and I can see it is even more straightforward in installation than selenium java that has so many dependencies etc... in a nut shell, 🫡 I appreciate
@RaghavPal
Жыл бұрын
Most welcome Godwin