0% found this document useful (0 votes)
4 views4 pages

Practical Solution - QA 24-25

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Practical Solution - QA 24-25

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

This is Vaibhav Kashyap and I am using python language to complete these question.

1. Searching a Number

def search(arr,n,k):

for i in range (n):

if arr[i] == k;

return i+1

return -1

#Using a example here

N=5

K = 16

Arr = {9,7,2,16,4}

result = search (Arr, N,K)

print(result)

2. Balanced Array

def minValueToBalance(arr,n);

left_sum = sum(arr[n//2])

right_sum = sum (arr[n//2])

return abs(left_sum - right_sum)

#Using a example for better overview of the code

N=4

arr = [1,5,3,2]

result = minValueToBalance(arr,N)

print(result) #The Output will be 1, when you use both left_sum and right_sum....!
3. Test Case for Login Page

from Selenium import webdriver

from selenium.webdriver.common.by import By

from selenium.webdriver.common.keys import keys

import time

#Test Case 1: Valid Email and Password

def test_valid_login():

email = driver.find_element(By.ID, "email")

password = driver.find_element(By.ID, "password")

login_button = driver.find_elements(By.ID, "login_button)

email.send_keys("[email protected]"

password.send_keys("password123!")

login_button.click()

time.sleep(2)

assert "Dashboard" in driver.title

#Test Case 2 : Invalid Email(missing'a')

def test_invalid_email():

email = driver.find_element(By.ID ,"email)

password = driver.find_element(By.ID,"password)

login_button = driver.find_element(By, ID, "login_button)

time.sleep(2)

error_message = driver.find_element (By.CLASS_NAME,"error-message)


assert "Invalid email" in error_message.text

#Test Case 3 : Invalid Password (too short)

email = driver.find_element(By.ID ,"email)

password = driver.find_element(By.ID,"password)

login_button = driver.find_element(By, ID, "login_button)

email.clear()

email.send_keys([email protected])

password.clear()

password.send_keys("123")

login_button.click()

time sleep(2)

errror_message = driver.find_element(By.CLASS_NAME,"error-message")

assert "Password too short" in error_message.text

try:

test_valid_login()

print("Test Case 1 : Passed - Valid Login")

test_invalid_email()

print("Test Case 2 : Passed- Invalid Email")

test_short_password()

print("Test Case 3: Passed - Invalid Short Password")

finally:

driver.quit()
Thank you so much...........

You might also like