Follow these steps to set up and use Selenium on your MacBook for writing and executing test cases:
Ensure that Python is installed on your Mac. You can download and install Python from python.org.
pip install selenium
chrome://settings/help
.chromedriver
file to a location in your PATH using the following terminal command:
sudo mv chromedriver /usr/local/bin/
To verify that ChromeDriver is correctly installed, open your terminal and type:
chromedriver --version
This should display the version of ChromeDriver installed on your system.
Create a Python script with the following content to verify that everything is set up correctly:
from selenium import webdriver
# Set up the WebDriver
driver = webdriver.Chrome()
# Navigate to a webpage
driver.get('https://www.example.com')
# Perform some actions (e.g., find an element and click it)
element = driver.find_element('name', 'q')
element.send_keys('Selenium')
element.submit()
# Close the browser
driver.quit()
Run your script using Python:
python your_test_script.py
Published By: Krishanu Jadiya
Updated at: 2024-07-31 00:42:16