Advertisement
Suzana_Marek

Deposit

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