This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sujeetsr/master
Updated tests and README
- Loading branch information
Showing
16 changed files
with
261 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
**Check out the code** | ||
|
||
[email protected]:rockstor/rockstor-tests.git | ||
|
||
**Install required modules** | ||
|
||
pip install -r requirements.txt | ||
|
||
**Configure** | ||
|
||
Set the rockstor base_url in webdriver/development.yaml | ||
|
||
**Run tests** | ||
|
||
cd to the webdriver directory | ||
|
||
You can run an individual test like this | ||
|
||
python login.py | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
selenium==2.32.0 | ||
PyYAML==3.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.ui import Select | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
from selenium.common.exceptions import NoSuchElementException | ||
from selenium.webdriver.support import expected_conditions as EC | ||
import unittest, time, re | ||
import yaml | ||
import sys, getopt | ||
from rockstor_testcase import RockStorTestCase | ||
from inspect import stack | ||
from util import read_conf | ||
from login import Login | ||
from pools_create_raid0_2disks import PoolsCreateRaid02Disks | ||
|
||
if __name__ == '__main__': | ||
conf = read_conf() | ||
# TODO generate screenshot dir name from timestamp and create dir | ||
conf['screenshot_dir'] = 'output2' | ||
suite = unittest.TestSuite() | ||
suite.addTest(RockStorTestCase.parametrize(Login, conf=conf)) | ||
suite.addTest(RockStorTestCase.parametrize(PoolsCreateRaid02Disks, conf=conf)) | ||
unittest.TextTestRunner(verbosity=2).run(suite) | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
base_url: https://rs14dev | ||
screenshot_dir: output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
from selenium import webdriver | ||
from selenium.common.exceptions import TimeoutException | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.ui import Select | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
from selenium.common.exceptions import NoSuchElementException | ||
from selenium.webdriver.support import expected_conditions as EC | ||
from selenium.webdriver.common.by import By | ||
|
||
driver = webdriver.Firefox() | ||
|
||
# read configuration | ||
import unittest, time, re | ||
import yaml | ||
f = open('config.yaml') | ||
# use safe_load instead load | ||
config = yaml.safe_load(f) | ||
login_url = config['login_url'] | ||
|
||
f.close() | ||
|
||
# Go to the Login page | ||
driver.get(login_url) | ||
|
||
# Fill in username / password | ||
loginField = driver.find_element_by_name("login") | ||
loginField.send_keys("admin") | ||
|
||
passwordField = driver.find_element_by_name("password") | ||
passwordField.send_keys("admin") | ||
|
||
# submit the form | ||
driver.find_element_by_id("sign_in").click() | ||
|
||
current_step = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "current-step"))) | ||
print current_step.text | ||
|
||
driver.quit() | ||
import sys, getopt | ||
from rockstor_testcase import RockStorTestCase | ||
from inspect import stack | ||
import sys, traceback | ||
|
||
class Login(RockStorTestCase): | ||
def test_login(self): | ||
try: | ||
# Login | ||
driver = self.driver | ||
driver.get(self.base_url + "/login_page") | ||
driver.find_element_by_id("inputUsername").clear() | ||
driver.find_element_by_id("inputUsername").send_keys("admin") | ||
driver.find_element_by_id("inputPassword").clear() | ||
driver.find_element_by_id("inputPassword").send_keys("admin") | ||
driver.find_element_by_id("sign_in").click() | ||
|
||
# Check that the dashboard title is displayed | ||
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "widgets-container"))) | ||
dashboard_title = driver.find_element_by_id("title") | ||
self.assertRegexpMatches(dashboard_title.text, r"^[\s\S]*Dashboard[\s\S]*$") | ||
# logout | ||
driver.find_element_by_id("logout_user").click() | ||
except Exception, e: | ||
exc_type, exc_value, exc_traceback = sys.exc_info() | ||
traceback.print_exception(exc_type, exc_value, exc_traceback, | ||
limit=2, file=sys.stdout) | ||
self.save_screenshot(stack()[0][3]) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.ui import Select | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
from selenium.common.exceptions import NoSuchElementException | ||
from selenium.webdriver.support import expected_conditions as EC | ||
import unittest, time, re | ||
import yaml | ||
import sys, getopt | ||
import time | ||
from rockstor_testcase import RockStorTestCase | ||
|
||
class LoginAndSetup(RockStorTestCase): | ||
def test_login_and_setup(self): | ||
driver = self.driver | ||
driver.get(self.base_url + "/login_page?next=/") | ||
driver.find_element_by_id("inputUsername").clear() | ||
driver.find_element_by_id("inputUsername").send_keys("admin") | ||
driver.find_element_by_id("inputPassword").clear() | ||
driver.find_element_by_id("inputPassword").send_keys("admin") | ||
driver.find_element_by_id("sign_in").click() | ||
btn_next = driver.find_element_by_id('next-page') | ||
next_step_text = btn_next.text | ||
# Go through the setup wizard till the last page is displayed. | ||
while next_step_text != 'Finish': | ||
btn_next.click() | ||
# wait till current step element is rendered | ||
current_step = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "current-step"))) | ||
btn_next = driver.find_element_by_id('next-page') | ||
next_step_text = btn_next.text | ||
|
||
# Finish | ||
btn_next.click() | ||
|
||
# Check that the dashboard title is displayed | ||
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "widgets-container"))) | ||
dashboard_title = driver.find_element_by_id("title") | ||
self.assertRegexpMatches(dashboard_title.text, r"^[\s\S]*System Dashboard[\s\S]*$") | ||
# logout | ||
driver.find_element_by_id("logout_user").click() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.ui import Select | ||
from selenium.common.exceptions import NoSuchElementException | ||
import unittest, time, re | ||
from rockstor_testcase import RockStorTestCase | ||
|
||
class LoginInvalidPassword(RockStorTestCase): | ||
|
||
def test_login_invalid_username(self): | ||
driver = self.driver | ||
driver.get(self.base_url + "/login_page") | ||
driver.find_element_by_id("inputUsername").clear() | ||
driver.find_element_by_id("inputUsername").send_keys("admin") | ||
driver.find_element_by_id("inputPassword").clear() | ||
driver.find_element_by_id("inputPassword").send_keys("admin1") | ||
driver.find_element_by_css_selector("button.btn.btn-primary").click() | ||
# Warning: verifyTextPresent may require manual changes | ||
self.assertRegexpMatches(driver.find_element(by=By.TAG_NAME, value="body").text, r"^[\s\S]*Login incorrect![\s\S]*$") | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.support.ui import Select | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
from selenium.common.exceptions import NoSuchElementException | ||
from selenium.webdriver.support import expected_conditions as EC | ||
import unittest, time, re | ||
import yaml | ||
import sys, getopt | ||
from rockstor_testcase import RockStorTestCase | ||
from inspect import stack | ||
from util import read_conf | ||
from inspect import stack | ||
import sys, traceback | ||
|
||
class PoolsCreateRaid02Disks(RockStorTestCase): | ||
|
||
def test_create_raid0_2disks(self): | ||
try: | ||
self.login() | ||
self.create_pool() | ||
except Exception, e: | ||
exc_type, exc_value, exc_traceback = sys.exc_info() | ||
traceback.print_exception(exc_type, exc_value, exc_traceback, | ||
limit=2, file=sys.stdout) | ||
self.save_screenshot(stack()[0][3]) | ||
|
||
def login(self): | ||
# Login | ||
driver = self.driver | ||
driver.get(self.base_url + "/login_page") | ||
driver.find_element_by_id("inputUsername").clear() | ||
driver.find_element_by_id("inputUsername").send_keys("admin") | ||
driver.find_element_by_id("inputPassword").clear() | ||
driver.find_element_by_id("inputPassword").send_keys("admin") | ||
driver.find_element_by_id("sign_in").click() | ||
|
||
# Check that the dashboard title is displayed | ||
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "widgets-container"))) | ||
dashboard_title = driver.find_element_by_id("title") | ||
self.assertRegexpMatches(dashboard_title.text, r"^[\s\S]*Dashboard[\s\S]*$") | ||
|
||
def create_pool(self): | ||
driver = self.driver | ||
driver.find_element_by_id("pools_nav").click() | ||
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "add_pool"))) | ||
driver.find_element_by_id("add_pool").click() | ||
driver.find_element_by_id("pool_name").clear() | ||
driver.find_element_by_id("pool_name").send_keys("pool1") | ||
driver.find_element_by_id("sdb").click() | ||
driver.find_element_by_id("sdc").click() | ||
driver.find_element_by_id("create_pool").click() | ||
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.LINK_TEXT, "pool1"))) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
base_url: https://rs14staging | ||
screenshot_dir: output | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import yaml | ||
import argparse | ||
|
||
def read_conf(env_name): | ||
def read_conf(): | ||
parser = argparse.ArgumentParser(description='Run RockStor webdriver tests.') | ||
parser.add_argument('-e', '--env_name', default='development') | ||
parser.add_argument('testname', nargs='?', default=None) | ||
args = parser.parse_args() | ||
conf = None | ||
with open('config.yaml','r') as f: | ||
with open('%s.yaml' % args.env_name,'r') as f: | ||
conf = yaml.load(f) | ||
return conf | ||
|