private void SearchPI_Click(object sender, RoutedEventArgs e) { //1 searched UATools.SearchXPathAndClickEnterText(ref Drv, @"//input", PI_FSP.Text); PI_FSP.Clear(); try { //2 click on checkbox UATools.SearchXPathAndClick(ref Drv, "//input[@type='checkbox']"); //3 click on button System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.5)); IWebElement ActToDo = Drv.FindElement(By.XPath("//div[@class='bottom-xs']/div/div[2]/div/div/button")); ActToDo.Click(); //4 click on Doc System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.5)); IWebElement DocPI = Drv.FindElement(By.XPath("//span[@index]")); DocPI.Click(); //5 ActToDo inside PI System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.5)); ReadOnlyCollection <IWebElement> buttons = Drv.FindElements(By.XPath("//button")); int size = buttons.Count; System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.5)); buttons[size - 1].Click(); //6 Add Doc ReadOnlyCollection <IWebElement> span = Drv.FindElements(By.XPath("//span")); int size_span = span.Count; System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1)); span[size_span - 1].Click(); } catch (Exception) { ; } }