Advertisement
ILyaCyclone

Untitled

Apr 24th, 2019
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.89 KB | None | 0 0
  1. package com.example.tests;
  2.  
  3. import java.util.regex.Pattern;
  4. import java.util.concurrent.TimeUnit;
  5. import org.junit.*;
  6. import static org.junit.Assert.*;
  7. import static org.hamcrest.CoreMatchers.*;
  8. import org.openqa.selenium.*;
  9. import org.openqa.selenium.firefox.FirefoxDriver;
  10. import org.openqa.selenium.support.ui.Select;
  11.  
  12. public class HttpDeasigndemoComRtuApplicantsNewHtml {
  13. private WebDriver driver;
  14. private String baseUrl;
  15. private boolean acceptNextAlert = true;
  16. private StringBuffer verificationErrors = new StringBuffer();
  17.  
  18. @Before
  19. public void setUp() throws Exception {
  20. driver = new FirefoxDriver();
  21. baseUrl = "https://www.katalon.com/";
  22. driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  23. }
  24.  
  25. @Test
  26. public void testHttpDeasigndemoComRtuApplicantsNewHtml() throws Exception {
  27. driver.get("http://deasigndemo.com/rtu/applicants_new.html?level=2&training=20773,20774&cities=2");
  28. driver.findElement(By.xpath("//div/div/div")).click();
  29. driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Как стать студентом МИИТ'])[1]/following::div[6]")).click();
  30. driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Как стать студентом МИИТ'])[1]/following::div[6]")).click();
  31. driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Магистратура'])[2]/following::span[1]")).click();
  32. new Select(driver.findElement(By.name("level"))).selectByVisibleText("Аспирантура (Аспирантура и докторантура)");
  33. driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Аспирантура (Аспирантура и докторантура)'])[3]/following::div[2]")).click();
  34. driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Очная, Вечерняя'])[1]/following::span[2]")).click();
  35. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=training | label=Очная]]
  36. // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=training | label=Вечерняя]]
  37. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=training | label=Заочная]]
  38. // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=training | label=Заочная]]
  39. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=training | label=Вечерняя]]
  40. // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=training | label=Вечерняя]]
  41. driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Очная'])[2]/following::span[2]")).click();
  42. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=training | label=Вечерняя]]
  43. driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Как стать студентом МИИТ'])[1]/following::div[1]")).click();
  44. driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Заочная'])[3]/following::div[2]")).click();
  45. driver.findElement(By.linkText("Брянск")).click();
  46. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Москва]]
  47. // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=cities | label=Белгород]]
  48. // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=cities | label=Брянск]]
  49. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Волгоград]]
  50. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Воронеж]]
  51. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Елец (Липецкая область)]]
  52. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Казань]]
  53. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Калининград]]
  54. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Калуга]]
  55. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Киров]]
  56. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Курск]]
  57. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Муром (Владимирская область)]]
  58. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Нижний новгород]]
  59. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Ожерелье (Московская область)]]
  60. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Орёл]]
  61. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Саратов]]
  62. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Рославль (Смоленская область)]]
  63. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Ртищево (Саратовская область)]]
  64. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Рязань]]
  65. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Смоленск]]
  66. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Тамбов]]
  67. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Узловая (Тульская обл.)]]
  68. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Ярославль]]
  69. // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Белгород]]
  70. // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=cities | label=Москва]]
  71. driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Как стать студентом МИИТ'])[1]/following::div[1]")).click();
  72. driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Ярославль'])[2]/following::input[1]")).click();
  73. // ERROR: Caught exception [ERROR: Unsupported command [doubleClick | xpath=(.//*[normalize-space(text()) and normalize-space(.)='Как стать студентом МИИТ'])[1]/following::p[1] | ]]
  74. assertTrue(driver.getCurrentUrl().matches("^http://deasigndemo\\.com/rtu/applicants_new\\.html[\\s\\S]level=4&training=20775&cities=1,3$"));
  75. }
  76.  
  77. @After
  78. public void tearDown() throws Exception {
  79. driver.quit();
  80. String verificationErrorString = verificationErrors.toString();
  81. if (!"".equals(verificationErrorString)) {
  82. fail(verificationErrorString);
  83. }
  84. }
  85.  
  86. private boolean isElementPresent(By by) {
  87. try {
  88. driver.findElement(by);
  89. return true;
  90. } catch (NoSuchElementException e) {
  91. return false;
  92. }
  93. }
  94.  
  95. private boolean isAlertPresent() {
  96. try {
  97. driver.switchTo().alert();
  98. return true;
  99. } catch (NoAlertPresentException e) {
  100. return false;
  101. }
  102. }
  103.  
  104. private String closeAlertAndGetItsText() {
  105. try {
  106. Alert alert = driver.switchTo().alert();
  107. String alertText = alert.getText();
  108. if (acceptNextAlert) {
  109. alert.accept();
  110. } else {
  111. alert.dismiss();
  112. }
  113. return alertText;
  114. } finally {
  115. acceptNextAlert = true;
  116. }
  117. }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement