Advertisement
Raizekas

Untitled

Apr 7th, 2021
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.49 KB | None | 0 0
  1. import org.openqa.selenium.By;
  2. import org.openqa.selenium.Dimension;
  3. import org.openqa.selenium.WebDriver;
  4. import org.openqa.selenium.WebElement;
  5. import org.openqa.selenium.chrome.ChromeDriver;
  6.  
  7. import java.util.ArrayList;
  8. import java.util.Map;
  9.  
  10. public class Programa
  11. {
  12.     public static void main(String[] args) //throws InterruptedException
  13.     {
  14.         System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
  15.         WebDriver driver = new ChromeDriver();
  16.  
  17.         String bazineNuoroda = "http://demo.guru99.com/test/newtours/";
  18.         driver.get(bazineNuoroda);
  19.  
  20.        // WebElement meniuMygtukasBankProject = driver.findElement(By.linkText("Bank Project"));
  21.       //  meniuMygtukasBankProject.click();
  22.  
  23.         driver.findElement(By.linkText("Bank Project")).click();
  24.  
  25.         WebElement idError = driver.findElement(By.id("message23"));
  26.         WebElement pswError = driver.findElement(By.id("message18"));
  27.  
  28.         WebElement idTextField = driver.findElement(By.name("uid"));
  29.         WebElement pswTextField = driver.findElement(By.name("password"));
  30.  
  31.         idTextField.sendKeys("blbalbalbal");
  32.         pswTextField.sendKeys("value", "fffffffffffffffff");
  33.  
  34.  
  35.       //  driver.findElement(By.name("uid")).click();
  36.       //  driver.findElement(By.name("password")).click();
  37.        // driver.findElement(By.tagName("body")).click();
  38.  
  39.         if (idError.getText().equals("User-ID must not be blank"))
  40.         {
  41.             System.out.println("ID kai neįvestas, išveda errorą viskas gerai");
  42.         }
  43.         else
  44.         {
  45.             System.out.println("ID kai neįvestas, erroro neišveda. BLOGAI!");
  46.         }
  47.  
  48.  
  49.         if (pswError.getText().equals("Password must not be blank"))
  50.         {
  51.             System.out.println("PSW kai neįvestas, išveda errorą viskas gerai");
  52.         }
  53.         else
  54.         {
  55.             System.out.println("PSW kai neįvestas, erroro neišveda. BLOGAI!");
  56.         }
  57.  
  58.  
  59.  
  60.  
  61.     }
  62.  
  63.  
  64.     public static void patikrintiArLentelesPlotisKeiciasi(WebDriver driver)
  65.     {
  66.         ArrayList<String> tableBodyPlotis = new ArrayList<>();
  67.  
  68.         WebElement visasPuslapioBody = driver.findElement(By.cssSelector("div > table > tbody"));
  69.         WebElement visasPuslapioBody2 = driver.findElement(By.tagName("tbody"));
  70.  
  71.         System.out.println(visasPuslapioBody.getText());
  72.         System.out.println(visasPuslapioBody2.getText());
  73.  
  74.        /* try
  75.         {
  76.             Thread.sleep(5000);
  77.         }
  78.         catch (InterruptedException e)
  79.         {
  80.             e.printStackTrace();
  81.         }*/
  82.  
  83.         System.out.println(visasPuslapioBody.getCssValue("width"));
  84.         System.out.println(visasPuslapioBody2.getCssValue("width"));
  85.         tableBodyPlotis.add(visasPuslapioBody.getCssValue("width"));
  86.  
  87.  
  88.         driver.manage().window().setSize(new Dimension(1000, 1000));
  89.         tableBodyPlotis.add(visasPuslapioBody.getCssValue("width"));
  90.  
  91.  
  92.         driver.manage().window().setSize(new Dimension(3000, 1000));
  93.         tableBodyPlotis.add(visasPuslapioBody.getCssValue("width"));
  94.  
  95.         if (tableBodyPlotis.get(0).equals(tableBodyPlotis.get(1)))
  96.         {
  97.             System.out.println("Lentelės plotis nepakito pakeitus naršyklės plotį į 1000px");
  98.         }
  99.  
  100.         if (tableBodyPlotis.get(0).equals(tableBodyPlotis.get(2)))
  101.         {
  102.             System.out.println("Lentelės plotis nepakito pakeitus naršyklės plotį į 3000px");
  103.         }
  104.  
  105.         System.out.println(tableBodyPlotis.toString());
  106.     }
  107. }
  108.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement