Hi guys I have been trying to automate our Web browser, I have the Main class where I call all my classes that I create as soon as I run the Test, the open_Browser will run and when its done it will just stop there but I have called the other function in side of the main aswell.
theres code of my Main:
public static void main(String[] args) {
openWeb();
testCase001();
}
//This function called the OpenSystemAdmin class.
public static void openWeb() {
OpenSystemAdmin open = new OpenSystemAdmin();
open.openWeb();
open.pressAdminLoginButton();
}
//This function called the TestCaseWithValidDetails class.
public static void testCase001() {
TestCaseWithValidDetails testCase = new TestCaseWithValidDetails();
testCase.testCaseWithValidDetails1();
}
package System_Admin_Tests;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import static System_Admin_Tests.ScreenShot_Function.screenShot;
import static System_Admin_Tests.ScreenShot_Function.screenShotNames;
import static org.openqa.selenium.By.id;
public class TestCaseWithValidDetails {
public static WebDriver driver;
//TestCase ID : LogIn_001
//Test Description : Verify that the logIn function works with the right details.
public static void testCaseWithValidDetails1() {
//username
WebElement username = driver.findElement(id("edmail"));
username.sendKeys("email");
//Password
WebElement password = driver.findElement(id("email"));
password.sendKeys("password");
/*
Enter Button
try {
Thread.sleep(2000);
screenShot(driver, "Screenshots_LogIn.Passes //" + screenShotNames());
} catch (Exception e) {
throw new RuntimeException(e);
}
*/
OpenSystemAdmin.enterButton();
/*
try {
screenShot(driver, "Screenshots_LogIn.Passes //" + screenShotNames());
} catch (Exception e) {
throw new RuntimeException(e);
}
System.out.println("Login in test passed");
*/
}
}
this is my OpenSystemAdmin code:
public class OpenSystemAdmin {
public static WebDriver driver;
public static void openWeb() {
try {
System.setProperty("driverChromeDriver",
".mvn/chromedriver");
driver = new ChromeDriver();
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.get("https://mrflutter.000webhostapp.com/");
} catch (Exception e) {
e.printStackTrace();
}
}
//This function is there to press the System Admin button on the home screen.
public static void pressAdminLoginButton() {
WebElement pressSystemAdmin = driver.findElement(By.linkText("SYSTEM ADMIN"));
pressSystemAdmin.click();
}
//Some Added functions:
//EnterButton
public static void enterButton() {
driver.findElement(By.cssSelector("button[type='submit']")).click();
}
I was expecting it open Web Browser and the click on System Admin then enter the username and password then click enter to signing.