|
| 1 | +import unittest |
| 2 | +from selenium import webdriver |
| 3 | +from selenium.webdriver.common.keys import Keys |
| 4 | +from selenium.webdriver.support.select import Select |
| 5 | +from selenium.webdriver.common.by import By |
| 6 | +from selenium.webdriver.support.ui import WebDriverWait |
| 7 | +from selenium.webdriver.support import expected_conditions as EC |
| 8 | +from self import self |
| 9 | + |
| 10 | + |
| 11 | +class DemoMaharaOrgLogin(unittest.TestCase): |
| 12 | + @classmethod |
| 13 | + def setUpClass(cls): |
| 14 | + self.driver=webdriver.Chrome() |
| 15 | + self.driver.maximize_window() |
| 16 | + def setUp(self): |
| 17 | + driver=self.driver |
| 18 | + driver.get("https://demo.mahara.org/") |
| 19 | + # define username web element |
| 20 | + username = driver.find_element_by_id("login_login_username") |
| 21 | + # enter student11 in the username field |
| 22 | + username.send_keys("student1") |
| 23 | + # define password web element |
| 24 | + password = driver.find_element_by_name("login_password") |
| 25 | + # enter password in the password field |
| 26 | + password.send_keys("Test@123stu") |
| 27 | + # define login button |
| 28 | + loginbutton = driver.find_element_by_id("login_submit") |
| 29 | + # click on login button |
| 30 | + loginbutton.click() |
| 31 | + def test_change_maximum_tags_in_cloud(self): |
| 32 | + driver=self.driver |
| 33 | + settings=driver.find_element_by_link_text("Settings") |
| 34 | + settings.click() |
| 35 | + driver.implicitly_wait(5) |
| 36 | + maxtags=driver.find_element_by_xpath("//*[@id='accountprefs_tagssideblockmaxtags']") |
| 37 | + maxtags.clear() |
| 38 | + maxtags.send_keys(30) |
| 39 | + self.driver.implicitly_wait(5) |
| 40 | + savebutton=driver.find_element_by_id("accountprefs_submit") |
| 41 | + savebutton.click() |
| 42 | + driver.implicitly_wait(4) |
| 43 | + max_text=driver.find_element_by_xpath("//*[@id='accountprefs_tagssideblockmaxtags']").get_attribute("value") |
| 44 | + print(max_text) |
| 45 | + self.assertTrue(max_text,"30") |
| 46 | + |
| 47 | + def test_change_default_licence(self): |
| 48 | + driver=self.driver |
| 49 | + settings=driver.find_element_by_link_text("Settings") |
| 50 | + settings.click() |
| 51 | + wait=WebDriverWait(driver,30) |
| 52 | + licence_select=wait.until(EC.presence_of_all_elements_located(By.XPATH,"//*[@id='accountprefs_licensedefault']")) |
| 53 | + select=Select(driver.find_element_by_xpath("//*[@id='accountprefs_licensedefault']")) |
| 54 | + driver.implicitly_wait(5) |
| 55 | + select.select_by_visible_text("Creative Commons Attribution 4.0") |
| 56 | + savebutton = driver.find_element_by_id("accountprefs_submit") |
| 57 | + savebutton.click() |
| 58 | + self.assertTrue(driver.find_element_by_xpath("//*[@id='accountprefs_licensedefault']").text,"Creative Commons Attribution 4.0") |
| 59 | + |
| 60 | + def tearDown(self): |
| 61 | + driver=self.driver |
| 62 | + logout=driver.find_element_by_link_text("Logout") |
| 63 | + |
| 64 | + @classmethod |
| 65 | + def tearDownClass(self): |
| 66 | + self.driver.close() |
| 67 | + self.driver.quit() |
| 68 | + |
| 69 | +if __name__ == '__main__': |
| 70 | + unittest.main() |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + |
0 commit comments