This repository contains an automated web test using Selenium and Python to validate the login functionality of Intervue.io.
The script:
- Opens Intervue.io
- Navigates to the login page
- Attempts login with provided credentials
- Captures a screenshot if the login fails
- Closes the browser after execution
This project is designed for QA automation testing, ensuring the login mechanism functions as expected.
📂 intervue-qa-test/
├── test_intervue.py # Main automation script
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── screenshots/ # Folder to store failure screenshots
git clone https://github.com/yourusername/intervue-qa-test.git
cd intervue-qa-test
Ensure you have Python installed, then run:
pip install -r requirements.txt
Selenium requires a WebDriver to automate the browser.
- Download ChromeDriver: Download Here
- Place it in the project directory OR add it to your system PATH
🔹 Want to use Edge or Firefox? Install the respective WebDriver:
- Edge: Microsoft Edge WebDriver
- Firefox: GeckoDriver
Execute the script using:
python test_intervue.py
💡 Example with Arguments
python test_intervue.py --email test@example.com --password wrongpassword
if browser.lower() == "chrome":
self.driver = webdriver.Chrome()
elif browser.lower() == "firefox":
self.driver = webdriver.Firefox()
elif browser.lower() == "edge":
self.driver = webdriver.Edge()
else:
raise ValueError(f"Unsupported browser: {browser}")
📌 Why?
- This ensures flexibility by allowing different browsers (Chrome, Firefox, Edge).
- If an unsupported browser is passed, an error is raised.
def open_website(self):
self.driver.get("https://www.intervue.io")
print("Website opened successfully")
📌 Why?
- This function loads the Intervue.io website using Selenium's
get()
method.
def navigate_to_login(self):
login_button = WebDriverWait(self.driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//a[contains(text(), 'Login') or contains(@class, 'login')]"))
)
login_button.click()
print("Navigated to login page")
📌 Why?
- Uses Explicit Wait to ensure the login button is clickable before clicking.
- Uses XPath selectors to dynamically locate the login button.
email_field = self.driver.find_element(By.XPATH, "//input[@type='email']")
password_field = self.driver.find_element(By.XPATH, "//input[@type='password']")
submit_button = self.driver.find_element(By.XPATH, "//button[@type='submit']")
📌 Why?
- Locates email and password fields dynamically using XPath.
- Uses
send_keys()
to input credentials.
def take_screenshot(self, filename):
self.driver.save_screenshot(filename)
print(f"Screenshot saved as {filename}")
📌 Why?
- If login fails, the script captures the current screen state and saves it as an image for debugging.
📌 Example Screenshot File:
📂 intervue-qa-test/
├── login_button_not_found_20250301-091259.png 👈 Saved screenshot of failed login
🔹 The script saves screenshots in the screenshots/ directory with a timestamped filename:
login_failed_20250228-153000.png
🔹 This helps QA teams analyze why the login failed.
🔹 Modify Login Credentials
Edit test_intervue.py
and update:
test_email = "your-email@example.com"
test_password = "your-password"
🔹 Use a Different Browser
Change "chrome"
to "firefox"
or "edge"
in:
test = IntervueTest(browser="chrome")
Issue | Solution |
---|---|
WebDriverNotFoundException |
Ensure ChromeDriver is installed and in the system PATH. |
ElementNotFoundException |
The website structure might have changed. Update XPath selectors in test_intervue.py . |
TimeoutException |
Increase wait times using WebDriverWait(driver, 15) if the website is slow. |
🚀 Happy Testing!