Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- import java.util.Arrays;
- import java.util.List;
- public class ProgramaArturo {
- public static void main(String[] args) {
- System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
- WebDriver driver = new ChromeDriver();
- final String ivestasLogin = "blabla";
- final String fillerLogin = "The username: ";
- final String expectedIsvestasLogin = fillerLogin + ivestasLogin;
- final String ivestasPsw = "bebebe";
- final String fillerPsw = "The password: ";
- final String expectedIsvestasPsw = fillerPsw + ivestasPsw;
- String bazineNuoroda = "http://thedemosite.co.uk/";
- driver.get(bazineNuoroda);
- driver.findElement(By.linkText("3. Add a User")).click();
- WebElement idTextField = driver.findElement(By.name("username"));
- WebElement pswTextField = driver.findElement(By.name("password"));
- idTextField.sendKeys(ivestasLogin);
- pswTextField.sendKeys(ivestasPsw);
- driver.findElement(By.cssSelector("tr:nth-child(3) input")).click();
- WebElement userCredentials = driver.findElement(By.cssSelector("blockquote:nth-child(2) > blockquote"));
- String tempIsvestiInicialai = userCredentials.getText();
- String[] tempDuIsvestiInicialai = tempIsvestiInicialai.split("\n");
- // GALIMA JAU DARYTI VEIKSMUS IŠSYK TOLIAU IR SU MASYVU
- // ARBA GALIMA DAR TĄ MASYVĄ IRGI PASIKEISTI Į LIST, JOG BŪTŲ PATOGIAU
- List<String> isvestiInicialai = Arrays.asList(tempDuIsvestiInicialai);
- System.out.println(isvestiInicialai.toString());
- // Logino tikrinimas
- if (isvestiInicialai.get(0).equals(expectedIsvestasLogin)){
- System.out.println("true");
- System.out.println(isvestiInicialai.get(0));
- System.out.println(expectedIsvestasLogin);
- System.out.println("-------------");
- }
- else {
- System.out.println("false");
- System.out.println(isvestiInicialai.get(0));
- System.out.println(expectedIsvestasLogin);
- System.out.println("-------------");
- }
- // Password tikrinimas
- if (isvestiInicialai.get(1).equals(expectedIsvestasPsw)){
- System.out.println("true");
- System.out.println(isvestiInicialai.get(1));
- System.out.println(expectedIsvestasLogin);
- System.out.println("-------------");
- }
- else {
- System.out.println("false");
- System.out.println(isvestiInicialai.get(1));
- System.out.println(expectedIsvestasLogin);
- System.out.println("-------------");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement