I have the following Inspected element Id for a dropdown with a few fields in a UI screen.
DropDown values:
- List item1
- List item2
- List item3
Inspected Element ID:
<select id="form1:PartialSysAdminKey_adminContractIdField" name="form1:PartialSysAdminKey_adminContractIdField" class="selectOneMenu" size="1">
There will be cases when the drop down will hold no values.
I need to display a sysout log, only when this drop down has atleast one value.
Can someone please suggest how can I incorporate this in my Selenium testing?
Currently, I have this following code that checks whether the server is up and tests a login.
package testPackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class TestClass {
    public static void main(String[] args) {
        ChromeOptions options = new ChromeOptions();
        options.addArguments("headless");
        System.setProperty("webdriver.chrome.driver", "D:\\Softwares\\chromedriver_win32\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://bigdata/steward.jsp");
        if (driver.getTitle().equalsIgnoreCase("Login")) {
                serverStatus = "UP";
        } else {
            serverStatus = "DOWN";
        }
        System.out.println("Server is " + serverStatus + ".");
        if (serverStatus.equalsIgnoreCase("UP")) {
            driver.findElement(By.id("username")).sendKeys("username");
            driver.findElement(By.id("password")).sendKeys("password");
            driver.findElement(By.id("login")).click();
            String newUrl = driver.getCurrentUrl();
            if (newUrl.equalsIgnoreCase("https://bigdata/error.jsp")) {
                System.out.println("Incorrect username/password.");
            } else {
                System.out.println("Logged in successfully.");
            }
        } else {
            System.out.println("Login could not be done.");
        }
        driver.quit();
    }
}
 
     
     
     
     
    