| 1 | Тестовите се експортирани како C#/NUnit/Web Driver. |
| 2 | |
| 3 | '''Register.cs''' |
| 4 | {{{ |
| 5 | using System; |
| 6 | using System.Text; |
| 7 | using System.Text.RegularExpressions; |
| 8 | using System.Threading; |
| 9 | using NUnit.Framework; |
| 10 | using OpenQA.Selenium; |
| 11 | using OpenQA.Selenium.Firefox; |
| 12 | using OpenQA.Selenium.Support.UI; |
| 13 | |
| 14 | namespace SeleniumTests |
| 15 | { |
| 16 | [TestFixture] |
| 17 | public class Register |
| 18 | { |
| 19 | private IWebDriver driver; |
| 20 | private StringBuilder verificationErrors; |
| 21 | private string baseURL; |
| 22 | private bool acceptNextAlert = true; |
| 23 | |
| 24 | [SetUp] |
| 25 | public void SetupTest() |
| 26 | { |
| 27 | driver = new FirefoxDriver(); |
| 28 | baseURL = "http://localhost:1400/"; |
| 29 | verificationErrors = new StringBuilder(); |
| 30 | } |
| 31 | |
| 32 | [TearDown] |
| 33 | public void TeardownTest() |
| 34 | { |
| 35 | try |
| 36 | { |
| 37 | driver.Quit(); |
| 38 | } |
| 39 | catch (Exception) |
| 40 | { |
| 41 | // Ignore errors if unable to close the browser |
| 42 | } |
| 43 | Assert.AreEqual("", verificationErrors.ToString()); |
| 44 | } |
| 45 | |
| 46 | [Test] |
| 47 | public void TheRegisterTest() |
| 48 | { |
| 49 | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
| 50 | driver.FindElement(By.Id("ctl10_registerLink")).Click(); |
| 51 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
| 52 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("novstudent3"); |
| 53 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); |
| 54 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("novstudent1@mail.com"); |
| 55 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
| 56 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("novstudent"); |
| 57 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
| 58 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("novstudent"); |
| 59 | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
| 60 | driver.FindElement(By.Id("MainContent_txtImePrezime")).Clear(); |
| 61 | driver.FindElement(By.Id("MainContent_txtImePrezime")).SendKeys("Student Nov"); |
| 62 | driver.FindElement(By.Id("MainContent_txtMesto")).Clear(); |
| 63 | driver.FindElement(By.Id("MainContent_txtMesto")).SendKeys("New York"); |
| 64 | driver.FindElement(By.Id("MainContent_txtDatum")).Clear(); |
| 65 | driver.FindElement(By.Id("MainContent_txtDatum")).SendKeys("01-08-1990"); |
| 66 | driver.FindElement(By.Id("MainContent_txtObrazovanie")).Clear(); |
| 67 | driver.FindElement(By.Id("MainContent_txtObrazovanie")).SendKeys("BS"); |
| 68 | driver.FindElement(By.Id("MainContent_txtInstitucija")).Clear(); |
| 69 | driver.FindElement(By.Id("MainContent_txtInstitucija")).SendKeys("Proba"); |
| 70 | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).Clear(); |
| 71 | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).SendKeys("Proba"); |
| 72 | driver.FindElement(By.Id("MainContent_txtPozicija")).Clear(); |
| 73 | driver.FindElement(By.Id("MainContent_txtPozicija")).SendKeys("Proba"); |
| 74 | driver.FindElement(By.Id("MainContent_btnAdd")).Click(); |
| 75 | driver.FindElement(By.Id("MainContent_Button2")).Click(); |
| 76 | driver.FindElement(By.Id("MainContent_Button1")).Click(); |
| 77 | driver.FindElement(By.Id("MainContent_txtActivity")).Clear(); |
| 78 | driver.FindElement(By.Id("MainContent_txtActivity")).SendKeys("rrr"); |
| 79 | driver.FindElement(By.Id("MainContent_btnShow")).Click(); |
| 80 | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).Clear(); |
| 81 | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).SendKeys("uuu"); |
| 82 | driver.FindElement(By.Id("MainContent_gvMe_CheckBox1_0")).Click(); |
| 83 | driver.FindElement(By.Id("MainContent_btnAddMe")).Click(); |
| 84 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| 85 | } |
| 86 | private bool IsElementPresent(By by) |
| 87 | { |
| 88 | try |
| 89 | { |
| 90 | driver.FindElement(by); |
| 91 | return true; |
| 92 | } |
| 93 | catch (NoSuchElementException) |
| 94 | { |
| 95 | return false; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | private bool IsAlertPresent() |
| 100 | { |
| 101 | try |
| 102 | { |
| 103 | driver.SwitchTo().Alert(); |
| 104 | return true; |
| 105 | } |
| 106 | catch (NoAlertPresentException) |
| 107 | { |
| 108 | return false; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | private string CloseAlertAndGetItsText() { |
| 113 | try { |
| 114 | IAlert alert = driver.SwitchTo().Alert(); |
| 115 | string alertText = alert.Text; |
| 116 | if (acceptNextAlert) { |
| 117 | alert.Accept(); |
| 118 | } else { |
| 119 | alert.Dismiss(); |
| 120 | } |
| 121 | return alertText; |
| 122 | } finally { |
| 123 | acceptNextAlert = true; |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | }}} |
| 129 | |
| 130 | |
| 131 | '''LoginFieldValidation.cs''' |
| 132 | |
| 133 | {{{ |
| 134 | using System; |
| 135 | using System.Text; |
| 136 | using System.Text.RegularExpressions; |
| 137 | using System.Threading; |
| 138 | using NUnit.Framework; |
| 139 | using OpenQA.Selenium; |
| 140 | using OpenQA.Selenium.Firefox; |
| 141 | using OpenQA.Selenium.Support.UI; |
| 142 | |
| 143 | namespace SeleniumTests |
| 144 | { |
| 145 | [TestFixture] |
| 146 | public class LoginFieldValidation |
| 147 | { |
| 148 | private IWebDriver driver; |
| 149 | private StringBuilder verificationErrors; |
| 150 | private string baseURL; |
| 151 | private bool acceptNextAlert = true; |
| 152 | |
| 153 | [SetUp] |
| 154 | public void SetupTest() |
| 155 | { |
| 156 | driver = new FirefoxDriver(); |
| 157 | baseURL = "http://localhost:1400/"; |
| 158 | verificationErrors = new StringBuilder(); |
| 159 | } |
| 160 | |
| 161 | [TearDown] |
| 162 | public void TeardownTest() |
| 163 | { |
| 164 | try |
| 165 | { |
| 166 | driver.Quit(); |
| 167 | } |
| 168 | catch (Exception) |
| 169 | { |
| 170 | // Ignore errors if unable to close the browser |
| 171 | } |
| 172 | Assert.AreEqual("", verificationErrors.ToString()); |
| 173 | } |
| 174 | |
| 175 | [Test] |
| 176 | public void TheLoginFieldValidationTest() |
| 177 | { |
| 178 | driver.Navigate().GoToUrl(baseURL + "/"); |
| 179 | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
| 180 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| 181 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| 182 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| 183 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| 184 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("aaa"); |
| 185 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| 186 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| 187 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student12"); |
| 188 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| 189 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1233"); |
| 190 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| 191 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| 192 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| 193 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| 194 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); |
| 195 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| 196 | } |
| 197 | private bool IsElementPresent(By by) |
| 198 | { |
| 199 | try |
| 200 | { |
| 201 | driver.FindElement(by); |
| 202 | return true; |
| 203 | } |
| 204 | catch (NoSuchElementException) |
| 205 | { |
| 206 | return false; |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | private bool IsAlertPresent() |
| 211 | { |
| 212 | try |
| 213 | { |
| 214 | driver.SwitchTo().Alert(); |
| 215 | return true; |
| 216 | } |
| 217 | catch (NoAlertPresentException) |
| 218 | { |
| 219 | return false; |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | private string CloseAlertAndGetItsText() { |
| 224 | try { |
| 225 | IAlert alert = driver.SwitchTo().Alert(); |
| 226 | string alertText = alert.Text; |
| 227 | if (acceptNextAlert) { |
| 228 | alert.Accept(); |
| 229 | } else { |
| 230 | alert.Dismiss(); |
| 231 | } |
| 232 | return alertText; |
| 233 | } finally { |
| 234 | acceptNextAlert = true; |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | }}} |
| 240 | |
| 241 | '''Registerfieldvalidation.cs''' |
| 242 | {{{ |
| 243 | using System; |
| 244 | using System.Text; |
| 245 | using System.Text.RegularExpressions; |
| 246 | using System.Threading; |
| 247 | using NUnit.Framework; |
| 248 | using OpenQA.Selenium; |
| 249 | using OpenQA.Selenium.Firefox; |
| 250 | using OpenQA.Selenium.Support.UI; |
| 251 | |
| 252 | namespace SeleniumTests |
| 253 | { |
| 254 | [TestFixture] |
| 255 | public class RegisterFieldValidation |
| 256 | { |
| 257 | private IWebDriver driver; |
| 258 | private StringBuilder verificationErrors; |
| 259 | private string baseURL; |
| 260 | private bool acceptNextAlert = true; |
| 261 | |
| 262 | [SetUp] |
| 263 | public void SetupTest() |
| 264 | { |
| 265 | driver = new FirefoxDriver(); |
| 266 | baseURL = "http://localhost:1400/"; |
| 267 | verificationErrors = new StringBuilder(); |
| 268 | } |
| 269 | |
| 270 | [TearDown] |
| 271 | public void TeardownTest() |
| 272 | { |
| 273 | try |
| 274 | { |
| 275 | driver.Quit(); |
| 276 | } |
| 277 | catch (Exception) |
| 278 | { |
| 279 | // Ignore errors if unable to close the browser |
| 280 | } |
| 281 | Assert.AreEqual("", verificationErrors.ToString()); |
| 282 | } |
| 283 | |
| 284 | [Test] |
| 285 | public void TheRegisterFieldValidationTest() |
| 286 | { |
| 287 | driver.Navigate().GoToUrl(baseURL + "/"); |
| 288 | driver.FindElement(By.Id("ctl10_registerLink")).Click(); |
| 289 | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
| 290 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
| 291 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abc"); |
| 292 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); |
| 293 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("abc@mail.com"); |
| 294 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
| 295 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("abcabc1"); |
| 296 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
| 297 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abcabc1"); |
| 298 | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
| 299 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
| 300 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abcde"); |
| 301 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
| 302 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("abcdefg1"); |
| 303 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
| 304 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abvv"); |
| 305 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
| 306 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abcdefg1"); |
| 307 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
| 308 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abcdefg"); |
| 309 | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
| 310 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| 311 | } |
| 312 | private bool IsElementPresent(By by) |
| 313 | { |
| 314 | try |
| 315 | { |
| 316 | driver.FindElement(by); |
| 317 | return true; |
| 318 | } |
| 319 | catch (NoSuchElementException) |
| 320 | { |
| 321 | return false; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | private bool IsAlertPresent() |
| 326 | { |
| 327 | try |
| 328 | { |
| 329 | driver.SwitchTo().Alert(); |
| 330 | return true; |
| 331 | } |
| 332 | catch (NoAlertPresentException) |
| 333 | { |
| 334 | return false; |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | private string CloseAlertAndGetItsText() { |
| 339 | try { |
| 340 | IAlert alert = driver.SwitchTo().Alert(); |
| 341 | string alertText = alert.Text; |
| 342 | if (acceptNextAlert) { |
| 343 | alert.Accept(); |
| 344 | } else { |
| 345 | alert.Dismiss(); |
| 346 | } |
| 347 | return alertText; |
| 348 | } finally { |
| 349 | acceptNextAlert = true; |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | }}} |
| 355 | |
| 356 | '''Search.cs''' |
| 357 | {{{ |
| 358 | using System; |
| 359 | using System.Text; |
| 360 | using System.Text.RegularExpressions; |
| 361 | using System.Threading; |
| 362 | using NUnit.Framework; |
| 363 | using OpenQA.Selenium; |
| 364 | using OpenQA.Selenium.Firefox; |
| 365 | using OpenQA.Selenium.Support.UI; |
| 366 | |
| 367 | namespace SeleniumTests |
| 368 | { |
| 369 | [TestFixture] |
| 370 | public class Search |
| 371 | { |
| 372 | private IWebDriver driver; |
| 373 | private StringBuilder verificationErrors; |
| 374 | private string baseURL; |
| 375 | private bool acceptNextAlert = true; |
| 376 | |
| 377 | [SetUp] |
| 378 | public void SetupTest() |
| 379 | { |
| 380 | driver = new FirefoxDriver(); |
| 381 | baseURL = "http://localhost:1400/"; |
| 382 | verificationErrors = new StringBuilder(); |
| 383 | } |
| 384 | |
| 385 | [TearDown] |
| 386 | public void TeardownTest() |
| 387 | { |
| 388 | try |
| 389 | { |
| 390 | driver.Quit(); |
| 391 | } |
| 392 | catch (Exception) |
| 393 | { |
| 394 | // Ignore errors if unable to close the browser |
| 395 | } |
| 396 | Assert.AreEqual("", verificationErrors.ToString()); |
| 397 | } |
| 398 | |
| 399 | [Test] |
| 400 | public void TheSearchTest() |
| 401 | { |
| 402 | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
| 403 | driver.FindElement(By.LinkText("Контакт")).Click(); |
| 404 | driver.FindElement(By.Id("txtSearch")).Clear(); |
| 405 | driver.FindElement(By.Id("txtSearch")).SendKeys("IS"); |
| 406 | driver.FindElement(By.Id("btnSearch")).Click(); |
| 407 | driver.FindElement(By.LinkText("Почетна")).Click(); |
| 408 | driver.FindElement(By.Id("txtSearch")).Clear(); |
| 409 | driver.FindElement(By.Id("txtSearch")).SendKeys("IS"); |
| 410 | driver.FindElement(By.Id("btnSearch")).Click(); |
| 411 | } |
| 412 | private bool IsElementPresent(By by) |
| 413 | { |
| 414 | try |
| 415 | { |
| 416 | driver.FindElement(by); |
| 417 | return true; |
| 418 | } |
| 419 | catch (NoSuchElementException) |
| 420 | { |
| 421 | return false; |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | private bool IsAlertPresent() |
| 426 | { |
| 427 | try |
| 428 | { |
| 429 | driver.SwitchTo().Alert(); |
| 430 | return true; |
| 431 | } |
| 432 | catch (NoAlertPresentException) |
| 433 | { |
| 434 | return false; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | private string CloseAlertAndGetItsText() { |
| 439 | try { |
| 440 | IAlert alert = driver.SwitchTo().Alert(); |
| 441 | string alertText = alert.Text; |
| 442 | if (acceptNextAlert) { |
| 443 | alert.Accept(); |
| 444 | } else { |
| 445 | alert.Dismiss(); |
| 446 | } |
| 447 | return alertText; |
| 448 | } finally { |
| 449 | acceptNextAlert = true; |
| 450 | } |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | }}} |
| 455 | |
| 456 | '''Changepassword.cs''' |
| 457 | {{{ |
| 458 | using System; |
| 459 | using System.Text; |
| 460 | using System.Text.RegularExpressions; |
| 461 | using System.Threading; |
| 462 | using NUnit.Framework; |
| 463 | using OpenQA.Selenium; |
| 464 | using OpenQA.Selenium.Firefox; |
| 465 | using OpenQA.Selenium.Support.UI; |
| 466 | |
| 467 | namespace SeleniumTests |
| 468 | { |
| 469 | [TestFixture] |
| 470 | public class ChangePassword |
| 471 | { |
| 472 | private IWebDriver driver; |
| 473 | private StringBuilder verificationErrors; |
| 474 | private string baseURL; |
| 475 | private bool acceptNextAlert = true; |
| 476 | |
| 477 | [SetUp] |
| 478 | public void SetupTest() |
| 479 | { |
| 480 | driver = new FirefoxDriver(); |
| 481 | baseURL = "http://localhost:1400/"; |
| 482 | verificationErrors = new StringBuilder(); |
| 483 | } |
| 484 | |
| 485 | [TearDown] |
| 486 | public void TeardownTest() |
| 487 | { |
| 488 | try |
| 489 | { |
| 490 | driver.Quit(); |
| 491 | } |
| 492 | catch (Exception) |
| 493 | { |
| 494 | // Ignore errors if unable to close the browser |
| 495 | } |
| 496 | Assert.AreEqual("", verificationErrors.ToString()); |
| 497 | } |
| 498 | |
| 499 | [Test] |
| 500 | public void TheChangePasswordTest() |
| 501 | { |
| 502 | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
| 503 | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
| 504 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| 505 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| 506 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| 507 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); |
| 508 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| 509 | driver.FindElement(By.Id("ctl10_hpLink")).Click(); |
| 510 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_CurrentPassword")).Clear(); |
| 511 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_CurrentPassword")).SendKeys("student123"); |
| 512 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_NewPassword")).Clear(); |
| 513 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_NewPassword")).SendKeys("student1234"); |
| 514 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_ConfirmNewPassword")).Clear(); |
| 515 | driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_ConfirmNewPassword")).SendKeys("student1234"); |
| 516 | driver.FindElement(By.Name("ctl00$MainContent$ctl07$ChangePasswordContainerID$ctl04")).Click(); |
| 517 | driver.FindElement(By.LinkText("Одјави се")).Click(); |
| 518 | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
| 519 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| 520 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| 521 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| 522 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1234"); |
| 523 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| 524 | driver.FindElement(By.LinkText("Одјави се")).Click(); |
| 525 | } |
| 526 | private bool IsElementPresent(By by) |
| 527 | { |
| 528 | try |
| 529 | { |
| 530 | driver.FindElement(by); |
| 531 | return true; |
| 532 | } |
| 533 | catch (NoSuchElementException) |
| 534 | { |
| 535 | return false; |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | private bool IsAlertPresent() |
| 540 | { |
| 541 | try |
| 542 | { |
| 543 | driver.SwitchTo().Alert(); |
| 544 | return true; |
| 545 | } |
| 546 | catch (NoAlertPresentException) |
| 547 | { |
| 548 | return false; |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | private string CloseAlertAndGetItsText() { |
| 553 | try { |
| 554 | IAlert alert = driver.SwitchTo().Alert(); |
| 555 | string alertText = alert.Text; |
| 556 | if (acceptNextAlert) { |
| 557 | alert.Accept(); |
| 558 | } else { |
| 559 | alert.Dismiss(); |
| 560 | } |
| 561 | return alertText; |
| 562 | } finally { |
| 563 | acceptNextAlert = true; |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | } |
| 568 | }}} |
| 569 | |
| 570 | '''Addinfo.cs''' |
| 571 | {{{ |
| 572 | using System; |
| 573 | using System.Text; |
| 574 | using System.Text.RegularExpressions; |
| 575 | using System.Threading; |
| 576 | using NUnit.Framework; |
| 577 | using OpenQA.Selenium; |
| 578 | using OpenQA.Selenium.Firefox; |
| 579 | using OpenQA.Selenium.Support.UI; |
| 580 | |
| 581 | namespace SeleniumTests |
| 582 | { |
| 583 | [TestFixture] |
| 584 | public class AddInfoLater |
| 585 | { |
| 586 | private IWebDriver driver; |
| 587 | private StringBuilder verificationErrors; |
| 588 | private string baseURL; |
| 589 | private bool acceptNextAlert = true; |
| 590 | |
| 591 | [SetUp] |
| 592 | public void SetupTest() |
| 593 | { |
| 594 | driver = new FirefoxDriver(); |
| 595 | baseURL = "http://localhost:1400/"; |
| 596 | verificationErrors = new StringBuilder(); |
| 597 | } |
| 598 | |
| 599 | [TearDown] |
| 600 | public void TeardownTest() |
| 601 | { |
| 602 | try |
| 603 | { |
| 604 | driver.Quit(); |
| 605 | } |
| 606 | catch (Exception) |
| 607 | { |
| 608 | // Ignore errors if unable to close the browser |
| 609 | } |
| 610 | Assert.AreEqual("", verificationErrors.ToString()); |
| 611 | } |
| 612 | |
| 613 | [Test] |
| 614 | public void TheAddInfoLaterTest() |
| 615 | { |
| 616 | driver.Navigate().GoToUrl(baseURL + "/"); |
| 617 | driver.FindElement(By.Id("ctl10_registerLink")).Click(); |
| 618 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); |
| 619 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("mojasmetka1"); |
| 620 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); |
| 621 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("adresa@mail.com"); |
| 622 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); |
| 623 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("mojasmetka1"); |
| 624 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); |
| 625 | driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("mojasmetka1"); |
| 626 | driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); |
| 627 | driver.FindElement(By.Id("MainContent_Button2")).Click(); |
| 628 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| 629 | driver.FindElement(By.CssSelector("span.username")).Click(); |
| 630 | driver.FindElement(By.Id("MainContent_txtImePrezime")).Clear(); |
| 631 | driver.FindElement(By.Id("MainContent_txtImePrezime")).SendKeys("moja"); |
| 632 | driver.FindElement(By.Id("MainContent_rblPol_1")).Click(); |
| 633 | driver.FindElement(By.Id("MainContent_txtMesto")).Clear(); |
| 634 | driver.FindElement(By.Id("MainContent_txtMesto")).SendKeys("ww"); |
| 635 | driver.FindElement(By.Id("MainContent_txtDatum")).Clear(); |
| 636 | driver.FindElement(By.Id("MainContent_txtDatum")).SendKeys("16.06.1989"); |
| 637 | driver.FindElement(By.Id("MainContent_txtObrazovanie")).Clear(); |
| 638 | driver.FindElement(By.Id("MainContent_txtObrazovanie")).SendKeys("ww"); |
| 639 | driver.FindElement(By.Id("MainContent_txtInstitucija")).Clear(); |
| 640 | driver.FindElement(By.Id("MainContent_txtInstitucija")).SendKeys("ww"); |
| 641 | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).Clear(); |
| 642 | driver.FindElement(By.Id("MainContent_txtVrabotenVo")).SendKeys("ww"); |
| 643 | driver.FindElement(By.Id("MainContent_txtPozicija")).Clear(); |
| 644 | driver.FindElement(By.Id("MainContent_txtPozicija")).SendKeys("ww"); |
| 645 | driver.FindElement(By.Id("MainContent_btnAdd")).Click(); |
| 646 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| 647 | } |
| 648 | private bool IsElementPresent(By by) |
| 649 | { |
| 650 | try |
| 651 | { |
| 652 | driver.FindElement(by); |
| 653 | return true; |
| 654 | } |
| 655 | catch (NoSuchElementException) |
| 656 | { |
| 657 | return false; |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | private bool IsAlertPresent() |
| 662 | { |
| 663 | try |
| 664 | { |
| 665 | driver.SwitchTo().Alert(); |
| 666 | return true; |
| 667 | } |
| 668 | catch (NoAlertPresentException) |
| 669 | { |
| 670 | return false; |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | private string CloseAlertAndGetItsText() { |
| 675 | try { |
| 676 | IAlert alert = driver.SwitchTo().Alert(); |
| 677 | string alertText = alert.Text; |
| 678 | if (acceptNextAlert) { |
| 679 | alert.Accept(); |
| 680 | } else { |
| 681 | alert.Dismiss(); |
| 682 | } |
| 683 | return alertText; |
| 684 | } finally { |
| 685 | acceptNextAlert = true; |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | }}} |
| 692 | |
| 693 | '''Addnewactivity.cs''' |
| 694 | {{{ |
| 695 | using System; |
| 696 | using System.Text; |
| 697 | using System.Text.RegularExpressions; |
| 698 | using System.Threading; |
| 699 | using NUnit.Framework; |
| 700 | using OpenQA.Selenium; |
| 701 | using OpenQA.Selenium.Firefox; |
| 702 | using OpenQA.Selenium.Support.UI; |
| 703 | |
| 704 | namespace SeleniumTests |
| 705 | { |
| 706 | [TestFixture] |
| 707 | public class AddNewActivity |
| 708 | { |
| 709 | private IWebDriver driver; |
| 710 | private StringBuilder verificationErrors; |
| 711 | private string baseURL; |
| 712 | private bool acceptNextAlert = true; |
| 713 | |
| 714 | [SetUp] |
| 715 | public void SetupTest() |
| 716 | { |
| 717 | driver = new FirefoxDriver(); |
| 718 | baseURL = "http://localhost:1400/"; |
| 719 | verificationErrors = new StringBuilder(); |
| 720 | } |
| 721 | |
| 722 | [TearDown] |
| 723 | public void TeardownTest() |
| 724 | { |
| 725 | try |
| 726 | { |
| 727 | driver.Quit(); |
| 728 | } |
| 729 | catch (Exception) |
| 730 | { |
| 731 | // Ignore errors if unable to close the browser |
| 732 | } |
| 733 | Assert.AreEqual("", verificationErrors.ToString()); |
| 734 | } |
| 735 | |
| 736 | [Test] |
| 737 | public void TheAddNewActivityTest() |
| 738 | { |
| 739 | driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); |
| 740 | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
| 741 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| 742 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| 743 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| 744 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1234"); |
| 745 | driver.FindElement(By.Id("MainContent_ctl00_RememberMe")).Click(); |
| 746 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| 747 | driver.FindElement(By.Id("MainContent_Button1")).Click(); |
| 748 | driver.FindElement(By.Id("MainContent_txtName")).Clear(); |
| 749 | driver.FindElement(By.Id("MainContent_txtName")).SendKeys("nestonovo"); |
| 750 | driver.FindElement(By.Id("MainContent_txtCategory")).Clear(); |
| 751 | driver.FindElement(By.Id("MainContent_txtCategory")).SendKeys("/"); |
| 752 | driver.FindElement(By.Id("MainContent_txtPlace")).Clear(); |
| 753 | driver.FindElement(By.Id("MainContent_txtPlace")).SendKeys("Proba"); |
| 754 | driver.FindElement(By.Id("MainContent_txtDate")).Clear(); |
| 755 | driver.FindElement(By.Id("MainContent_txtDate")).SendKeys("11.11.2013"); |
| 756 | driver.FindElement(By.Id("MainContent_txtRole")).Clear(); |
| 757 | driver.FindElement(By.Id("MainContent_txtRole")).SendKeys("/"); |
| 758 | driver.FindElement(By.Id("MainContent_btnInsert")).Click(); |
| 759 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| 760 | driver.FindElement(By.LinkText("Одјави се")).Click(); |
| 761 | } |
| 762 | private bool IsElementPresent(By by) |
| 763 | { |
| 764 | try |
| 765 | { |
| 766 | driver.FindElement(by); |
| 767 | return true; |
| 768 | } |
| 769 | catch (NoSuchElementException) |
| 770 | { |
| 771 | return false; |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | private bool IsAlertPresent() |
| 776 | { |
| 777 | try |
| 778 | { |
| 779 | driver.SwitchTo().Alert(); |
| 780 | return true; |
| 781 | } |
| 782 | catch (NoAlertPresentException) |
| 783 | { |
| 784 | return false; |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | private string CloseAlertAndGetItsText() { |
| 789 | try { |
| 790 | IAlert alert = driver.SwitchTo().Alert(); |
| 791 | string alertText = alert.Text; |
| 792 | if (acceptNextAlert) { |
| 793 | alert.Accept(); |
| 794 | } else { |
| 795 | alert.Dismiss(); |
| 796 | } |
| 797 | return alertText; |
| 798 | } finally { |
| 799 | acceptNextAlert = true; |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | } |
| 804 | }}} |
| 805 | |
| 806 | '''Addusertoexistingactivity.cs''' |
| 807 | {{{ |
| 808 | using System; |
| 809 | using System.Text; |
| 810 | using System.Text.RegularExpressions; |
| 811 | using System.Threading; |
| 812 | using NUnit.Framework; |
| 813 | using OpenQA.Selenium; |
| 814 | using OpenQA.Selenium.Firefox; |
| 815 | using OpenQA.Selenium.Support.UI; |
| 816 | |
| 817 | namespace SeleniumTests |
| 818 | { |
| 819 | [TestFixture] |
| 820 | public class AddUserToExistingActivity |
| 821 | { |
| 822 | private IWebDriver driver; |
| 823 | private StringBuilder verificationErrors; |
| 824 | private string baseURL; |
| 825 | private bool acceptNextAlert = true; |
| 826 | |
| 827 | [SetUp] |
| 828 | public void SetupTest() |
| 829 | { |
| 830 | driver = new FirefoxDriver(); |
| 831 | baseURL = "http://localhost:1400/"; |
| 832 | verificationErrors = new StringBuilder(); |
| 833 | } |
| 834 | |
| 835 | [TearDown] |
| 836 | public void TeardownTest() |
| 837 | { |
| 838 | try |
| 839 | { |
| 840 | driver.Quit(); |
| 841 | } |
| 842 | catch (Exception) |
| 843 | { |
| 844 | // Ignore errors if unable to close the browser |
| 845 | } |
| 846 | Assert.AreEqual("", verificationErrors.ToString()); |
| 847 | } |
| 848 | |
| 849 | [Test] |
| 850 | public void TheAddUserToExistingActivityTest() |
| 851 | { |
| 852 | driver.Navigate().GoToUrl(baseURL + "/"); |
| 853 | driver.FindElement(By.Id("ctl10_loginLink")).Click(); |
| 854 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); |
| 855 | driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); |
| 856 | driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); |
| 857 | driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); |
| 858 | driver.FindElement(By.Id("MainContent_ctl00_RememberMe")).Click(); |
| 859 | driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); |
| 860 | driver.FindElement(By.Id("MainContent_Button1")).Click(); |
| 861 | driver.FindElement(By.Id("MainContent_txtActivity")).Clear(); |
| 862 | driver.FindElement(By.Id("MainContent_txtActivity")).SendKeys("nnnn"); |
| 863 | driver.FindElement(By.Id("MainContent_btnShow")).Click(); |
| 864 | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).Clear(); |
| 865 | driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).SendKeys("mmm"); |
| 866 | driver.FindElement(By.Id("MainContent_gvMe_CheckBox1_0")).Click(); |
| 867 | driver.FindElement(By.Id("MainContent_btnAddMe")).Click(); |
| 868 | driver.FindElement(By.LinkText("Мојата Биографија")).Click(); |
| 869 | driver.FindElement(By.LinkText("2")).Click(); |
| 870 | } |
| 871 | private bool IsElementPresent(By by) |
| 872 | { |
| 873 | try |
| 874 | { |
| 875 | driver.FindElement(by); |
| 876 | return true; |
| 877 | } |
| 878 | catch (NoSuchElementException) |
| 879 | { |
| 880 | return false; |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | private bool IsAlertPresent() |
| 885 | { |
| 886 | try |
| 887 | { |
| 888 | driver.SwitchTo().Alert(); |
| 889 | return true; |
| 890 | } |
| 891 | catch (NoAlertPresentException) |
| 892 | { |
| 893 | return false; |
| 894 | } |
| 895 | } |
| 896 | |
| 897 | private string CloseAlertAndGetItsText() { |
| 898 | try { |
| 899 | IAlert alert = driver.SwitchTo().Alert(); |
| 900 | string alertText = alert.Text; |
| 901 | if (acceptNextAlert) { |
| 902 | alert.Accept(); |
| 903 | } else { |
| 904 | alert.Dismiss(); |
| 905 | } |
| 906 | return alertText; |
| 907 | } finally { |
| 908 | acceptNextAlert = true; |
| 909 | } |
| 910 | } |
| 911 | } |
| 912 | } |
| 913 | }}} |