Advertisement
Raizekas

Untitled

Apr 7th, 2021
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.86 KB | None | 0 0
  1. import org.openqa.selenium.By;
  2. import org.openqa.selenium.WebDriver;
  3. import org.openqa.selenium.WebElement;
  4. import org.openqa.selenium.chrome.ChromeDriver;
  5.  
  6. import java.util.Arrays;
  7. import java.util.List;
  8.  
  9. public class ProgramaArturo {
  10.     public static void main(String[] args) {
  11.         System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
  12.         WebDriver driver = new ChromeDriver();
  13.  
  14.         final String ivestasLogin = "blabla";
  15.         final String fillerLogin = "The username: ";
  16.         final String expectedIsvestasLogin = fillerLogin + ivestasLogin;
  17.  
  18.         final String ivestasPsw = "bebebe";
  19.         final String fillerPsw = "The password: ";
  20.         final String expectedIsvestasPsw = fillerPsw + ivestasPsw;
  21.  
  22.  
  23.         String bazineNuoroda = "http://thedemosite.co.uk/";
  24.         driver.get(bazineNuoroda);
  25.  
  26.         driver.findElement(By.linkText("3. Add a User")).click();
  27.  
  28.         WebElement idTextField = driver.findElement(By.name("username"));
  29.         WebElement pswTextField = driver.findElement(By.name("password"));
  30.  
  31.         idTextField.sendKeys(ivestasLogin);
  32.         pswTextField.sendKeys(ivestasPsw);
  33.  
  34.         driver.findElement(By.cssSelector("tr:nth-child(3) input")).click();
  35.  
  36.         WebElement userCredentials = driver.findElement(By.cssSelector("blockquote:nth-child(2) > blockquote"));
  37.  
  38.         String tempIsvestiInicialai = userCredentials.getText();
  39.  
  40.         String[] tempDuIsvestiInicialai = tempIsvestiInicialai.split("\n");
  41.  
  42.         // GALIMA JAU DARYTI VEIKSMUS IŠSYK TOLIAU IR SU MASYVU
  43.         // ARBA GALIMA DAR TĄ MASYVĄ IRGI PASIKEISTI Į LIST, JOG BŪTŲ PATOGIAU
  44.  
  45.         List<String> isvestiInicialai = Arrays.asList(tempDuIsvestiInicialai);
  46.  
  47.         System.out.println(isvestiInicialai.toString());
  48.  
  49.  
  50.         // Logino tikrinimas
  51.         if (isvestiInicialai.get(0).equals(expectedIsvestasLogin)){
  52.             System.out.println("true");
  53.             System.out.println(isvestiInicialai.get(0));
  54.             System.out.println(expectedIsvestasLogin);
  55.             System.out.println("-------------");
  56.         }
  57.         else {
  58.             System.out.println("false");
  59.             System.out.println(isvestiInicialai.get(0));
  60.             System.out.println(expectedIsvestasLogin);
  61.             System.out.println("-------------");
  62.         }
  63.  
  64.         // Password tikrinimas
  65.         if (isvestiInicialai.get(1).equals(expectedIsvestasPsw)){
  66.             System.out.println("true");
  67.             System.out.println(isvestiInicialai.get(1));
  68.             System.out.println(expectedIsvestasLogin);
  69.             System.out.println("-------------");
  70.         }
  71.         else {
  72.             System.out.println("false");
  73.             System.out.println(isvestiInicialai.get(1));
  74.             System.out.println(expectedIsvestasLogin);
  75.             System.out.println("-------------");
  76.         }
  77.     }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement