public void AddBranchCriteria(String stepName, string targetStepName, string propertyName, string criteriaValue) { var lnkBranchCriteria = new Link( By.XPath("(//*[@id='_webrRSV_DIV_0']/table/tbody/tr/td[3]/a[text()='" + stepName + "" + "'])[1]/../../td[4]/table/tbody/tr/td/table/tbody/tr/td[2]/span[text()='" + targetStepName + "']/../../td[1]/a")); var parentWindow = CurrentWindowTitle; var popup = new BranchCriteriaPopup(); lnkBranchCriteria.Click(); PopUpWindow.SwitchTo(popup.Title); popup.AddBranchCriterion(propertyName, criteriaValue); PopUpWindow.SwitchTo(parentWindow); Wait.Until(d => !PopUpWindow.IsOpen(popup.Title)); Thread.Sleep(1500); WaitForPageLoad(); }