Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.example;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.support.ui.WebDriverWait;import org.openqa.selenium.support.ui.ExpectedConditions;
- import java.time.Duration;
- public class Main {
- WebDriver driver;
- public void launchBrowser(){
- System.setProperty("webdriver.chrome.driver", "/Users/alaricsecurities/Downloads/chromedriver-mac-x64 3/chromedriver");
- driver= new ChromeDriver();
- driver.get("https://myportal-dev.alaric.bg/");
- WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
- WebElement usernameField = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Username")));
- usernameField.click();
- WebElement passwordField = driver.findElement(By.id("Password"));
- usernameField.click();
- passwordField.sendKeys("Test@123!");
- WebElement loginButton = driver.findElement(By.name("button"));
- loginButton.click();
- WebElement cookies = wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("cky-btn-accept")));
- cookies.click();
- WebElement menuTransfersButtons = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[normalize-space(text())='Трансфери']")));
- menuTransfersButtons.click();
- WebElement buttonZahranvane = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//span[normalize-space(text())='Захранване']")));
- buttonZahranvane.click();
- WebElement inputValue = wait.until(ExpectedConditions.elementToBeClickable(By.id("mat-input-0")));
- inputValue.click();
- inputValue.sendKeys("5000");
- WebElement buttonZahraniSmetka = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(.,'Захрани сметка')]")));
- buttonZahraniSmetka.click();
- String expectedIban = "BG44BPBI79301435353501";
- // Check if IBAN is found in page source (debugging)
- String pageSource = driver.getPageSource();
- if (pageSource.contains(expectedIban)) {
- System.out.println("The IBAN exists in the page source.");
- } else {
- System.out.println("The IBAN does NOT exist in the page source.");
- }
- // Wait for the element to become visible
- //WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20)); // Increase wait time
- WebElement ibanElement = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(text(), '" + expectedIban + "')]")));
- String actualIban = ibanElement.getText().trim();
- System.out.println("Actual IBAN from page: '" + actualIban + "'");
- if (actualIban.equals(expectedIban)) {
- System.out.println("IBAN is correct: " + actualIban);
- } else {
- System.out.println("IBAN mismatch! Expected: " + expectedIban + ", but found: " + actualIban);
- }
- try {
- Thread.sleep(20000);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- driver.quit();
- }
- public static void main(String[] args) {
- Main obj=new Main();
- obj.launchBrowser();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement