Advertisement
Suzana_Marek

createDeposit

Jun 18th, 2025
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.26 KB | None | 0 0
  1. package org.example;
  2. import org.openqa.selenium.By;
  3. import org.openqa.selenium.WebDriver;
  4. import org.openqa.selenium.WebElement;
  5. import org.openqa.selenium.chrome.ChromeDriver;
  6. import org.openqa.selenium.support.ui.WebDriverWait;
  7. import org.openqa.selenium.support.ui.ExpectedConditions;
  8. import java.time.Duration;
  9. public class createDeposit {
  10.     WebDriver driver;
  11.     public void launchBrowser() {
  12.         System.setProperty("webdriver.chrome.driver", "/Users/alaricsecurities/Downloads/chromedriver-mac-x64 4/chromedriver");
  13.         driver = new ChromeDriver();
  14.         try {
  15.             driver.get("https://myportal-dev.alaric.bg/");
  16.             WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
  17.  
  18.             WebElement usernameField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Username")));
  19.             usernameField.sendKeys("[email protected]");
  20.  
  21.             WebElement passwordField = driver.findElement(By.id("Password"));
  22.             passwordField.sendKeys("Test@123!");
  23.  
  24.             WebElement loginButton = driver.findElement(By.name("button"));
  25.             loginButton.click();
  26.  
  27.             WebElement cookies = wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("cky-btn-accept")));
  28.             cookies.click();
  29.  
  30.             WebElement menuTransfersButtons = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[normalize-space(text())='Трансфери']")));
  31.             menuTransfersButtons.click();
  32.  
  33.             WebElement buttonZahranvane = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//span[normalize-space(text())='Захранване']")));
  34.             buttonZahranvane.click();
  35.  
  36.             WebElement inputValue = wait.until(ExpectedConditions.elementToBeClickable(By.id("mat-input-0")));
  37.             inputValue.sendKeys("5000");
  38.  
  39.             WebElement buttonZahraniSmetka = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(.,'Захрани сметка')]")));
  40.             buttonZahraniSmetka.click();
  41.  
  42.             String expectedIban = "BG84UNCR70002283869475";
  43.             String pageSource = driver.getPageSource();
  44.             if (pageSource.contains(expectedIban)) {
  45.                 System.out.println("The IBAN exists in the page source.");
  46.             } else {
  47.                 System.out.println("The IBAN does NOT exist in the page source.");
  48.             }
  49.  
  50.             WebElement ibanElement = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(text(), '" + expectedIban + "')]")));
  51.             String actualIban = ibanElement.getText().trim();
  52.             System.out.println("Actual IBAN from page: '" + actualIban + "'");
  53.  
  54.             if (actualIban.equals(expectedIban)) {
  55.                 System.out.println("IBAN is correct: " + actualIban);
  56.             } else {
  57.                 System.out.println("IBAN mismatch! Expected: " + expectedIban + ", but found: " + actualIban);
  58.             }
  59.         } catch (Exception e) {
  60.             e.printStackTrace();
  61.         } finally {
  62.             driver.quit();
  63.         }
  64.     }
  65.     public static void main(String[] args) {
  66.         createDeposit obj=new createDeposit();
  67.         obj.launchBrowser();
  68.  
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement