Suggestion in handling the dependent fields in frame work.

43 views
Skip to first unread message

GuruKrishna

unread,
Mar 14, 2015, 12:18:56 PM3/14/15
to webd...@googlegroups.com
Hi All,

I am working in an application which is completely ajax based...i.e lots of fields are dependent on some other fields and settings.

While creating normal selenium scripts,i have to use lot of if/else condition.

How will I handle this situation while creating a hybrid /Keyword Framework ?

Please suggest
.
Thanks
Guru


--





darrell

unread,
Mar 15, 2015, 11:24:09 AM3/15/15
to webd...@googlegroups.com
Not entirely clear on how you used to handle this with if/else conditions. Regardless, if selecting something from one field alters another field I would simply use WebDriverWait to wait for the expected value on the second element. For example, if I select Country as "United States" then the Language field changes to have "Español". I would not tie the Country and Language fields together in my automation. I would simple look for the value "Español" on the State field. For example,

    WebDriver driver;
    WebDriverWait wdw;

    @Before
    public void setup() {
        // initialize driver and wdw here
    }

    @Test
    public void test32() {
        driver.get("http://www.aircanada.com");
        By country = By.cssSelector("#SITEVALUE [value='US']");
        SelectElement(country);
        By language = By.cssSelector("#LANGVALUE [value='Español']");
        SelectElement(language);
    }

    private void SelectElement(By option) {
        wdw.until(ExpectedConditions.presenceOfElementLocated(option));
        driver.findElement(option).click();
    }

I would also put in an option to take a screen capture if an exception is thrown. This way if selecting the country did not update the language, the test will fail on selecting the language with a NoSuchElementException. My exception handler would then take a screen capture and I would hopefully see that selecting country was wrong. Worse case I would step through the automation and see the language field isn't updated even when the correct country is selected.

GuruKrishna

unread,
Mar 15, 2015, 2:55:19 PM3/15/15
to webd...@googlegroups.com

Hi Darrell,
Thanks for your valuable update.
But in my case,
In my case...if US is selected some extra three field will appear in the UI but if some other country z selected then some more fields will appear.In my frane work I may select us or uk.and these fields i am pasding through the excel sheet.So hiw will i Handle these ?

Thanks
Guru

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.

SuperKevy

unread,
Mar 17, 2015, 10:50:14 AM3/17/15
to webd...@googlegroups.com

SuperKevy

unread,
Mar 17, 2015, 10:51:57 AM3/17/15
to webd...@googlegroups.com
How will I handle this situation while creating a hybrid /Keyword Framework ? 

What do you mean hybrid/keyword framework?
Reply all
Reply to author
Forward
0 new messages