Download this code from https://codegive.com
Running Selenium WebDriver from the command line can be a convenient way to automate browser tasks or perform web testing. In this tutorial, I'll guide you through the process of setting up and running Selenium WebDriver from the command line using Python as the programming language.
Python Installation:
Ensure that Python is installed on your system. You can download and install Python from python.org.
Selenium Installation:
Install the Selenium WebDriver library using pip. Open your command prompt or terminal and run the following command:
WebDriver Installation:
Download the WebDriver executable for the browser you intend to automate (e.g., ChromeDriver for Chrome, GeckoDriver for Firefox). Ensure the WebDriver executable is in your system's PATH or provide its path explicitly in the script.
Create a new Python script, e.g., selenium_script.py, and use a text editor to add the following code:
This script initializes a Chrome WebDriver, navigates to 'https://example.com' (replace with your desired URL), and includes a placeholder for additional Selenium actions.
Open your command prompt or terminal, navigate to the directory containing your script, and run the following command:
This command will execute your Python script, launching the WebDriver-controlled browser.
Congratulations! You've successfully set up and run Selenium WebDriver from the command line using Python. Feel free to customize the script according to your specific needs and integrate additional Selenium commands for web automation.
ChatGPT