Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.tests;
- import java.util.regex.Pattern;
- import java.util.concurrent.TimeUnit;
- import org.junit.*;
- import static org.junit.Assert.*;
- import static org.hamcrest.CoreMatchers.*;
- import org.openqa.selenium.*;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.openqa.selenium.support.ui.Select;
- public class HttpDeasigndemoComRtuApplicantsNewHtml {
- private WebDriver driver;
- private String baseUrl;
- private boolean acceptNextAlert = true;
- private StringBuffer verificationErrors = new StringBuffer();
- @Before
- public void setUp() throws Exception {
- driver = new FirefoxDriver();
- baseUrl = "https://www.katalon.com/";
- driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
- }
- @Test
- public void testHttpDeasigndemoComRtuApplicantsNewHtml() throws Exception {
- driver.get("http://deasigndemo.com/rtu/applicants_new.html?level=2&training=20773,20774&cities=2");
- driver.findElement(By.xpath("//div/div/div")).click();
- driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Как стать студентом МИИТ'])[1]/following::div[6]")).click();
- driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Как стать студентом МИИТ'])[1]/following::div[6]")).click();
- driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Магистратура'])[2]/following::span[1]")).click();
- new Select(driver.findElement(By.name("level"))).selectByVisibleText("Аспирантура (Аспирантура и докторантура)");
- driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Аспирантура (Аспирантура и докторантура)'])[3]/following::div[2]")).click();
- driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Очная, Вечерняя'])[1]/following::span[2]")).click();
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=training | label=Очная]]
- // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=training | label=Вечерняя]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=training | label=Заочная]]
- // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=training | label=Заочная]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=training | label=Вечерняя]]
- // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=training | label=Вечерняя]]
- driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Очная'])[2]/following::span[2]")).click();
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=training | label=Вечерняя]]
- driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Как стать студентом МИИТ'])[1]/following::div[1]")).click();
- driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Заочная'])[3]/following::div[2]")).click();
- driver.findElement(By.linkText("Брянск")).click();
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Москва]]
- // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=cities | label=Белгород]]
- // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=cities | label=Брянск]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Волгоград]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Воронеж]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Елец (Липецкая область)]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Казань]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Калининград]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Калуга]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Киров]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Курск]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Муром (Владимирская область)]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Нижний новгород]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Ожерелье (Московская область)]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Орёл]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Саратов]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Рославль (Смоленская область)]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Ртищево (Саратовская область)]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Рязань]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Смоленск]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Тамбов]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Узловая (Тульская обл.)]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Ярославль]]
- // ERROR: Caught exception [ERROR: Unsupported command [removeSelection | name=cities | label=Белгород]]
- // ERROR: Caught exception [ERROR: Unsupported command [addSelection | name=cities | label=Москва]]
- driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Как стать студентом МИИТ'])[1]/following::div[1]")).click();
- driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Ярославль'])[2]/following::input[1]")).click();
- // ERROR: Caught exception [ERROR: Unsupported command [doubleClick | xpath=(.//*[normalize-space(text()) and normalize-space(.)='Как стать студентом МИИТ'])[1]/following::p[1] | ]]
- assertTrue(driver.getCurrentUrl().matches("^http://deasigndemo\\.com/rtu/applicants_new\\.html[\\s\\S]level=4&training=20775&cities=1,3$"));
- }
- @After
- public void tearDown() throws Exception {
- driver.quit();
- String verificationErrorString = verificationErrors.toString();
- if (!"".equals(verificationErrorString)) {
- fail(verificationErrorString);
- }
- }
- private boolean isElementPresent(By by) {
- try {
- driver.findElement(by);
- return true;
- } catch (NoSuchElementException e) {
- return false;
- }
- }
- private boolean isAlertPresent() {
- try {
- driver.switchTo().alert();
- return true;
- } catch (NoAlertPresentException e) {
- return false;
- }
- }
- private String closeAlertAndGetItsText() {
- try {
- Alert alert = driver.switchTo().alert();
- String alertText = alert.getText();
- if (acceptNextAlert) {
- alert.accept();
- } else {
- alert.dismiss();
- }
- return alertText;
- } finally {
- acceptNextAlert = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement