Adik28

Testy automatyzujące

Feb 17th, 2021 (edited)
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.58 KB | None | 0 0
  1. package test;
  2. import org.openqa.selenium.*;
  3. import org.openqa.selenium.By.ById;
  4. import org.openqa.selenium.chrome.*;
  5. import org.openqa.selenium.support.ui.Select;
  6.  
  7. import com.thoughtworks.selenium.webdriven.commands.IsSomethingSelected;
  8.  
  9. import static org.junit.Assert.assertTrue;
  10.  
  11. import org.junit.Assert;
  12. import org.junit.Test;
  13.  
  14.  
  15. public class GoogleSearchTest {
  16.    
  17.     /**
  18.      * @param Args
  19.      * @throws InterruptedException
  20.      */
  21.     public static void main(String Args[]) throws InterruptedException {
  22.  
  23.             String title;
  24.             String projectPath = System.getProperty("user.dir");
  25.             System.out.println(projectPath);
  26.        
  27.             System.setProperty("webdriver.chrome.driver", "E://Programy//Eclipse//chromedriver_win32/chromedriver.exe");
  28.  
  29.             WebDriver driver = new ChromeDriver();
  30.    
  31.    
  32.             /*
  33.             driver.get("https://www.trojmiasto.pl/");
  34.             WebElement szukaj = driver.findElement(By.xpath("/html/body/div[2]/div[1]/section[2]/div[1]/div[2]/form/input[2]"));
  35.             szukaj.sendKeys("nieruchomości");
  36.             Thread.sleep(5000);
  37.             szukaj.submit();
  38.             */
  39.             //driver.get("http://localhost:1234/#/reports/config/addConfig");
  40.            
  41.            
  42.             /*
  43.             driver.get("http://the-internet.herokuapp.com/checkboxes");
  44.             WebElement szukaj = driver.findElement(By.xpath("/html/body/div[2]/div/div/form/input[1]"));
  45.             Thread.sleep(5000);
  46.            
  47.             if (szukaj.isSelected())
  48.             {
  49.                 szukaj.click();
  50.             }
  51.             */
  52.            
  53.             /*
  54.            
  55.             driver.get("http://the-internet.herokuapp.com/dropdown");
  56.             Select s = new Select(driver.findElement(By.id("dropdown")));
  57.             s.selectByValue("2");
  58.            
  59.          
  60.             driver.get("http://the-internet.herokuapp.com/add_remove_elements/");
  61.             WebElement szukaj = driver.findElement(By.xpath(" /html/body/div[2]/div/div/button"));
  62.             Thread.sleep(3000);
  63.             szukaj.click();
  64.            
  65.            
  66.             WebElement szukaj2 = driver.findElement(By.xpath("/html/body/div[2]/div/div/div/button\r\n"+ "          "));
  67.             Thread.sleep(5000);
  68.             szukaj2.click();
  69.            
  70.             Thread.sleep(5000);
  71.            
  72.             assertTrue(driver.findElement(By.xpath(" /html/body/div[2]/div/div/button")).isDisplayed());
  73.  
  74.            
  75.             driver.get("http://the-internet.herokuapp.com/");
  76.            
  77.             //Assert.assertEquals(driver.findElement(By.xpath("/html/body/div[2]/div/h1")).getText(), "Welcome to the-internet asas");
  78.            
  79.               */
  80.    
  81.            
  82.             driver.get("http://localhost:1234/#/reports");
  83.             driver.manage().window().maximize();
  84.             WebElement nazwaSerwera = driver.findElement(By.xpath("/html/body/div[1]/div/section/section/div/div/div[3]/div/a/div[2]/div[2]/div"));
  85.             Thread.sleep(2000);
  86.             nazwaSerwera.click();
  87.             Thread.sleep(2000);
  88.          
  89.             WebElement nazwaSerwera1 = driver.findElement(By.xpath("/html/body/div/div/section/div/div/div/div[1]/div/div/div[1]/a"));
  90.          
  91.          
  92.             nazwaSerwera1.click();
  93.             Thread.sleep(2000);
  94.            
  95.             WebElement nazwaSerwera2 = driver.findElement(By.xpath(" /html/body/div/div/header/div/header[2]/div/div[2]/a/button/span"));
  96.              
  97.              
  98.             nazwaSerwera2.click();
  99.             Thread.sleep(2000);
  100.            
  101.             driver.navigate().refresh();
  102.             Thread.sleep(2000);
  103.            
  104.             //nazwa serwera
  105.             driver.findElement(By.xpath("/html/body/div[1]/div/section/div[2]/div/form/div/div[1]/div[3]/div/div/div/div[1]/div/input")).sendKeys("L1WW291/SQLEXPRESS03");
  106.             Thread.sleep(2000);
  107.            
  108.             //nazwa bazy danych
  109.             driver.findElement(By.xpath("/html/body/div/div/section/div[2]/div/form/div/div[1]/div[4]/div/div/div/div[1]/div/input")).sendKeys("wcyw1t");
  110.             Thread.sleep(2000);
  111.            
  112.             //login
  113.             driver.findElement(By.xpath("/html/body/div[1]/div/section/div[2]/div/form/div/div[1]/div[5]/div/div/div/div[1]/div/input")).sendKeys("stamina");
  114.             Thread.sleep(1000);
  115.            
  116.            
  117.             //hasło
  118.             driver.findElement(By.xpath("/html/body/div[1]/div/section/div[2]/div/form/div/div[1]/div[6]/div/div/div/div[1]/div[1]/input")).sendKeys("stamina");
  119.             Thread.sleep(1000);
  120.            
  121.             //wciśnięcie przysicku Test połączenia
  122.             WebElement przyciskTestPolaczenia = driver.findElement(By.xpath("/html/body/div[1]/div/section/div[2]/div/form/div/div[2]/div/div/button[1]/span[1]"));
  123.             Thread.sleep(1000);
  124.             przyciskTestPolaczenia.click();
  125.          
  126.             //sprawdzenie, czy na przycisku jest napis "Test połączenia"
  127.             //Assert.assertEquals(driver.findElement(By.xpath("/html/body/div[1]/div/section/div[2]/div/form/div/div[2]/div/div/button[1]/span[1]")).getText(), "Test połączeń");
  128.            
  129.            
  130.            
  131.            
  132. }}
Add Comment
Please, Sign In to add comment