0

here situation is like that admin set the Specified fields for front end user and its upon admin that how many fields he set for user. One thing is that he can only create 2 types of fields either Text or Drop down.
Also user can set that field mandatory. Now question is that how I can automate using selenium 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 image from DOM. I think that here Divs has been used. Also one thing that there is option that may be Specified Meetings fields are not present So I have to first check that either these fields are present or not. So scenario will be like this. => Meeting Specifics fields are present or not => Field is of type text or Drop down => Field is necessary or not. => Either next field is exist or not.

enter image description here

enter image description here

  • How do you find out if a field is necessary or not? – Moro May 2 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. – Upkar Singh May 2 at 10:25
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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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