1

The situation is that admin sets the Specified fields for the front end user and it is upon admin to decide how many fields he'll set for the user. One thing is that he can only create 2 types of fields; either Text or Dropdown.

Also, the user can make that field mandatory. Now the question is how can I automate that using selenium and java. I have to check that either these fields are present or not and if present then which type of it and then I have to check that either it is necessary or nor.

Here I am attaching an image from DOM. I think that here Divs has been used. Also, one thing possible is there is an option that Specified Meetings fields may be not present. So I have to first check that either these fields are present or not. So the scenario will be like this:

  • Meeting Specifics fields are present or not
  • The field is of type text or Dropdown
  • The field is necessary or not
  • Either the next field exists or not.

enter image description here

enter image description here

2
  • How do you find out if a field is necessary or not?
    – Moro
    May 2, 2019 at 9:59
  • Here i'm able to see in your DOM that Required field is not directly written in fields tag, so from my code you just need to change that in your way that how your developers are handling Required field. May 2, 2019 at 10:25

2 Answers 2

0

See, i will suggest you that this all is depends on your test cases that what scenarios are they following.

From my point, suppose that if test case start from that your admin has select some number of input and Select fields then you come to your Meeting Specific page and here you will count the number of all fields present here, it means you already well know that what fields will present here with what numbers, so you just need to check that fields.
Here may this code help you:

        List<WebElement> element=driver.findElements(By.tagName("select"));
        Assert.assertEquals(element.size(), 2);
        for(WebElement attr:element)
        {
            Assert.assertEquals(attr.getAttribute("required"), "true");
        }
        List<WebElement> element1=driver.findElements(By.tagName("input"));
        Assert.assertEquals(element1.size(), 1);
        for(WebElement attr1:element1)
        {
            Assert.assertEquals(attr1.getAttribute("required"), "true");
        }  

And in second case if as a admin you have not selected any fields then you already know that on Meeting Specific page there will be no fields, then you just need to verify that no input and select are present.
Here may this code help you-

        List<WebElement> element=driver.findElements(By.tagName("select"));
        Assert.assertEquals(element.isEmpty(), true);

        List<WebElement> element1=driver.findElements(By.tagName("input"));
        Assert.assertEquals(element1.isEmpty(), true);
-1

You just fuel add with the database and manipulation with the data base that is the best option for drop down list

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.