| | 1542 | |
| | 1543 | '''Тестирање на апликацијата со Selenium IDE''' |
| | 1544 | |
| | 1545 | Тестовите се експортирани како C#/NUnit/Web Driver. |
| | 1546 | |
| | 1547 | '''Register.cs''' |
| | 1548 | {{{ |
| | 1549 | using System; |
| | 1550 | using System.Text; |
| | 1551 | using System.Text.RegularExpressions; |
| | 1552 | using System.Threading; |
| | 1553 | using NUnit.Framework; |
| | 1554 | using OpenQA.Selenium; |
| | 1555 | using OpenQA.Selenium.Firefox; |
| | 1556 | using OpenQA.Selenium.Support.UI; |
| | 1557 | |
| | 1558 | namespace SeleniumTests |
| | 1559 | { |
| | 1560 | [TestFixture] |
| | 1561 | public class Register |
| | 1562 | { |
| | 1563 | private IWebDriver driver; |
| | 1564 | private StringBuilder verificationErrors; |
| | 1565 | private string baseURL; |
| | 1566 | private bool acceptNextAlert = true; |
| | 1567 | |
| | 1568 | [SetUp] |
| | 1569 | public void SetupTest() |
| | 1570 | { |
| | 1571 | driver = new FirefoxDriver(); |
| | 1572 | baseURL = "http://localhost:1400/"; |
| | 1573 | verificationErrors = new StringBuilder(); |
| | 1574 | } |
| | 1575 | |
| | 1576 | [TearDown] |
| | 1577 | public void TeardownTest() |
| | 1578 | { |
| | 1579 | try |
| | 1580 | { |
| | 1581 | driver.Quit(); |
| | 1582 | } |
| | 1583 | catch (Exception) |
| | 1584 | { |
| | 1585 | // Ignore errors if unable to close the browser |
| | 1586 | } |
| | 1587 | Assert.AreEqual("", verificationErrors.ToString()); |
| | 1588 | } |
| | 1589 | |
| | 1590 | [Test] |
| | 1591 | public void TheRegisterTest() |
| | 1592 | { |
| | 1593 | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
| | 1594 | driver.FindElement(By.Id("ctl10_registerLink")).Click(); |
| | 1595 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
| | 1596 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("novstudent3"); |
| | 1597 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); |
| | 1598 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("novstudent1@mail.com"); |
| | 1599 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
| | 1600 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("novstudent"); |
| | 1601 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
| | 1602 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("novstudent"); |
| | 1603 | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
| | 1604 | driver.FindElement(By.Id("MainContent_txtImePrezime")).Clear(); |
| | 1605 | driver.FindElement(By.Id("MainContent_txtImePrezime")).SendKeys("Student Nov"); |
| | 1606 | driver.FindElement(By.Id("MainContent_txtMesto")).Clear(); |
| | 1607 | driver.FindElement(By.Id("MainContent_txtMesto")).SendKeys("New York"); |
| | 1608 | driver.FindElement(By.Id("MainContent_txtDatum")).Clear(); |
| | 1609 | driver.FindElement(By.Id("MainContent_txtDatum")).SendKeys("01-08-1990"); |
| | 1610 | driver.FindElement(By.Id("MainContent_txtObrazovanie")).Clear(); |
| | 1611 | driver.FindElement(By.Id("MainContent_txtObrazovanie")).SendKeys("BS"); |
| | 1612 | driver.FindElement(By.Id("MainContent_txtInstitucija")).Clear(); |
| | 1613 | driver.FindElement(By.Id("MainContent_txtInstitucija")).SendKeys("Proba"); |
| | 1614 | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).Clear(); |
| | 1615 | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).SendKeys("Proba"); |
| | 1616 | driver.FindElement(By.Id("MainContent_txtPozicija")).Clear(); |
| | 1617 | driver.FindElement(By.Id("MainContent_txtPozicija")).SendKeys("Proba"); |
| | 1618 | driver.FindElement(By.Id("MainContent_btnAdd")).Click(); |
| | 1619 | driver.FindElement(By.Id("MainContent_Button2")).Click(); |
| | 1620 | driver.FindElement(By.Id("MainContent_Button1")).Click(); |
| | 1621 | driver.FindElement(By.Id("MainContent_txtActivity")).Clear(); |
| | 1622 | driver.FindElement(By.Id("MainContent_txtActivity")).SendKeys("rrr"); |
| | 1623 | driver.FindElement(By.Id("MainContent_btnShow")).Click(); |
| | 1624 | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).Clear(); |
| | 1625 | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).SendKeys("uuu"); |
| | 1626 | driver.FindElement(By.Id("MainContent_gvMe_CheckBox1_0")).Click(); |
| | 1627 | driver.FindElement(By.Id("MainContent_btnAddMe")).Click(); |
| | 1628 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| | 1629 | } |
| | 1630 | private bool IsElementPresent(By by) |
| | 1631 | { |
| | 1632 | try |
| | 1633 | { |
| | 1634 | driver.FindElement(by); |
| | 1635 | return true; |
| | 1636 | } |
| | 1637 | catch (NoSuchElementException) |
| | 1638 | { |
| | 1639 | return false; |
| | 1640 | } |
| | 1641 | } |
| | 1642 | |
| | 1643 | private bool IsAlertPresent() |
| | 1644 | { |
| | 1645 | try |
| | 1646 | { |
| | 1647 | driver.SwitchTo().Alert(); |
| | 1648 | return true; |
| | 1649 | } |
| | 1650 | catch (NoAlertPresentException) |
| | 1651 | { |
| | 1652 | return false; |
| | 1653 | } |
| | 1654 | } |
| | 1655 | |
| | 1656 | private string CloseAlertAndGetItsText() { |
| | 1657 | try { |
| | 1658 | IAlert alert = driver.SwitchTo().Alert(); |
| | 1659 | string alertText = alert.Text; |
| | 1660 | if (acceptNextAlert) { |
| | 1661 | alert.Accept(); |
| | 1662 | } else { |
| | 1663 | alert.Dismiss(); |
| | 1664 | } |
| | 1665 | return alertText; |
| | 1666 | } finally { |
| | 1667 | acceptNextAlert = true; |
| | 1668 | } |
| | 1669 | } |
| | 1670 | } |
| | 1671 | } |
| | 1672 | }}} |
| | 1673 | |
| | 1674 | |
| | 1675 | '''LoginFieldValidation.cs''' |
| | 1676 | |
| | 1677 | {{{ |
| | 1678 | using System; |
| | 1679 | using System.Text; |
| | 1680 | using System.Text.RegularExpressions; |
| | 1681 | using System.Threading; |
| | 1682 | using NUnit.Framework; |
| | 1683 | using OpenQA.Selenium; |
| | 1684 | using OpenQA.Selenium.Firefox; |
| | 1685 | using OpenQA.Selenium.Support.UI; |
| | 1686 | |
| | 1687 | namespace SeleniumTests |
| | 1688 | { |
| | 1689 | [TestFixture] |
| | 1690 | public class LoginFieldValidation |
| | 1691 | { |
| | 1692 | private IWebDriver driver; |
| | 1693 | private StringBuilder verificationErrors; |
| | 1694 | private string baseURL; |
| | 1695 | private bool acceptNextAlert = true; |
| | 1696 | |
| | 1697 | [SetUp] |
| | 1698 | public void SetupTest() |
| | 1699 | { |
| | 1700 | driver = new FirefoxDriver(); |
| | 1701 | baseURL = "http://localhost:1400/"; |
| | 1702 | verificationErrors = new StringBuilder(); |
| | 1703 | } |
| | 1704 | |
| | 1705 | [TearDown] |
| | 1706 | public void TeardownTest() |
| | 1707 | { |
| | 1708 | try |
| | 1709 | { |
| | 1710 | driver.Quit(); |
| | 1711 | } |
| | 1712 | catch (Exception) |
| | 1713 | { |
| | 1714 | // Ignore errors if unable to close the browser |
| | 1715 | } |
| | 1716 | Assert.AreEqual("", verificationErrors.ToString()); |
| | 1717 | } |
| | 1718 | |
| | 1719 | [Test] |
| | 1720 | public void TheLoginFieldValidationTest() |
| | 1721 | { |
| | 1722 | driver.Navigate().GoToUrl(baseURL + "/"); |
| | 1723 | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
| | 1724 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| | 1725 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| | 1726 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| | 1727 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| | 1728 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("aaa"); |
| | 1729 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| | 1730 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| | 1731 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student12"); |
| | 1732 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| | 1733 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1233"); |
| | 1734 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| | 1735 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| | 1736 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| | 1737 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| | 1738 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); |
| | 1739 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| | 1740 | } |
| | 1741 | private bool IsElementPresent(By by) |
| | 1742 | { |
| | 1743 | try |
| | 1744 | { |
| | 1745 | driver.FindElement(by); |
| | 1746 | return true; |
| | 1747 | } |
| | 1748 | catch (NoSuchElementException) |
| | 1749 | { |
| | 1750 | return false; |
| | 1751 | } |
| | 1752 | } |
| | 1753 | |
| | 1754 | private bool IsAlertPresent() |
| | 1755 | { |
| | 1756 | try |
| | 1757 | { |
| | 1758 | driver.SwitchTo().Alert(); |
| | 1759 | return true; |
| | 1760 | } |
| | 1761 | catch (NoAlertPresentException) |
| | 1762 | { |
| | 1763 | return false; |
| | 1764 | } |
| | 1765 | } |
| | 1766 | |
| | 1767 | private string CloseAlertAndGetItsText() { |
| | 1768 | try { |
| | 1769 | IAlert alert = driver.SwitchTo().Alert(); |
| | 1770 | string alertText = alert.Text; |
| | 1771 | if (acceptNextAlert) { |
| | 1772 | alert.Accept(); |
| | 1773 | } else { |
| | 1774 | alert.Dismiss(); |
| | 1775 | } |
| | 1776 | return alertText; |
| | 1777 | } finally { |
| | 1778 | acceptNextAlert = true; |
| | 1779 | } |
| | 1780 | } |
| | 1781 | } |
| | 1782 | } |
| | 1783 | }}} |
| | 1784 | |
| | 1785 | '''Registerfieldvalidation.cs''' |
| | 1786 | {{{ |
| | 1787 | using System; |
| | 1788 | using System.Text; |
| | 1789 | using System.Text.RegularExpressions; |
| | 1790 | using System.Threading; |
| | 1791 | using NUnit.Framework; |
| | 1792 | using OpenQA.Selenium; |
| | 1793 | using OpenQA.Selenium.Firefox; |
| | 1794 | using OpenQA.Selenium.Support.UI; |
| | 1795 | |
| | 1796 | namespace SeleniumTests |
| | 1797 | { |
| | 1798 | [TestFixture] |
| | 1799 | public class RegisterFieldValidation |
| | 1800 | { |
| | 1801 | private IWebDriver driver; |
| | 1802 | private StringBuilder verificationErrors; |
| | 1803 | private string baseURL; |
| | 1804 | private bool acceptNextAlert = true; |
| | 1805 | |
| | 1806 | [SetUp] |
| | 1807 | public void SetupTest() |
| | 1808 | { |
| | 1809 | driver = new FirefoxDriver(); |
| | 1810 | baseURL = "http://localhost:1400/"; |
| | 1811 | verificationErrors = new StringBuilder(); |
| | 1812 | } |
| | 1813 | |
| | 1814 | [TearDown] |
| | 1815 | public void TeardownTest() |
| | 1816 | { |
| | 1817 | try |
| | 1818 | { |
| | 1819 | driver.Quit(); |
| | 1820 | } |
| | 1821 | catch (Exception) |
| | 1822 | { |
| | 1823 | // Ignore errors if unable to close the browser |
| | 1824 | } |
| | 1825 | Assert.AreEqual("", verificationErrors.ToString()); |
| | 1826 | } |
| | 1827 | |
| | 1828 | [Test] |
| | 1829 | public void TheRegisterFieldValidationTest() |
| | 1830 | { |
| | 1831 | driver.Navigate().GoToUrl(baseURL + "/"); |
| | 1832 | driver.FindElement(By.Id("ctl10_registerLink")).Click(); |
| | 1833 | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
| | 1834 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
| | 1835 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abc"); |
| | 1836 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); |
| | 1837 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("abc@mail.com"); |
| | 1838 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
| | 1839 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("abcabc1"); |
| | 1840 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
| | 1841 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abcabc1"); |
| | 1842 | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
| | 1843 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
| | 1844 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abcde"); |
| | 1845 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
| | 1846 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("abcdefg1"); |
| | 1847 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
| | 1848 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abvv"); |
| | 1849 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
| | 1850 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abcdefg1"); |
| | 1851 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
| | 1852 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abcdefg"); |
| | 1853 | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
| | 1854 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| | 1855 | } |
| | 1856 | private bool IsElementPresent(By by) |
| | 1857 | { |
| | 1858 | try |
| | 1859 | { |
| | 1860 | driver.FindElement(by); |
| | 1861 | return true; |
| | 1862 | } |
| | 1863 | catch (NoSuchElementException) |
| | 1864 | { |
| | 1865 | return false; |
| | 1866 | } |
| | 1867 | } |
| | 1868 | |
| | 1869 | private bool IsAlertPresent() |
| | 1870 | { |
| | 1871 | try |
| | 1872 | { |
| | 1873 | driver.SwitchTo().Alert(); |
| | 1874 | return true; |
| | 1875 | } |
| | 1876 | catch (NoAlertPresentException) |
| | 1877 | { |
| | 1878 | return false; |
| | 1879 | } |
| | 1880 | } |
| | 1881 | |
| | 1882 | private string CloseAlertAndGetItsText() { |
| | 1883 | try { |
| | 1884 | IAlert alert = driver.SwitchTo().Alert(); |
| | 1885 | string alertText = alert.Text; |
| | 1886 | if (acceptNextAlert) { |
| | 1887 | alert.Accept(); |
| | 1888 | } else { |
| | 1889 | alert.Dismiss(); |
| | 1890 | } |
| | 1891 | return alertText; |
| | 1892 | } finally { |
| | 1893 | acceptNextAlert = true; |
| | 1894 | } |
| | 1895 | } |
| | 1896 | } |
| | 1897 | } |
| | 1898 | }}} |
| | 1899 | |
| | 1900 | '''Search.cs''' |
| | 1901 | {{{ |
| | 1902 | using System; |
| | 1903 | using System.Text; |
| | 1904 | using System.Text.RegularExpressions; |
| | 1905 | using System.Threading; |
| | 1906 | using NUnit.Framework; |
| | 1907 | using OpenQA.Selenium; |
| | 1908 | using OpenQA.Selenium.Firefox; |
| | 1909 | using OpenQA.Selenium.Support.UI; |
| | 1910 | |
| | 1911 | namespace SeleniumTests |
| | 1912 | { |
| | 1913 | [TestFixture] |
| | 1914 | public class Search |
| | 1915 | { |
| | 1916 | private IWebDriver driver; |
| | 1917 | private StringBuilder verificationErrors; |
| | 1918 | private string baseURL; |
| | 1919 | private bool acceptNextAlert = true; |
| | 1920 | |
| | 1921 | [SetUp] |
| | 1922 | public void SetupTest() |
| | 1923 | { |
| | 1924 | driver = new FirefoxDriver(); |
| | 1925 | baseURL = "http://localhost:1400/"; |
| | 1926 | verificationErrors = new StringBuilder(); |
| | 1927 | } |
| | 1928 | |
| | 1929 | [TearDown] |
| | 1930 | public void TeardownTest() |
| | 1931 | { |
| | 1932 | try |
| | 1933 | { |
| | 1934 | driver.Quit(); |
| | 1935 | } |
| | 1936 | catch (Exception) |
| | 1937 | { |
| | 1938 | // Ignore errors if unable to close the browser |
| | 1939 | } |
| | 1940 | Assert.AreEqual("", verificationErrors.ToString()); |
| | 1941 | } |
| | 1942 | |
| | 1943 | [Test] |
| | 1944 | public void TheSearchTest() |
| | 1945 | { |
| | 1946 | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
| | 1947 | driver.FindElement(By.LinkText("Контакт")).Click(); |
| | 1948 | driver.FindElement(By.Id("txtSearch")).Clear(); |
| | 1949 | driver.FindElement(By.Id("txtSearch")).SendKeys("IS"); |
| | 1950 | driver.FindElement(By.Id("btnSearch")).Click(); |
| | 1951 | driver.FindElement(By.LinkText("Почетна")).Click(); |
| | 1952 | driver.FindElement(By.Id("txtSearch")).Clear(); |
| | 1953 | driver.FindElement(By.Id("txtSearch")).SendKeys("IS"); |
| | 1954 | driver.FindElement(By.Id("btnSearch")).Click(); |
| | 1955 | } |
| | 1956 | private bool IsElementPresent(By by) |
| | 1957 | { |
| | 1958 | try |
| | 1959 | { |
| | 1960 | driver.FindElement(by); |
| | 1961 | return true; |
| | 1962 | } |
| | 1963 | catch (NoSuchElementException) |
| | 1964 | { |
| | 1965 | return false; |
| | 1966 | } |
| | 1967 | } |
| | 1968 | |
| | 1969 | private bool IsAlertPresent() |
| | 1970 | { |
| | 1971 | try |
| | 1972 | { |
| | 1973 | driver.SwitchTo().Alert(); |
| | 1974 | return true; |
| | 1975 | } |
| | 1976 | catch (NoAlertPresentException) |
| | 1977 | { |
| | 1978 | return false; |
| | 1979 | } |
| | 1980 | } |
| | 1981 | |
| | 1982 | private string CloseAlertAndGetItsText() { |
| | 1983 | try { |
| | 1984 | IAlert alert = driver.SwitchTo().Alert(); |
| | 1985 | string alertText = alert.Text; |
| | 1986 | if (acceptNextAlert) { |
| | 1987 | alert.Accept(); |
| | 1988 | } else { |
| | 1989 | alert.Dismiss(); |
| | 1990 | } |
| | 1991 | return alertText; |
| | 1992 | } finally { |
| | 1993 | acceptNextAlert = true; |
| | 1994 | } |
| | 1995 | } |
| | 1996 | } |
| | 1997 | } |
| | 1998 | }}} |
| | 1999 | |
| | 2000 | '''Changepassword.cs''' |
| | 2001 | {{{ |
| | 2002 | using System; |
| | 2003 | using System.Text; |
| | 2004 | using System.Text.RegularExpressions; |
| | 2005 | using System.Threading; |
| | 2006 | using NUnit.Framework; |
| | 2007 | using OpenQA.Selenium; |
| | 2008 | using OpenQA.Selenium.Firefox; |
| | 2009 | using OpenQA.Selenium.Support.UI; |
| | 2010 | |
| | 2011 | namespace SeleniumTests |
| | 2012 | { |
| | 2013 | [TestFixture] |
| | 2014 | public class ChangePassword |
| | 2015 | { |
| | 2016 | private IWebDriver driver; |
| | 2017 | private StringBuilder verificationErrors; |
| | 2018 | private string baseURL; |
| | 2019 | private bool acceptNextAlert = true; |
| | 2020 | |
| | 2021 | [SetUp] |
| | 2022 | public void SetupTest() |
| | 2023 | { |
| | 2024 | driver = new FirefoxDriver(); |
| | 2025 | baseURL = "http://localhost:1400/"; |
| | 2026 | verificationErrors = new StringBuilder(); |
| | 2027 | } |
| | 2028 | |
| | 2029 | [TearDown] |
| | 2030 | public void TeardownTest() |
| | 2031 | { |
| | 2032 | try |
| | 2033 | { |
| | 2034 | driver.Quit(); |
| | 2035 | } |
| | 2036 | catch (Exception) |
| | 2037 | { |
| | 2038 | // Ignore errors if unable to close the browser |
| | 2039 | } |
| | 2040 | Assert.AreEqual("", verificationErrors.ToString()); |
| | 2041 | } |
| | 2042 | |
| | 2043 | [Test] |
| | 2044 | public void TheChangePasswordTest() |
| | 2045 | { |
| | 2046 | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
| | 2047 | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
| | 2048 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| | 2049 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| | 2050 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| | 2051 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); |
| | 2052 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| | 2053 | driver.FindElement(By.Id("ctl10_hpLink")).Click(); |
| | 2054 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_CurrentPassword")).Clear(); |
| | 2055 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_CurrentPassword")).SendKeys("student123"); |
| | 2056 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_NewPassword")).Clear(); |
| | 2057 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_NewPassword")).SendKeys("student1234"); |
| | 2058 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_ConfirmNewPassword")).Clear(); |
| | 2059 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_ConfirmNewPassword")).SendKeys("student1234"); |
| | 2060 | driver.FindElement(By.Name("ctl00$MainContent$ctl07$ChangePasswordContainerID$ctl04")).Click(); |
| | 2061 | driver.FindElement(By.LinkText("Одјави се")).Click(); |
| | 2062 | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
| | 2063 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| | 2064 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| | 2065 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| | 2066 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1234"); |
| | 2067 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| | 2068 | driver.FindElement(By.LinkText("Одјави се")).Click(); |
| | 2069 | } |
| | 2070 | private bool IsElementPresent(By by) |
| | 2071 | { |
| | 2072 | try |
| | 2073 | { |
| | 2074 | driver.FindElement(by); |
| | 2075 | return true; |
| | 2076 | } |
| | 2077 | catch (NoSuchElementException) |
| | 2078 | { |
| | 2079 | return false; |
| | 2080 | } |
| | 2081 | } |
| | 2082 | |
| | 2083 | private bool IsAlertPresent() |
| | 2084 | { |
| | 2085 | try |
| | 2086 | { |
| | 2087 | driver.SwitchTo().Alert(); |
| | 2088 | return true; |
| | 2089 | } |
| | 2090 | catch (NoAlertPresentException) |
| | 2091 | { |
| | 2092 | return false; |
| | 2093 | } |
| | 2094 | } |
| | 2095 | |
| | 2096 | private string CloseAlertAndGetItsText() { |
| | 2097 | try { |
| | 2098 | IAlert alert = driver.SwitchTo().Alert(); |
| | 2099 | string alertText = alert.Text; |
| | 2100 | if (acceptNextAlert) { |
| | 2101 | alert.Accept(); |
| | 2102 | } else { |
| | 2103 | alert.Dismiss(); |
| | 2104 | } |
| | 2105 | return alertText; |
| | 2106 | } finally { |
| | 2107 | acceptNextAlert = true; |
| | 2108 | } |
| | 2109 | } |
| | 2110 | } |
| | 2111 | } |
| | 2112 | }}} |
| | 2113 | |
| | 2114 | '''Addinfo.cs''' |
| | 2115 | {{{ |
| | 2116 | using System; |
| | 2117 | using System.Text; |
| | 2118 | using System.Text.RegularExpressions; |
| | 2119 | using System.Threading; |
| | 2120 | using NUnit.Framework; |
| | 2121 | using OpenQA.Selenium; |
| | 2122 | using OpenQA.Selenium.Firefox; |
| | 2123 | using OpenQA.Selenium.Support.UI; |
| | 2124 | |
| | 2125 | namespace SeleniumTests |
| | 2126 | { |
| | 2127 | [TestFixture] |
| | 2128 | public class AddInfoLater |
| | 2129 | { |
| | 2130 | private IWebDriver driver; |
| | 2131 | private StringBuilder verificationErrors; |
| | 2132 | private string baseURL; |
| | 2133 | private bool acceptNextAlert = true; |
| | 2134 | |
| | 2135 | [SetUp] |
| | 2136 | public void SetupTest() |
| | 2137 | { |
| | 2138 | driver = new FirefoxDriver(); |
| | 2139 | baseURL = "http://localhost:1400/"; |
| | 2140 | verificationErrors = new StringBuilder(); |
| | 2141 | } |
| | 2142 | |
| | 2143 | [TearDown] |
| | 2144 | public void TeardownTest() |
| | 2145 | { |
| | 2146 | try |
| | 2147 | { |
| | 2148 | driver.Quit(); |
| | 2149 | } |
| | 2150 | catch (Exception) |
| | 2151 | { |
| | 2152 | // Ignore errors if unable to close the browser |
| | 2153 | } |
| | 2154 | Assert.AreEqual("", verificationErrors.ToString()); |
| | 2155 | } |
| | 2156 | |
| | 2157 | [Test] |
| | 2158 | public void TheAddInfoLaterTest() |
| | 2159 | { |
| | 2160 | driver.Navigate().GoToUrl(baseURL + "/"); |
| | 2161 | driver.FindElement(By.Id("ctl10_registerLink")).Click(); |
| | 2162 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
| | 2163 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("mojasmetka1"); |
| | 2164 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); |
| | 2165 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("adresa@mail.com"); |
| | 2166 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
| | 2167 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("mojasmetka1"); |
| | 2168 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
| | 2169 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("mojasmetka1"); |
| | 2170 | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
| | 2171 | driver.FindElement(By.Id("MainContent_Button2")).Click(); |
| | 2172 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| | 2173 | driver.FindElement(By.CssSelector("span.username")).Click(); |
| | 2174 | driver.FindElement(By.Id("MainContent_txtImePrezime")).Clear(); |
| | 2175 | driver.FindElement(By.Id("MainContent_txtImePrezime")).SendKeys("moja"); |
| | 2176 | driver.FindElement(By.Id("MainContent_rblPol_1")).Click(); |
| | 2177 | driver.FindElement(By.Id("MainContent_txtMesto")).Clear(); |
| | 2178 | driver.FindElement(By.Id("MainContent_txtMesto")).SendKeys("ww"); |
| | 2179 | driver.FindElement(By.Id("MainContent_txtDatum")).Clear(); |
| | 2180 | driver.FindElement(By.Id("MainContent_txtDatum")).SendKeys("16.06.1989"); |
| | 2181 | driver.FindElement(By.Id("MainContent_txtObrazovanie")).Clear(); |
| | 2182 | driver.FindElement(By.Id("MainContent_txtObrazovanie")).SendKeys("ww"); |
| | 2183 | driver.FindElement(By.Id("MainContent_txtInstitucija")).Clear(); |
| | 2184 | driver.FindElement(By.Id("MainContent_txtInstitucija")).SendKeys("ww"); |
| | 2185 | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).Clear(); |
| | 2186 | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).SendKeys("ww"); |
| | 2187 | driver.FindElement(By.Id("MainContent_txtPozicija")).Clear(); |
| | 2188 | driver.FindElement(By.Id("MainContent_txtPozicija")).SendKeys("ww"); |
| | 2189 | driver.FindElement(By.Id("MainContent_btnAdd")).Click(); |
| | 2190 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| | 2191 | } |
| | 2192 | private bool IsElementPresent(By by) |
| | 2193 | { |
| | 2194 | try |
| | 2195 | { |
| | 2196 | driver.FindElement(by); |
| | 2197 | return true; |
| | 2198 | } |
| | 2199 | catch (NoSuchElementException) |
| | 2200 | { |
| | 2201 | return false; |
| | 2202 | } |
| | 2203 | } |
| | 2204 | |
| | 2205 | private bool IsAlertPresent() |
| | 2206 | { |
| | 2207 | try |
| | 2208 | { |
| | 2209 | driver.SwitchTo().Alert(); |
| | 2210 | return true; |
| | 2211 | } |
| | 2212 | catch (NoAlertPresentException) |
| | 2213 | { |
| | 2214 | return false; |
| | 2215 | } |
| | 2216 | } |
| | 2217 | |
| | 2218 | private string CloseAlertAndGetItsText() { |
| | 2219 | try { |
| | 2220 | IAlert alert = driver.SwitchTo().Alert(); |
| | 2221 | string alertText = alert.Text; |
| | 2222 | if (acceptNextAlert) { |
| | 2223 | alert.Accept(); |
| | 2224 | } else { |
| | 2225 | alert.Dismiss(); |
| | 2226 | } |
| | 2227 | return alertText; |
| | 2228 | } finally { |
| | 2229 | acceptNextAlert = true; |
| | 2230 | } |
| | 2231 | } |
| | 2232 | } |
| | 2233 | } |
| | 2234 | |
| | 2235 | }}} |
| | 2236 | |
| | 2237 | '''Addnewactivity.cs''' |
| | 2238 | {{{ |
| | 2239 | using System; |
| | 2240 | using System.Text; |
| | 2241 | using System.Text.RegularExpressions; |
| | 2242 | using System.Threading; |
| | 2243 | using NUnit.Framework; |
| | 2244 | using OpenQA.Selenium; |
| | 2245 | using OpenQA.Selenium.Firefox; |
| | 2246 | using OpenQA.Selenium.Support.UI; |
| | 2247 | |
| | 2248 | namespace SeleniumTests |
| | 2249 | { |
| | 2250 | [TestFixture] |
| | 2251 | public class AddNewActivity |
| | 2252 | { |
| | 2253 | private IWebDriver driver; |
| | 2254 | private StringBuilder verificationErrors; |
| | 2255 | private string baseURL; |
| | 2256 | private bool acceptNextAlert = true; |
| | 2257 | |
| | 2258 | [SetUp] |
| | 2259 | public void SetupTest() |
| | 2260 | { |
| | 2261 | driver = new FirefoxDriver(); |
| | 2262 | baseURL = "http://localhost:1400/"; |
| | 2263 | verificationErrors = new StringBuilder(); |
| | 2264 | } |
| | 2265 | |
| | 2266 | [TearDown] |
| | 2267 | public void TeardownTest() |
| | 2268 | { |
| | 2269 | try |
| | 2270 | { |
| | 2271 | driver.Quit(); |
| | 2272 | } |
| | 2273 | catch (Exception) |
| | 2274 | { |
| | 2275 | // Ignore errors if unable to close the browser |
| | 2276 | } |
| | 2277 | Assert.AreEqual("", verificationErrors.ToString()); |
| | 2278 | } |
| | 2279 | |
| | 2280 | [Test] |
| | 2281 | public void TheAddNewActivityTest() |
| | 2282 | { |
| | 2283 | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
| | 2284 | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
| | 2285 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| | 2286 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| | 2287 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| | 2288 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1234"); |
| | 2289 | driver.FindElement(By.Id("MainContent_ctl00_RememberMe")).Click(); |
| | 2290 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| | 2291 | driver.FindElement(By.Id("MainContent_Button1")).Click(); |
| | 2292 | driver.FindElement(By.Id("MainContent_txtName")).Clear(); |
| | 2293 | driver.FindElement(By.Id("MainContent_txtName")).SendKeys("nestonovo"); |
| | 2294 | driver.FindElement(By.Id("MainContent_txtCategory")).Clear(); |
| | 2295 | driver.FindElement(By.Id("MainContent_txtCategory")).SendKeys("/"); |
| | 2296 | driver.FindElement(By.Id("MainContent_txtPlace")).Clear(); |
| | 2297 | driver.FindElement(By.Id("MainContent_txtPlace")).SendKeys("Proba"); |
| | 2298 | driver.FindElement(By.Id("MainContent_txtDate")).Clear(); |
| | 2299 | driver.FindElement(By.Id("MainContent_txtDate")).SendKeys("11.11.2013"); |
| | 2300 | driver.FindElement(By.Id("MainContent_txtRole")).Clear(); |
| | 2301 | driver.FindElement(By.Id("MainContent_txtRole")).SendKeys("/"); |
| | 2302 | driver.FindElement(By.Id("MainContent_btnInsert")).Click(); |
| | 2303 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| | 2304 | driver.FindElement(By.LinkText("Одјави се")).Click(); |
| | 2305 | } |
| | 2306 | private bool IsElementPresent(By by) |
| | 2307 | { |
| | 2308 | try |
| | 2309 | { |
| | 2310 | driver.FindElement(by); |
| | 2311 | return true; |
| | 2312 | } |
| | 2313 | catch (NoSuchElementException) |
| | 2314 | { |
| | 2315 | return false; |
| | 2316 | } |
| | 2317 | } |
| | 2318 | |
| | 2319 | private bool IsAlertPresent() |
| | 2320 | { |
| | 2321 | try |
| | 2322 | { |
| | 2323 | driver.SwitchTo().Alert(); |
| | 2324 | return true; |
| | 2325 | } |
| | 2326 | catch (NoAlertPresentException) |
| | 2327 | { |
| | 2328 | return false; |
| | 2329 | } |
| | 2330 | } |
| | 2331 | |
| | 2332 | private string CloseAlertAndGetItsText() { |
| | 2333 | try { |
| | 2334 | IAlert alert = driver.SwitchTo().Alert(); |
| | 2335 | string alertText = alert.Text; |
| | 2336 | if (acceptNextAlert) { |
| | 2337 | alert.Accept(); |
| | 2338 | } else { |
| | 2339 | alert.Dismiss(); |
| | 2340 | } |
| | 2341 | return alertText; |
| | 2342 | } finally { |
| | 2343 | acceptNextAlert = true; |
| | 2344 | } |
| | 2345 | } |
| | 2346 | } |
| | 2347 | } |
| | 2348 | }}} |
| | 2349 | |
| | 2350 | '''Addusertoexistingactivity.cs''' |
| | 2351 | {{{ |
| | 2352 | using System; |
| | 2353 | using System.Text; |
| | 2354 | using System.Text.RegularExpressions; |
| | 2355 | using System.Threading; |
| | 2356 | using NUnit.Framework; |
| | 2357 | using OpenQA.Selenium; |
| | 2358 | using OpenQA.Selenium.Firefox; |
| | 2359 | using OpenQA.Selenium.Support.UI; |
| | 2360 | |
| | 2361 | namespace SeleniumTests |
| | 2362 | { |
| | 2363 | [TestFixture] |
| | 2364 | public class AddUserToExistingActivity |
| | 2365 | { |
| | 2366 | private IWebDriver driver; |
| | 2367 | private StringBuilder verificationErrors; |
| | 2368 | private string baseURL; |
| | 2369 | private bool acceptNextAlert = true; |
| | 2370 | |
| | 2371 | [SetUp] |
| | 2372 | public void SetupTest() |
| | 2373 | { |
| | 2374 | driver = new FirefoxDriver(); |
| | 2375 | baseURL = "http://localhost:1400/"; |
| | 2376 | verificationErrors = new StringBuilder(); |
| | 2377 | } |
| | 2378 | |
| | 2379 | [TearDown] |
| | 2380 | public void TeardownTest() |
| | 2381 | { |
| | 2382 | try |
| | 2383 | { |
| | 2384 | driver.Quit(); |
| | 2385 | } |
| | 2386 | catch (Exception) |
| | 2387 | { |
| | 2388 | // Ignore errors if unable to close the browser |
| | 2389 | } |
| | 2390 | Assert.AreEqual("", verificationErrors.ToString()); |
| | 2391 | } |
| | 2392 | |
| | 2393 | [Test] |
| | 2394 | public void TheAddUserToExistingActivityTest() |
| | 2395 | { |
| | 2396 | driver.Navigate().GoToUrl(baseURL + "/"); |
| | 2397 | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
| | 2398 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| | 2399 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| | 2400 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| | 2401 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); |
| | 2402 | driver.FindElement(By.Id("MainContent_ctl00_RememberMe")).Click(); |
| | 2403 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| | 2404 | driver.FindElement(By.Id("MainContent_Button1")).Click(); |
| | 2405 | driver.FindElement(By.Id("MainContent_txtActivity")).Clear(); |
| | 2406 | driver.FindElement(By.Id("MainContent_txtActivity")).SendKeys("nnnn"); |
| | 2407 | driver.FindElement(By.Id("MainContent_btnShow")).Click(); |
| | 2408 | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).Clear(); |
| | 2409 | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).SendKeys("mmm"); |
| | 2410 | driver.FindElement(By.Id("MainContent_gvMe_CheckBox1_0")).Click(); |
| | 2411 | driver.FindElement(By.Id("MainContent_btnAddMe")).Click(); |
| | 2412 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| | 2413 | driver.FindElement(By.LinkText("2")).Click(); |
| | 2414 | } |
| | 2415 | private bool IsElementPresent(By by) |
| | 2416 | { |
| | 2417 | try |
| | 2418 | { |
| | 2419 | driver.FindElement(by); |
| | 2420 | return true; |
| | 2421 | } |
| | 2422 | catch (NoSuchElementException) |
| | 2423 | { |
| | 2424 | return false; |
| | 2425 | } |
| | 2426 | } |
| | 2427 | |
| | 2428 | private bool IsAlertPresent() |
| | 2429 | { |
| | 2430 | try |
| | 2431 | { |
| | 2432 | driver.SwitchTo().Alert(); |
| | 2433 | return true; |
| | 2434 | } |
| | 2435 | catch (NoAlertPresentException) |
| | 2436 | { |
| | 2437 | return false; |
| | 2438 | } |
| | 2439 | } |
| | 2440 | |
| | 2441 | private string CloseAlertAndGetItsText() { |
| | 2442 | try { |
| | 2443 | IAlert alert = driver.SwitchTo().Alert(); |
| | 2444 | string alertText = alert.Text; |
| | 2445 | if (acceptNextAlert) { |
| | 2446 | alert.Accept(); |
| | 2447 | } else { |
| | 2448 | alert.Dismiss(); |
| | 2449 | } |
| | 2450 | return alertText; |
| | 2451 | } finally { |
| | 2452 | acceptNextAlert = true; |
| | 2453 | } |
| | 2454 | } |
| | 2455 | } |
| | 2456 | } |
| | 2457 | }}} |