Ich starte meinen ersten automatisierten Test mit selen webdriver in Eclipse auf einer statischen Demo-Site. Der Hauptzweck des Tests besteht darin, zu zeigen, dass eine Transaktion in meiner Protokolldatei bestätigt wird, z. sollte etwas wie "Bestätigung erhalten"/oder nicht sagen? Dies sollte kommt nach dem folgenden Schritt:Erster automatisierter Authentifizierungstest mit Selenium Webdriver in Eclipse
"// Finden Taste zur Bestätigung und klicken Sie darauf driver.findElement (By.id (" next ")) klicken(); logger.info (" Click Confirmar Taste");"
Allerdings bin ich nicht ganz sicher, welchen Code zu verwenden, um dieses Ergebnis zu erhalten. Nach dem Klicken auf diese Schaltfläche wird eine Bestätigungsmeldung angezeigt. Ich möchte überprüfen, dass die Transaktion irgendwie funktioniert hat, und wenn es nicht erhalten wurde, möchte ich auch eine Benachrichtigung, die das sagt.
Kann mir jemand dabei helfen ??
komplette Code unten:
package com.scotia.test;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.xml.DOMConfigurator;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class ScotiaTest1 {
@Test
@Parameters("test1")
public void beforeTest(@Optional("optional") String type)
{
System.out.println("Type in Before Test is="+type);
}
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver","/Users/theone/Downloads/chromedriver-new");
Logger logger=Logger.getLogger("Test1");
DOMConfigurator.configure("log4j.xml");
// Create a new instance of the Chrome driver
WebDriver driver = new ChromeDriver();
logger.info("Chrome opened");
//Login using Username and Password
driver.get("https://username:[email protected]/_Prototype/desktop/html/Chile_index.html#");
logger.info("Application Launched");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//Find Proximity Serie A link and click on it
driver.findElement(By.cssSelector("#investing_tab tr:nth-child(7) a.acct-name")).click();
logger.info("Click Proximidad Serie A");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//Find New Funds Button and click on it
driver.findElement(By.cssSelector(".pad-top-10.txt-right .btn.action-btn")).click();
logger.info("Click Button Nuevo Fondo");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//Select Field Rescue investment and choose Rescue
Select dropdown = new Select(driver.findElement(By.id("mf_action")));
dropdown.selectByVisibleText("Inversión");
logger.info("Select Inversión from dropdown");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//Select Field Current account and choose current account
dropdown = new Select(driver.findElement(By.id("selaccount_drpdown")));
dropdown.selectByVisibleText("Cuenta Corriente *** 0002 USD 10.000,00");
logger.info("Select Cuenta Corriente *** 0002 USD 10.000,00 from dropdown");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//Select Field Fund Type and choose medium term
dropdown = new Select(driver.findElement(By.id("term")));
dropdown.selectByVisibleText("Deuda de Mediano y Largo Plazo");
logger.info("Select Deuda de Mediano y Largo Plazo from dropdown");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//Select Field Mutual Fund Name and choose Proximity Series A
dropdown = new Select(driver.findElement(By.id("typefund")));
dropdown.selectByVisibleText("Proximidad Serie A");
logger.info("Select Proximidad Serie A from dropdown");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//Select Field Fund account Name and choose 001
dropdown = new Select(driver.findElement(By.id("sub_accnt")));
dropdown.selectByVisibleText("001");
logger.info("Select 001 from dropdown");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//Select Field Rode and type 222
driver.findElement(By.id("amount_field")).sendKeys("222");
logger.info("Type 222 in Monto text feild");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//Find to Accept Button and click on it
driver.findElement(By.id("next")).click();
logger.info("Click Aceptar button");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//Find to Confirm Button and click on it
driver.findElement(By.id("next")).click();
logger.info("Click Confirmar Button");
//Wait for 1 Sec
Thread.sleep(1000);
logger.info("Pause Execution for 1 second");
//driver.findElement(By.cssSelector("RUIFW-alert-success.getText()"));(does not do anything)
// Close browser
driver.quit();
logger.info("Close Browser");
}