The script runs perfectly if executed alone, but fails when it is joined together
Hi All,
I have wriiten a script to select colors/options for various dropdown fields as below. When i execute each field separately, it opens the dropdown box and selects the required option but when executed together, it fails after the first dropdown color select and the error message says "Out of the window bounds". Any idea why???
function otherBranchdet(){
page = browser.Page("*");
//Solid Fill Color
page.FindElement("#Form_EditForm_SolidFillID_chosen > .chosen-single").Click();
page.FindElement("//li[contains(text(), 'ABC- Solid fill ( #823A22 )')]").Click();
//Light Tint Fill color
page.FindElement("#Form_EditForm_LightTintFillID_chosen > .chosen-single").Click();
page.FindElement("//li[contains(text(), 'ABC- Light tint fill ( #F3EBE9 )')]").Click();
//Darker Tint Fill color
page.FindElement("#Form_EditForm_DarkerTintFillID_chosen > .chosen-single").Click();
page.FindElement("//li[contains(text(), 'ABC- Darker tint fill ( #DAC4BD )')]").Click();
//Lines on Light Tint Fill color
page.FindElement("#Form_EditForm_LinesOnLightTintFillID_chosen > .chosen-single").Click();
page.FindElement("//li[contains(text(), 'ABC- Light line tint fill ( #DAC4BD )')]").Click();
//Lines on Darker Tint Fill color
page.FindElement("#Form_EditForm_LinesOnDarkerTintFillID_chosen > .chosen-single").Click();
page.FindElement("//li[contains(text(), 'ABC- Dark line tint fill ( #C19D91 )')]").Click();
//Header Search Input fill color
page.FindElement("#Form_EditForm_SearchInputFillID_chosen > .chosen-single").Click();
page.FindElement("//li[contains(text(), 'ABC- Light line tint fill ( #DAC4BD )')]").Click();
}
Hi All,
So i found out the root cause of the issue. Since all the drop down fields have same values, when it selects a value from the first drop down field, it stores that field's dom values or bounday values and though it opens the second drop down, it searches for the values in first drop down and since it couldn't find it, the test gave me out of the bounds error.
Therefore, I made my xpath element more absolute(teels it in which dropdown, it should look for the values) and it resolved the issue.
Hope it helps.