First Selenium Python Script
Step-by-step instructions for writing your first Selenium
Python automation script.
New Script File
Let’s write a simple code. Follow the below steps to create the script.
Launch the Eclipse IDE.
Create a new script file.
File >> New >> File

Give a name to the script file. Python script file should have .py
file extension. Enter the following code in the script and save it.
Script Code
from selenium import webdriver
import time
browser = webdriver.Chrome()
browser.get('https://example.com')
time.sleep(10)
browser.quit()<br />

Run the Script
Right-click on the script and choose the following option: Run As >> Python Run
Explanation
Let’s understand the script. The first statement
browser = webdriver.Chrome()
The above statement initializes the browser object by creating an instance of the Chrome object. This will create and start a session for browser interaction.
browser.get(‘https://example.com’)