Automation test website bkel
git clone https://github.com/loctvl842/Software-Testing--Proj3
cd Software-Testing--Proj3
python3 -m venv env
source env/bin/activate
pip install -r ./requirements.txt
Go to src
folder and run the following commands
Test login
python run.py test LoginSuite
Test changing password
python run.py test ChangePasswordSuite
- Read the testcases in folder
testcases
- Read the result of test in folder
solutions
Create testcases by changing value in files LoginSuite.py
and ChangePasswordSuite.py
- After installing all dependencies in files
requirements.txt
, import in fileTestUtils.py
:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
- Get the
driver
by the following command(Make sure to installChrome
):
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
- In order to test the website, we use the following command:
driver.get("https://e-learning.hcmut.edu.vn/")
- Then test one element by some ways below:
find element by id
result_eles = driver.find_elements(By.ID, "msg")
find element by class name
driver.find_element(By.CLASS_NAME, "langbutton")
find element by XPath
driver.find_element(By.XPATH, "//a[starts-with(@href, 'https://e-learning.hcmut.edu.vn/login/logout.php')]")
- We can also control one element by an action such as: cllcking a button, or inputting a field input. For example:
driver.find_element(By.ID, "username").clear()
driver.find_element(By.ID, "username").send_keys("loc.letvl842002")
driver.find_element(By.NAME, "submit").click()
- Beside, we can check if one element is displayed by using the following command:
powermenu_btn.is_displayed():
Login | ChangePassword |
---|---|