Selenium Demo

Share

Selenium Demo

Creating a demo test case with Selenium typically involves writing a simple script to automate a web browser and interact with web elements. For this demonstration, I’ll outline a basic Selenium WebDriver script in Python. The example will demonstrate opening a web browser (Chrome, in this case), navigating to a website (e.g., Google), performing a search, and then closing the browser.

Prerequisites

  1. Python Installation: Ensure Python is installed on your system.
  2. Selenium Installation: Install Selenium WebDriver for Python using pip:
    bash
    pip install selenium
  3. WebDriver Installation: Download the ChromeDriver from its website. Ensure it’s placed in a directory that’s in your system’s PATH, or provide the path in your script.

Selenium WebDriver Demo Script

Here’s a simple script that demonstrates basic Selenium WebDriver functionality:

python
from selenium import webdriver from selenium.webdriver.common.keys import Keys # Set up WebDriver driver = webdriver.Chrome() # or specify the path if not in PATH # Navigate to a URL driver.get("http://www.google.com") # Find an element and interact with it search_box = driver.find_element_by_name('q') # Locate the Google search box search_box.send_keys('Selenium WebDriver') # Input text into the search box search_box.send_keys(Keys.RETURN) # Simulate hitting the Enter key # Wait to see the results driver.implicitly_wait(10) # Waits for 10 seconds # Close the browser driver.quit()

Running the Script

  1. Save this script in a .py file, for example, selenium_demo.py.
  2. Run the script from the command line or your IDE.
    bash
    python selenium_demo.py
  3. The script will open Chrome, navigate to Google, perform a search for “Selenium WebDriver”, and then close the browser after a brief wait.

Explanation of Key Steps

  • WebDriver Setup: Initializes the WebDriver for Chrome.
  • Navigation: The driver.get method navigates to a specified URL.
  • Element Interaction: Locates the search box, inputs text, and submits the form.
  • Implicit Wait: Waits for elements to load.
  • Closing Browser: The driver.quit method closes the browser window.

Demo Day 1 Video:

 
You can find more information about Selenium in this Selenium Link

 

Conclusion:

Unogeeks is the No.1 IT Training Institute for Selenium Training. Anyone Disagree? Please drop in a comment

You can check out our other latest blogs on  Selenium here – Selenium Blogs

You can check out our Best In Class Selenium Training Details here – Selenium Training

💬 Follow & Connect with us:

———————————-

For Training inquiries:

Call/Whatsapp: +91 73960 33555

Mail us at: info@unogeeks.com

Our Website ➜ https://unogeeks.com

Follow us:

Instagram: https://www.instagram.com/unogeeks

Facebook:https://www.facebook.com/UnogeeksSoftwareTrainingInstitute

Twitter: https://twitter.com/unogeeks


Share

Leave a Reply

Your email address will not be published. Required fields are marked *