Revize b11af9b1
Přidáno uživatelem Jakub Schenk před asi 2 roky(ů)
Backend/FrontendTesting/UserManagementTesting.cs | ||
---|---|---|
49 | 49 |
[DataRow(true, "ggg", "ggg", "", "ggg")] |
50 | 50 |
[DataRow(false, "hhh", "hhh", "", "hhh")] |
51 | 51 |
[DataRow(true, "iii", "iii", "iii", "")] |
52 |
[DataRow(false, "jjj", "jjj", "jjj", "")]*/ |
|
52 |
[DataRow(false, "jjj", "jjj", "jjj", "")] |
|
53 |
there were some problems with multiple tests runs*/ |
|
53 | 54 |
[TestMethod] |
54 | 55 |
[DataRow(false, "aaa", "aaa", "aaa", "aaa")] |
55 | 56 |
public void CreateUser(bool isAdmin, string Username, string Name, string Surname, string Password) |
56 | 57 |
{ |
57 | 58 |
var driver = new ChromeDriver(); |
58 | 59 |
WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromSeconds(5)); |
59 |
|
|
60 |
|
|
60 | 61 |
if (!Login(driver)) Assert.Fail("Login failed"); |
61 | 62 |
driver.Manage().Window.Maximize(); |
62 | 63 |
//Thread.Sleep(1000); |
... | ... | |
66 | 67 |
//popup handling |
67 | 68 |
string currentHandle = driver.CurrentWindowHandle; |
68 | 69 |
ReadOnlyCollection<string> originalHandles = driver.WindowHandles; |
69 |
|
|
70 |
|
|
70 | 71 |
//popup window actions |
71 | 72 |
if (isAdmin) |
72 | 73 |
{ |
... | ... | |
83 | 84 |
|
84 | 85 |
driver.Navigate().Refresh(); |
85 | 86 |
|
86 |
|
|
87 |
|
|
87 | 88 |
//Here should be new user in database if creditals were valid |
88 | 89 |
var table = getTable(driver); |
89 | 90 |
bool found = false; |
90 | 91 |
string nm, srnm, usrnm, rl, dcks; |
91 |
for(int i = 0; i < table.Count-5; i+=6)
|
|
92 |
for (int i = 0; i < table.Count - 5; i += 6)
|
|
92 | 93 |
{ |
93 |
nm= table[i]; |
|
94 |
srnm= table[i+1];
|
|
95 |
usrnm= table[i+2];
|
|
94 |
nm = table[i];
|
|
95 |
srnm = table[i + 1];
|
|
96 |
usrnm = table[i + 2];
|
|
96 | 97 |
//rl= table[i+3]; |
97 | 98 |
//dcks= table[i+4]; |
98 | 99 |
if (nm == Name && srnm == Surname && usrnm == Username) found = true; |
99 | 100 |
} |
100 |
if(Username!="" || Password != "" || Name!="" || Surname!="")
|
|
101 |
if (Username != "" || Password != "" || Name != "" || Surname != "")
|
|
101 | 102 |
{ |
102 | 103 |
//valid creditals - user should be in db |
103 | 104 |
Assert.IsTrue(found, "There should be new user but he was not found."); |
... | ... | |
108 | 109 |
//invalids creditals - user shouldnt be in db |
109 | 110 |
Assert.IsFalse(found, "There should NOT be new user but he was found in the table. "); |
110 | 111 |
} |
111 |
driver.Navigate().GoToUrl(url);
|
|
112 |
driver.Navigate().GoToUrl(url); |
|
112 | 113 |
driver.Close(); |
113 | 114 |
driver.Quit(); |
114 | 115 |
} |
115 | 116 |
|
116 | 117 |
|
117 | 118 |
|
118 |
|
|
119 |
//getting table of users from page for comparison if there is/is not user there should/should not be |
|
119 | 120 |
private List<string> getTable(IWebDriver driver) |
120 | 121 |
{ |
121 | 122 |
List<string> cont = new List<string>(); |
... | ... | |
128 | 129 |
return cont; |
129 | 130 |
} |
130 | 131 |
|
132 |
//easy login to run on start of the test |
|
131 | 133 |
private bool Login(IWebDriver driver) |
132 | 134 |
{ |
133 | 135 |
driver.Navigate().GoToUrl(url); |
Také k dispozici: Unified diff
Testing cleanup + readme
cleaning testing, adding new comments to user creation frontend, adding readme