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.
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'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.
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
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?
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 - ua-cam.com/play/PLhW3qG5bs-L9Nu0MBqLs0bIdKOLjDAyjQ.html
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.
@@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
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
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?
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
@@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..
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.
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
• 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.
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.
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
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.
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
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 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
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
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/.
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") ```
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.
Hi Raghav, I'm getting error driver = webdriver.chrome(service=ChromeService(ChromeDriverManager().install())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'module' object is not callable Please help me
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
Can any one help me, I am getting this error. driver= webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'module' object is not callable
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
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 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!
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
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.
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.
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.
So happy to know this helped Pablo
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.
You are most welcome Madhav
Thanks alot man 😍, i was running for some series of issues because of deprecated tutorials. Sending love from Brazil!
Glad I could help
Simplicity at its best. That's all I can say about all your videos. Thank you for sharing.
Most welcome Harsh
Hi Raghav, Thank you so much for this video. from today i am starting Automation testing with python.
Glad it was helpful Hemlata
It's the first good video about selenium! Thanks
You're welcome!
thank u so much Raghav sir ..eagerly waiting for python selenium series..great sir.
So nice of you Mallikarjuna
Thinking of it and here it come. Thanks Raghav.
Most welcome Yousuf
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.
Glad it helped Julien
I am able to launch the browser. Thanku you soo much Raghav 😊
Most welcome 😊
Thank you! so comprehensive and detailed and professional! Love your vid and it helped me a lot!
Great to know this.. Most welcome 🤗
Great work Raghav, thanks a lot!
Most welcome Rafael
Thank you very much for this tutorial! We will wait new tutorials!
You are welcome
Raghav Pal I always like your explain stile and again this one is also super. Many thanks
Always welcome Zahid
Thank you so much Raghav for detail explanation.
Most welcome Surya
Ot dushi rahmat, jigar
Най-добре дошли
It was very very Useful....Thank you so much Raghav Sir :)
Most welcome Venkat
Thanks for this Sir, I've been waiting for this video a long time :)
So nice of you Paul
@@RaghavPal keep uploading videos Sir :)
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?
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
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?
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 - ua-cam.com/play/PLhW3qG5bs-L9Nu0MBqLs0bIdKOLjDAyjQ.html
Thank you very much for this tutorial. You explained easy understandable manner!
You're very welcome Prasad
thanks mate
You're welcome!
Thanks Raghav for initiating for this series 😊👍
My pleasure Sarang
Great video, nice and clean! Keep it up 🔥
Thanks
Very Helpful Vedio . Thank you so much
Most welcome
Thanks Raghav, waiting for next learning Things in same series 🎉
Coming soon Prasanna
Excellent
Thanks Deepak
Hello from Vietnam, your video is very informative. Thank you very much. Can I use Pycharm and Python to control and interact with Excel??
Yes, you can Phuong
Very Clear!! Thank you!!
Glad it was helpful!
@@RaghavPal sir, please make a vid of web scraping using selenium python. It would be appreciated :)
Sure
Thanks!!!!
Most welcome
Hello, can I use the Selenium Python code in the Katalon Studio?
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.
Hello Raghav, could you please make a series for this tutorial?
I will plan Nitin, you can check more Selenium Python here - automationstepbystep.com/
@@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
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
Thanks@@RaghavPal
Awesome video
Glad you enjoyed it 😊
Great
Thanks
Hi, very helpful video. I followed all the steps and getting error, what's the best way to share the error with you? :)
Hi Ammar, you can let me know in the video comments
Will webdriver manager work with robotframework? Can u paste a example code of implementation?
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
do you need to download the drivers first? or do i not need any drivers ?
No, just follow the steps as shown
Thanks
Welcome Ndema
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?
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
@@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..
I will need to check on this with details.. are you doing this with Selenium Python
@@RaghavPal No, I am working with WebDriver IO, Appium with Typescript....
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.
@RaghavPal, I am not getting community version as shown below
Krushith
Check here - www.jetbrains.com/products/compare/?product=pycharm&product=pycharm-ce
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
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
Deeksha
will need more details and reference
Can I test this on a shared hosting? And do I need a chrome browser installed machine to run this?
• 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.
@@RaghavPal alright, thanks, do have any idea whether or not playwright would work on shared hosting, that one seems light weight.
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.
Hello Raghav sir, Facing this error: The process started from chrome location
Sudhir
The error message "The process started from chrome location
Sir i am unable to install selenium pip, even I try with d/w from different ways.. Can you please help me
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
while clicking on the + icon i am not able to see anything.
Can you please help me how to reslove this ?
where exactly Rajesh. Please point the time in the video, Can also try to restart IDE
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.
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
Hey I got it... Thank you.
Most welcome
Raise valueerror(f there is no such driver by url) how to solve this
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!
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.
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
@@RaghavPal Thank you so much sir.
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
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/.
Now its working i followed the chrome options method thank you
It opens in Edge, not Chrome, why is that?
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")
```
sir how to do it in VSCode
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.
Hi Raghav,
I'm getting error
driver = webdriver.chrome(service=ChromeService(ChromeDriverManager().install()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable
Please help me
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
Can any one help me, I am getting this error.
driver= webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable
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
No module named webdriver_manger error
Please provide a complete python selenium series with framework
Sure, I will do Piyush
thx
Most welcome
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)
Nicholas
It was just a small attempt to help beginners getting started.
@@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!
Thanks for the kind words, Nicholas.. humbled
vs code can?
You can use VS Code too here, let me know if you have specific ques Yoman
latest robot framework it's available for web applications.
I will check
i am not able to set-up python
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
Most welcome Godwin