Mocha Selenium

Share

Mocha Selenium

Sure, here’s a brief demo on how to use Selenium WebDriver with Python to automate a simple task on the “Selenium Easy” website. In this example, we’ll demonstrate how to navigate to the website, click a button, and verify the result.

Step 1: Set up your environment

Make sure you have Python installed on your system. You’ll also need to install the Selenium library by running the following command in your terminal or command prompt:

bash
pip install selenium

Step 2: Import necessary libraries

Create a Python script and import the required libraries:

python
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

Step 3: Initialize the WebDriver

Choose a web browser and create an instance of the WebDriver. For this demo, we’ll use Google Chrome:

python
# Specify the path to your Chrome WebDriver executable
chrome_driver_path = '/path/to/chromedriver'

# Create a Chrome WebDriver instance
driver = webdriver.Chrome(executable_path=chrome_driver_path)

Step 4: Navigate to the “Selenium Easy” website

python
# Navigate to the website
driver.get('https://www.seleniumeasy.com/test/')

Step 5: Click a button and wait for the result

In this example, we’ll click the “Start Practicing” button, and then we’ll wait for the result to appear.

python
# Find and click the "Start Practicing" button
start_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'btn_basic_example')))
start_button.click()

# Wait for the result element to appear
result_element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'basic_example')))

Step 6: Verify the result

python
# Get the text from the result element
result_text = result_element.text

# Print the result
print("Result:", result_text)

Step 7: Close the browser

python
# Close the browser
driver.quit()
This simple demo demonstrates how to use Selenium WebDriver with Python to automate interactions with a web page. You can build on this example to perform more complex tasks and navigate through different pages on the “Selenium Easy” website or any other website you want to automate.

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 *